Hi all,
hoping someone has the magic idea here - I got stuck with this one.
I'm trying to use a (currently unknown) DallasTemperature sensors. Got the latest Arduino 1.0.1 compatible libraries for DT sensors and for oneWire, all set.
I'm trying to setup an array of these sensors, such as
...
#include <DallasTemperature.h>
#include <OneWire.h>
#define ONE_WIRE_BUS 7
OneWire oneWire(ONE_WIRE_BUS); // start OneWire interface on digital pin 7
#define SensorCount 5
// typedef uint8_t DeviceAddress[8];
DeviceAddress tmp; // a device address
DeviceAddress DevAddress[SensorCount]; // an array of 5 device addresses
DallasTemperature Sensors(&oneWire); // hookup sensors via oneWire interface
...
void setup(){
// setup serial speed for serial monitor
Serial.begin(9600);
...
// setup DallasTemperature Sensors
// start sensor library
Sensors.begin();
// find sensors by searching oneWire bus
oneWire.reset_search();
for (int i=0; i<SensorCount-1; i++)
{
// assigns the next address found to tmp
if (!oneWire.search(tmp)) // store whatever found in tmp
{
// oops ... fault
}
else
{
// success
DevAddress[i] = tmp;
}
}
...
Sensors.setResolution(12); // 12 bit, 0.06 deg C
...
};
Alas, it doesnt compile... with
sketch_mar01a.cpp: In function ‘void setup()’:
sketch_mar01a.cpp:61:23: error: invalid array assignment
I think part of the cause of the problem is that the DallasTemperature class (DallasTemperature.h) defined the type DeviceAddress as an array, and I am somehow pointing to the wrong parts of it:
typedef uint8_t DeviceAddress[8];
So that means my
DeviceAddress DevAddress[SensorCount]; // an array of 5 device addresses
is actually a
uint8_t DevAddress[8][SensorCount];
or a
uint8_t DevAddress[SensorCount][8];
which it doesn't like.
So my main question is - any ideas on how to define an array of addresses, each address pointing to a DeviceAddress which really is an array of [8] uint8_t's ? I've tried defining and array of pointers, such as
DeviceAddress* devAddress[SensorCount]
...
tmp = new DeviceAddress;
devAddress[i] = tmp;
but that only produces garbage as well ...
Any clever ideas?
Thanks in advance,
Otte