Which library must be included for the use of ZUNO_DYNAMIC_CHANNELS

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
KGBEl
Posts: 35
Joined: 21 Feb 2023 00:37

Which library must be included for the use of ZUNO_DYNAMIC_CHANNELS

Post by KGBEl »

I copied this code from github for my Z-Uno 2 and recived a lot of errors during verification in Arduino IDE.

The first error was:
"sketch_feb25b.ino:17:22: error: expected constructor, destructor, or type conversion before '(' token
byte number_of_sensors; // Number of sensors found"

Where line 17 is ZUNO_DYNAMIC_CHANNELS(MAX_SENSORS);

My guess is that I don't included the right library but...?


// Multiple temperature sensors DS18B20

#include "ZUNO_DS18B20.h"


#define DS18B20_BUS_PIN 11 // Pin to which 1-Wire bus is connected
#define MAX_SENSORS 1 // Number of DS18B20 sensors supported (equals to maximum number of channels for Z-Uno)

OneWire ow(DS18B20_BUS_PIN); // Software 1-Wire BUS
DS18B20Sensor ds18b20(&ow); // connect DS18B20 class to it

#define ADDR_SIZE 8 // Size of address of devices on 1-wire bus
byte addresses[ADDR_SIZE * MAX_SENSORS]; // Here we store all the scanned addresses
#define ADDR(i) (&addresses[i * ADDR_SIZE]) // Macro to simplify our life
byte number_of_sensors; // Number of sensors found

ZUNO_DYNAMIC_CHANNELS(MAX_SENSORS);

ZUNO_ENABLE(WITH_CC_SENSOR_MULTILEVEL);

void setup() {

// Scanning sensors on the bus every time we starting a sketch
delay(1000);
number_of_sensors = ds18b20.findAllSensors(addresses);

if (number_of_sensors > MAX_SENSORS)
number_of_sensors = MAX_SENSORS;

// Setting up Z-Uno channels dynamically
// You have to exclude/include your Z-Uno to this take effect on the controller side
ZUNO_START_CONFIG();
for (byte i = 0; i < number_of_sensors; i++) {
if (i == 0) {
ZUNO_SET_ZWCHANNEL(0x81);
} else {
ZUNO_SET_ZWCHANNEL(i+1);
}
// Each channel is temperature sensor
ZUNO_ADD_CHANNEL(
ZUNO_SENSOR_MULTILEVEL_CHANNEL_NUMBER,
ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE,
SENSOR_MULTILEVEL_PROPERTIES_COMBINER(
SENSOR_MULTILEVEL_SCALE_CELSIUS,
SENSOR_MULTILEVEL_SIZE_TWO_BYTES,
SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS
));
}
// Commit configuration that we made...
ZUNO_COMMIT_CONFIG();
}

void loop(){
for (byte i = 0; i < number_of_sensors; i++) {
// Read temperature
g_channels_data.wParam = ds18b20.getTempC100(ADDR(i));

// Send report
zunoSendReport(i + 1); // Channels start from 1
}

// We have to wait 30 seconds. It's a requirement of the Z-Wave protocol
delay(30000);
}
amatilda
Posts: 61
Joined: 26 Sep 2021 22:09

Re: Which library must be included for the use of ZUNO_DYNAMIC_CHANNELS

Post by amatilda »

KGBEl wrote:
27 Feb 2023 16:39
I copied this code from github for my Z-Uno 2 and recived a lot of errors during verification in Arduino IDE.

The first error was:
"sketch_feb25b.ino:17:22: error: expected constructor, destructor, or type conversion before '(' token
byte number_of_sensors; // Number of sensors found"

Where line 17 is ZUNO_DYNAMIC_CHANNELS(MAX_SENSORS);

....
Hello.
This method of dynamic channel creation is not supported in Z-Uno 2. Use this:
https://z-uno.z-wave.me/Reference/zunoS ... iguration/
KGBEl
Posts: 35
Joined: 21 Feb 2023 00:37

Re: Which library must be included for the use of ZUNO_DYNAMIC_CHANNELS

Post by KGBEl »

Thank you amatilda, makes my life a better life!
Post Reply