DS18B20 with Uno over Xbee


I wanted to get some clarification on how to get the sensor readings over an Xbee.

The Coordinator is plugged straight into the PC with a Sparkfun adapter
SH 13A200
SL 408B2E00
Series 2 Xbee with API firmware loaded and API enabled = 2.

The Router is plugged into an Arduino Uno R3 using an Xbee shield.
SH 13A200
SL 408B2E0C
DH and DL set to the Coordinator address
Again Series 2 Xbee with API firmware and API Enabled = 2

Im using a DS18B20 One Wire sensor with their default script loaded:

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// 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);

void setup(void)
  // start serial port
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library

void loop(void)
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  sensors.requestTemperatures(); // Send the command to get temperatures  
  //Serial.print("Temperature for Device 1 is: ");
  //Serial.println(sensors.getTempCByIndex(0)); // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire

If I un-comment the 2 serial print lines from the code above and view it through Putty it is giving the correct text + temp.
If I wanted to send that over to the other Xbee what would be the best place to start? Just the raw sensor data and nothing else
Would I require a similar thing to this > http://code.google.com/p/xbee-arduino/source/browse/trunk/examples/Series2_Tx/Series2_Tx.pde
I.e include the uint8_t payload = { 0, 0 }; and write the pin data to that?

When I used that - editing the required elements and monitoring the coordinator through X-CTU - I’m getting RX/IO data received and RX received packets:
7E 00 14 92 00 7D 33 A2 00 40 8B 2E 0C 0B 24 01 01 00 00 05 02 09 02 09 67 (RX/IO?)
7E 00 0E 90 00 7D 33 A2 00 40 8B 2E 0C 0B 24 01 00 01 84 (RX)

I’m using pin 2 so in the example script from the Xbee-Arduino library site I changed it from analogRead(5) to DigitalRead(2) - presumably that is correct?

I though it was a case of getting that data out of this - but I presumed I would receive a different kind of output that would require processing…
Can someone help get over this hurdle of how to actually send or parse the sensor data?

PS wiring wise this is how it is setup - http://cxem.net/arduino/arduino17-2.png - however the data line goes into pin 2 on the Xbee shield which plugs into the Arduino…

The Router is plugged into an Arduino Uno R3 using an Xbee shield.

First off, there is no such thing as "an XBee shield". There are at least three different, commonly used, XBee shield, and each is different. You have to do better than "an XBee shield".

If I wanted to send that over to the other Xbee what would be the best place to start?

Start with not using API mode. Then, the XBee will send whatever you tell it to send, as plain text.

Paul is quite right, the first place to start is to disable API mode. Packets are useful for complex networks, but when you’re just trying to send data back and forth it’s much easier to have the XBee simply send whatever is passed to the XBee.

Once you’ve disabled the API mode, any text you pass to the XBee should be transmitted directly without all the packet overhead.

Once you get that working, you should look into removing the Arduino from the sensor. The XBee has some rudimentary I/O onboard and while it won’t interface with your DS18B20 sensor, you could use a TMP36.

Check out this thread where someone else did the same thing a while ago:


The shield is an older libelium sensor - http://www.amazon.co.uk/Wireless-Xbee-A000021-Arduino-Shield/dp/B004V13O16/ref=sr_1_1?ie=UTF8&qid=1357146254&sr=8-1

I will try AT mode again - it doesn't seem to actually send the data in AT mode to the other Xbee so I might have some sketch changes to make - the xbee are working together as sending other data through serial is working just not the temp readings.

It's going to consist of 5 sensors in the end and so I thought API would be best. I will try AP a bit more and maybe the TM sensor as it looks like it might be a little easier to work with and see where I get

I'm not familiar with that shield specifically, but if you can pass numbers back and forth with the AT firmware, you should just as easily be able to pass temperatures using the same serial write commands. Since you have the Arduino Uno doing all the processing, there shouldn't be a difference between sending "test" and sending "71.3".

For multiple sensors, you could either send a set of five numbers like "71.3, 73.5, 91.8, 32.3, 55.7" or you could give each sensor an ID like "S1,71.3,S2,73.5,...". Either way, the API won't really help you, it'll just make it more complicated for this kind of simple application.

Again, the best method here is to ditch the Arduino Uno since the XBee has 6 pins with analog to digital conversion. You can simply hook up one TMP36 to each of the appropriate pins (probably using an XBee breakout board) and then set up the XBee to send readings at fixed intervals. You can even buffer a number of readings before transmitting them all together. In this case, the XBee does transmit with a simple API frame according to this very helpful guide: