Temperature Example: XBee Wi-Fi
Table of Contents
Measuring temperature is a popular way to get started with analog sensing. This example uses the TMP36 low-voltage linear temperature sensor that is included in the XBee Wi-Fi Cloud Kit. The TMP36 is very easy to set up. It doesn’t require any complicated circuits or tricky calculations to determine if it’s hot or not.
The sensor generates a voltage output output that is directly proportional to the Celsius temperature. The hotter it is, the higher the voltage that is passed to the XBee’s analog-to-digital converter (ADC). This reading is then sent via Device Cloud to the XBee Wi-Fi Cloud Kit’s online dashboard application where you can monitor the temperature right in your web browser.
2) Assemble the Parts
To hook up a temperature sensor you’ll need:
- 1 – XBee Wi-Fi Cloud Kit*
- 1 – TMP36 – for sensing temperature (data sheet)
- 4 – 10K ohm resistors
- Jumper wires
*…or a powered XBee Wi-Fi with breadboard and jumper wires.
3) Configure the Radio
You’ll configure the radio using your free Device Cloud account. (Note that radios can also be configured using XCTU.)
NOTE: If your radio was recently configured by the XBee Wi-Fi Cloud Kit then the sampling rate and pin settings are already set. You can safely skip these steps.
- Log in to Device Cloud.
- Select Devices under the Device Management tab.
- Select the XBee Wi-Fi that you are configuring, then select Properties or double-click to open the Properties window for that device.
- Select Configurations, then Input and Output Settings, then confirm that DIO2/AD2/SPI_SCLK is set to Analog Input.
- On the same page, confirm that Sample Rate is set to 5000 ms which will take a sample every five seconds.
- Save your changes!
4) Wire up the Circuit
You will build this sensor circuit using the XBee Development Board.
- Plug in the temp sensor into three separate rows on the breadboard as shown. With the flat side facing you, the pins are numbered 1 to 3 from left to right.
- Connect a red jumper wire from a socket in the same row as pin 1 of the TMP36 to 3.3 volts power.
- Connect a black jumper wire so that pin 3 of the TMP36 is connected to GND (ground).
- Plug in the four resistors to separate rows of the breadboard as shown. They will form a chain with the each resistor connecting to one end of each resistor on either side and scale the input down from 3.3 volt input to the 2.5 volt maximum of the XBee Wi-Fi’s ADC.
- Connect a blue (or any other color) jumper wire so that the middle pin (2) of the TMP36 is connected to the open end of the first resistor.
- Connect one end of a yellow (or any other color) jumper wire to the row where the first and second resistors meet. Connect the other end of this wire to to the XBee’s AD2 pin.
- Use a black wire to connect the open end of the fourth resistor to GND.
- Set the DIP switch for AD2 on the PCB to OFF to disconnect the soldered-on component.
- Here’s what everything should look like:
5) View It!
You will use the XBee Wi-Fi Cloud Kit’s web application to configure a widget for viewing the temperature readings from your sensor.
- Log in to the XBee Wi-Fi Cloud Kit web application.
- Use the Add Widget button to create a new display widget.
- Choose Gauge Widget for the widget type.
- Add a label such as “Temperature.”
- Choose your XBee Wi-Fi device by its ID.
- Select ADC2 as the input stream and check the device configuration to make sure it is configured properly.
- Enter “value/0.75/10-50” to transform the input from millivolts to degrees Celsius*. The calculation takes the input value, scales back by 1/4 from 3.3 volts to the 2.5 volt maximum that the ADC input on the XBee Wi-Fi can handle, then divides it by ten and subtracts half a volt to get the Celsius value. The TMP36 data sheet is the source for this info.
- Add a name for the Units such as “°C.”
- Set a low value of 0 and a high of 50 to see a reasonable Celsius temperature range displayed.
- Save the changes to see your new Widget:
* If you want to use Fahrenheit then the calculation is “(value / 0.75 / 10 – 50) * 1.8 +32” and don’t forget to change the label and value range to reflect the new unit of measure.
6) Use it!
Now you can see the temperature using the analog input of your XBee Wi-Fi! Try getting data from various locations, like outside on your patio or inside your freezer. You can also add a graph widget to examine data over time. Log the changes in your office to see temperature shifting from day to night. Finally you’ll have the documentation to convince your boss to buy you a blanket!
Remember that this temperature sensor is designed to produce stable readings, so it may take a few minutes for the sensor to fully reflect changes from its environment. If you want to experiment with rapidly changing sensor data try building the light sensor.