Config Parameters are note set/received

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
DerLexus
Posts: 15
Joined: 03 Sep 2017 14:38

Config Parameters are note set/received

Post by DerLexus » 07 Nov 2017 21:46

Hi there,

I tried to extend my sketch for my weather sensor with 4 parameters for compensation of measured values. It seems to be really simple, but as always problems occurs :(

It seems that the configuration callback isn't called at all. At least my parameters are not changing. I tried to add a Serial.print to the function but I doesn't get anything (can it be that Serial isn't allowed in callbacks, I remember I've read somewhere about that).

Do you have any other tips to try?

I can post my sketch if this helps and I'm on 1.6.5.

Thank you, bye!

User avatar
PoltoS
Posts: 3887
Joined: 26 Jan 2011 19:36

Re: Config Parameters are note set/received

Post by PoltoS » 07 Nov 2017 21:48

Have you tried the example presented here: http://z-uno.z-wave.me/Reference/ZUNO_S ... R_HANDLER/ ?

p0lyg0n1
Posts: 113
Joined: 04 Aug 2016 07:14

Re: Config Parameters are note set/received

Post by p0lyg0n1 » 08 Nov 2017 00:13

Post your sketch here, or you can send me it by means of PM. Don't worry, we will help you. :-)

DerLexus
Posts: 15
Joined: 03 Sep 2017 14:38

Re: Config Parameters are note set/received

Post by DerLexus » 08 Nov 2017 11:25

No problem, there is no magic in it :)

I attached it because of the 2 needed local libs.

@Poltos: I copied the example more or less from the blinking sample and changed it a bit. Maybe it has todo with the zuno sleep but I tried it without that and the problem is the same.
Attachments
zwave_weathersensor.zip
(8.32 KiB) Downloaded 15 times

DerLexus
Posts: 15
Joined: 03 Sep 2017 14:38

Re: Config Parameters are note set/received

Post by DerLexus » 10 Dec 2017 19:30

Does someone have a working example of user channels?

p0lyg0n1
Posts: 113
Joined: 04 Aug 2016 07:14

Re: Config Parameters are note set/received

Post by p0lyg0n1 » 13 Dec 2017 17:56

Hi,
I am sorry. We have a lot of work with new release and have no time to reply fast.
So, I tried your code. It works with my Razberry controller fine (configuration parameters work, I don't have a sensors I just comment all the sensor code).
See the attached screenshot.
The code is

Code: Select all

//#include "BH1750.h"
//#include "BME280.h"

#include <Wire.h>

//BME280 bme280; // Temp/Hum/Pressure Sensor BME280
//BH1750 bh1750; // Light Sensor BH1750

#define MAX_DWORD 4294967295

//#define DEBUG
#define MY_SERIAL Serial0
ZUNO_SETUP_DEBUG_MODE(DEBUG_ON);

// set up channel
ZUNO_SETUP_CHANNELS(
      // Temperature
      ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE,
                             SENSOR_MULTILEVEL_SCALE_CELSIUS,  
                             SENSOR_MULTILEVEL_SIZE_TWO_BYTES, 
                             SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS, 
                             getterTemp),
                             
      // Pressure
      ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_BAROMETRIC_PRESSURE ,
                             SENSOR_MULTILEVEL_SCALE_KILO_PASCAL,  
                             SENSOR_MULTILEVEL_SIZE_FOUR_BYTES, 
                             SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS, 
                             getterPressureKiloPascal),
      // Hum
      ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_RELATIVE_HUMIDITY ,
                             SENSOR_MULTILEVEL_SCALE_PERCENTAGE_VALUE ,  
                             SENSOR_MULTILEVEL_SIZE_ONE_BYTE, 
                             SENSOR_MULTILEVEL_PRECISION_ZERO_DECIMALS, 
                             getterHum),
      // Light
      ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_LUMINANCE,
                             SENSOR_MULTILEVEL_SCALE_LUX,  
                             SENSOR_MULTILEVEL_SIZE_TWO_BYTES, 
                             SENSOR_MULTILEVEL_PRECISION_ZERO_DECIMALS, 
                             getterLight)

      
);

//ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_SLEEPING);
ZUNO_SETUP_BATTERY_LEVELS(2400,3000);

dword lightLuxComp = 0, tempDegreesComp = 0, pressureKiloPascalComp = 0,humPercentComp = 0;

long  lightLux = 0,lightLuxOld = 0;
word  tempDegrees = 0,tempDegreesOld = 0;
long  pressureKiloPascal = 0,pressureKiloPascalOld = 0;
byte  humPercent = 0,humPercentOld = 0;

void config_parameter_changed(byte param, dword * value)
{
    switch(param)
    {
      case 64:  // Light
        lightLuxComp = *value;
        break; 
      case 65:  // Temperature
        tempDegreesComp = *value;
        if (tempDegreesComp>10000) tempDegreesComp=10000;
        break; 
      case 66:  // Pressure
        pressureKiloPascalComp = *value;
        if (pressureKiloPascalComp>10000) pressureKiloPascalComp=10000;
        break; 
      case 67:  // Humidity
        humPercentComp = *value;
        if (humPercentComp>100) humPercentComp=100;
        break; 
    }
}

