Multiple Temp Sensor (ds18b20)

Hi

I am trying to read multiple ds18b20 temperature sensors with the SC and I am using a basic program that worked for me on the arduino. The sketch keeps hanging on the print address function. The error reads; ‘DeviceAddress’ was not declared in this scope

I know the answer has got to be simple but has eluded me so far. The code is below.

Thanks

#include "spark-dallas-temperature/spark-dallas-temperature.h"
#include "OneWire/OneWire.h"

#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = {0x28, 0xD4, 0xFA, 0xB3, 0x5, 0x0, 0x0, 0x31};
DeviceAddress outsideThermometer = {0x28, 0x2A, 0x63, 0x50, 0x5, 0x0, 0x0, 0xD5};

void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 8; i++)
{
// zero pad the address if necessary
if (deviceAddress[i] < 16) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
}
}

added formatting (@mdma)

It could be the preprocessor messing with the code - it’s not super smart about what it does. Try adding

#pragma SPARK_NO_PREPROCESSOR

at the top of your sketch.

Great it worked. Thank you but now I have another question. How did you know that and where can i read about it?

1 Like

I know this because I was told :slight_smile: I don’t think there’s any public docs for this, so I created an issue. https://github.com/spark/docs/issues/259

2 Likes