# Multiple Temp Sensor (ds18b20)

**URL:** <https://community.particle.io/t/multiple-temp-sensor-ds18b20/8912>\
**Category:** uncategorized\
**Created:** [December 20, 2014, 2:46pm UTC](https://community.particle.io/t/multiple-temp-sensor-ds18b20/8912 "2014-12-20T14:46:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikemcp](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@mikemcp](https://community.particle.io/u/mikemcp)\
**Post date:** [December 20, 2014, 2:46pm UTC](https://community.particle.io/t/multiple-temp-sensor-ds18b20/8912/1 "2014-12-20T14:46:26Z")

</div>

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

```cpp
#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)_

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [December 20, 2014, 2:56pm UTC](https://community.particle.io/t/multiple-temp-sensor-ds18b20/8912/2 "2014-12-20T14:56:07Z")

</div>

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

```cpp
#pragma SPARK_NO_PREPROCESSOR

```

at the top of your sketch.

---

<div class="post-metadata">

**Author:** ![mikemcp](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@mikemcp](https://community.particle.io/u/mikemcp)\
**Post date:** [December 20, 2014, 3:21pm UTC](https://community.particle.io/t/multiple-temp-sensor-ds18b20/8912/3 "2014-12-20T15:21:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [December 21, 2014, 10:55am UTC](https://community.particle.io/t/multiple-temp-sensor-ds18b20/8912/4 "2014-12-21T10:55:21Z")

</div>

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