ZUNO_SETUP_CFGPARAMETER_HANDLER(config_parameter_changed);

void setup() 
{
  #ifdef DEBUG
  Serial.begin();
  #endif


  zunoLoadCFGParam(64,&lightLuxComp);
  lightLuxComp=(lightLuxComp==MAX_DWORD)?0:lightLuxComp;
  
  MY_SERIAL.println(lightLuxComp);
  zunoLoadCFGParam(65,&tempDegreesComp);
  tempDegreesComp=(tempDegreesComp==MAX_DWORD)?0:tempDegreesComp;
  
  zunoLoadCFGParam(66,&pressureKiloPascalComp);
  pressureKiloPascalComp=(pressureKiloPascalComp==MAX_DWORD)?0:pressureKiloPascalComp;
  
  zunoLoadCFGParam(67,&humPercentComp);
  humPercentComp=(humPercentComp==MAX_DWORD)?0:humPercentComp;

  //Wire.begin();
}

void readLightSensor()
{
 /* bh1750.begin(BH1750_ONE_TIME_HIGH_RES_MODE, BH1750_I2CADDR_LOW);
  delay(180); // delay for meassurement of bh1750
  bh1750.readLightLevel();
  lightLux = bh1750.lightLux + lightLuxComp;*/
}

void readTempSensor()
{
  /*
  bme280.begin();
  bme280.setOversampling(4);


  
  char result = bme280.startMeasurement();

  if (result == 0)
  {
    #ifdef DEBUG
    Serial.println("BMx280: Initialisierungsfehler");
    #endif
    return;
  }

  tempDegrees = bme280.getTemperature100() + tempDegreesComp;
  pressureKiloPascal = (bme280.getPressure100()/10.0) + pressureKiloPascalComp; // x/1000*100 = x/10
  humPercent = max(100,bme280.getHum() + humPercentComp);*/
}

void sendData()
{
  #ifdef DEBUG
    Serial.print("Params: ");
    Serial.print(lightLuxComp);
    Serial.print(", ");
    Serial.print(tempDegreesComp);
    Serial.print(", ");
    Serial.print(pressureKiloPascalComp);
    Serial.print(", ");
    Serial.println(humPercentComp);
  #endif
  
  #ifdef DEBUG
    Serial.print("Light       ");
    Serial.print(lightLux);
    Serial.println(" Lux");
    
    Serial.print("Temperature ");
    Serial.print(tempDegrees/100.0); 
    Serial.println(" C");
  
    Serial.print("Pressure    ");
    Serial.print(pressureKiloPascal/10); 
    Serial.println(" kPa");
  
    /*if(bme280.chip_id == 96) 
    {
      Serial.print("Humidity    ");
      Serial.print(humPercent); 
      Serial.println(" %");
    }*/
  #endif 
  
  if (tempDegreesOld != tempDegrees)
  {
    zunoSendReport(1);
    tempDegreesOld = tempDegrees;
  }
  
  if (pressureKiloPascalOld != pressureKiloPascal) 
  {
    zunoSendReport(2);
    pressureKiloPascalOld = pressureKiloPascal;
  }
  
  if (humPercent != humPercentOld) 
  {
    zunoSendReport(3);
    humPercentOld = humPercent;
  }
  
  if (lightLux != lightLuxOld)
  {
    zunoSendReport(4);
    lightLuxOld = lightLux;
  }
  
}

word getterLight() 
{ 
  return lightLux;
}

word getterTemp() 
{
  return tempDegrees;
}

long getterPressureKiloPascal() 
{
  return pressureKiloPascal;
}

byte getterHum() 
{
  return humPercent;
}

void loop() 
{
  #ifdef DEBUG
  delay(5000);  // time to open the serial console to view debug messages
  #endif

  readLightSensor();
  readTempSensor();
  sendData();
 

  zunoSendDeviceToSleep();
}
It looks like I know the reason why it's not working on your board. May be you use the prerelease version(2.1.1 from test-ucxx). Please try to reinstall the latest stable version from the main URL(http://rus.z-wave.me/files/z-uno/packag ... index.json). To reinstall Z-Uno packages you have to do this:
1. Remove Z-Uno package folder from Arduino (sometthing like <...>/Arduino15/packages/Z-Uno and <...>/Arduino15/packages/staging/Z-Uno - you will see it if you tap to "preferences.txt" link in preferences window of Arduino )
2. Check that you have the right URL in "Additionals Board Manager URLs".
3. Install Z-Uno board (release 2.1.1) using "Board manager".


Alex.
Attachments
Снимок экрана 2017-12-13 в 17.52.40.png
Снимок экрана 2017-12-13 в 17.52.40.png (88.61 KiB) Viewed 237 times

Post Reply