I mean
Code: Select all
byte sensor_addresses[][8] = {
{0x28, 0x1C, 0xD7, 0x3B, 0x05, 0x00, 0x00, 0xDE},
{0x28, 0x43, 0x9C, 0x3B, 0x05, 0x00, 0x00, 0x4D}
};
Code: Select all
#include "Arduino.h"
// Multiple temperature sensors
#include <ZUNO_DS18B20.h>
// DS18B20 pin connections
#define PIN_OW 9 // this is s_pin number and it have to be in range[9;16]
// We can connect a lot of 1-wire devices to 1-pin
// Because 1-wire is BUS with addresses
OneWire ow(PIN_OW);
// We need only one sensor in one moment of time to read it, so just
// create one object of it
DS18B20Sensor sen18b20(&ow);
// Currrently uCxx (v 0.810) doesn't support an array of constructed object
// But you can use an array of pointers to object
// For example in terms of 18b20:
// DS18B20Sensor sen1(&ow);
// DS18B20Sensor sen2(&ow);
// DS18B20Sensor * sensors[] = {&sen1, &sen2};
// Anyway you don't need it ^ here :)
// Instead of it we have to know adresses of all sensors that you connect to your 1-Wire bus.
// You can detect it if you connect it alone to the BUS one by one and record them addresses
// use scanAloneSensor() it returns 8-byte unique address of sensor connected to the BUS and fill sensor_addresses. This addresses is unique for any 1-wire device.
#define NUMBER_OF_SENSORS 2
#define ADDR_SIZE 8
void setup();
WORD getterTemp1();
WORD getterTemp0();
void loop();
byte sensor_addresses[][8] = {{0,1,2,3,4,5,6,7},{1,2,3,4,5,7,8}};
int temp[NUMBER_OF_SENSORS];
ZUNO_SETUP_CHANNELS(
ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE, SENSOR_MULTILEVEL_SCALE_CELSIUS, SENSOR_MULTILEVEL_SIZE_TWO_BYTES, SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS, getterTemp0),
ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE, SENSOR_MULTILEVEL_SCALE_CELSIUS, SENSOR_MULTILEVEL_SIZE_TWO_BYTES, SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS, getterTemp1));
struct s1{
byte b1;
};
struct s2 {
s1 s;
byte b2;
};
void setup() {
Serial.begin();
Serial.println("start");
}
void loop()
{
// use byte instead of int to reduce code size
for (byte i=0; i<NUMBER_OF_SENSORS; i++)
{
// Use fixed point math
// get temperature of sensor with address sensor_addresses[i]
temp[i] = sen18b20.getTempC100(sensor_addresses[i]);
Serial.print("Sensor ");
Serial.print(i);
Serial.print(" address is: ");
for (byte j = 0; j < ADDR_SIZE; j++)
{
Serial.print(sensor_addresses[i][j], HEX);
Serial.print(" ");
}
Serial.println();
Serial.print("Temperature: ");
Serial.println(temp[i]/100.0);
Serial.println();
// Sending report to the right channel
zunoSendReport(1 + i);
}
delay(30000);
}
word getterTemp0()
{
return temp[0];
}
word getterTemp1()
{
return temp[1];
}
Code: Select all
// <...>
cxx__class__OneWire ow;
cxx__class__DS18B20Sensor sen18b20;
unsigned char sensor_addresses[][8] = {{0, 1, 2, 3, 4, 5, 6, 7}, {1, 2, 3, 4, 5, 7, 8}};
int temp[2];
// <...>