Reading a Remote Temperature Sensor with XBee and Arduino

Arduino and XBee temperature-sensor bench setup

This XBee project receives an analog sample over a radio link and prints a temperature estimate in Celsius and Fahrenheit. One recording shows the hardware and another shows the Serial Monitor, connecting the physical experiment to the bytes received by the sketch.

How the project works

At 9600 baud, the sketch waits for at least 21 serial bytes and looks for the 0x7E start delimiter. It discards the following 18 bytes, then combines two bytes as an analog sample. That fixed offset assumes one particular XBee API frame layout.

The saved conversion is (sample / 1024.0) × 125 × 1.02 − 50, followed by the Celsius-to-Fahrenheit conversion. The intermediate quantity printed as volts is only the normalized ADC fraction in this sketch. The supplied TMP35/TMP36/TMP37 datasheet helps distinguish the sensor’s transfer function from the radio’s ADC reference.

Hardware and configuration

ItemIn the supplied code
Serial interface9600 baud
Frame delimiter0x7E
Sample assemblyLSB + 256 × MSB
Reference documentTMP35 / TMP36 / TMP37 datasheet

Working with the supplied code

Confirm the radio model, API mode, enabled analog channel and frame type before trusting the byte positions. A reusable receiver should parse the frame length and channel masks and validate the checksum instead of skipping a fixed number of bytes.

Compare a known temperature against the reported value before using the conversion elsewhere. The Screenium composition includes an internal movie as well as the finished screen-recording export; the finished demonstration is already available on the YouTube channel.

Video demonstrations

Arduino XBee Read Temperature Sensor01 — Ovidiu Carstea on YouTube
Arduino XBee Read Temperature Sensor02 — Ovidiu Carstea on YouTube

Source code and project files

Browse this project on GitHub. The files below are useful starting points for the sketches and references discussed in this post.

Download the used libraries (ZIP, 14.7 MB).

These notes describe the archived source and project media. The sketches have not been rebuilt or tested on hardware for this article.

Scroll to Top