resolver101757:
Thanks for the post, the example didnt work but you did give me a idea, i just passed 2 values, the object and the name.printTemperature(Probe04, "Probe04");
and on the function side :
void printTemperature(DeviceAddress deviceAddress, wchar_t deviceName)
I am keen to understand how your method works as it looks a lot neater than mine.
Thanks
did it print anything?
here is a revised version:
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
#define TEMP_INTERVAL 30000
#define DALLAS_CONVERT_MILLIS 750
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
struct SensorID{
DeviceAddress address;
char* friendlyName;
float tempC;
};
SensorID Probe[] = {
{{ 0x28, 0xFF, 0xFB, 0xD6, 0xA2, 0x16, 0x04, 0x08 }, "Einstein"},
{{ 0x28, 0xFF, 0x4F, 0xD5, 0xA2, 0x16, 0x04, 0xD0 }, "Heisenberg"},
{{ 0x28, 0x13, 0xBB, 0x03, 0x00, 0x00, 0x80, 0x27 }, "Newton"},
{{ 0x28, 0xFF, 0xDF, 0xAC, 0xA2, 0x16, 0x04, 0x5C }, "Euler"},
};
void setup()
{
Serial.begin();
sensors.begin();
for (auto p : Probe)
{
sensors.setResolution(p.address, 10);
}
}
void loop()
{
static unsigned long lastTempMillis = 0;
if (millis() - lastTempMillis > TEMP_INTERVAL)
{
sensors.requestTemperatures();
delay(DALLAS_CONVERT_MILLIS);
for (byte i = 0; i < sizeof(Probe)/sizeof(Probe[0]); i++)
{
Probe[i].tempC = sensors.getTemp(Probe[i].address);
Serial.print(F("Sensor: "));
Serial.print(Probe[i].friendlyName);
Serial.print(F("\t"));
Serial.println(Probe[i].tempC);
}
lastTempMillis = millis();
}
}