Xbee Wireless Temperature Sensor

by rmcdona413 on Thu Jul 16, 2009 7:12 am

Hello!

Has anyone made a wireless Xbee temperature sensor with the TMP36 and the Xbee using just the ADC on the Xbee itself?

Thanks in advance,


Chris
rmcdona413
 
Posts: 2
Joined: Thu Jul 16, 2009 7:09 am

Re: Xbee Wireless Temperature Sensor

by adafruit on Thu Jul 16, 2009 5:26 pm

its a planned demo project. its fantastically easy though. just look at the tweet-a-watt code and plug the output of the TMP36 into an analog pin and read it on the other side with the xbee library
User avatar
adafruit
 
Posts: 11643
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Xbee Wireless Temperature Sensor

by rmcdona413 on Sat Jul 18, 2009 9:45 am

Thanks! The one item I am still stuck on is the voltage range available on the analog in. From the product data sheets I see that is referenced to the power source that powers the xbee but what is the limit - 5V? or much higher?

Chris
rmcdona413
 
Posts: 2
Joined: Thu Jul 16, 2009 7:09 am

Re: Xbee Wireless Temperature Sensor

by adafruit on Sun Jul 19, 2009 1:13 am

3.3v
User avatar
adafruit
 
Posts: 11643
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Xbee Wireless Temperature Sensor

by Pelphry17 on Mon Aug 03, 2009 1:41 pm

Hi,

First post here and I'm totally new to the Xbees. I have been messing around with Python a little. I'm also planning to build a wireless temperature monitor. I'm pretty sure I can handle the analog temperature data. What I don't know how to do with the Python XBEE library is to be able to get the status of a single digital input on the XBEE. According to the xbee-java api this is how its done, but I don't know anything about Java.

Example: You want to read an digital sensor on a remote XBee end device. Look in the table for an available pin that supports DIGITAL_INPUT; let's use pin 20. In the table we can see that the AT Command for pin 20 is D0 and the DIGITAL_INPUT parameter value is 0x3. Now plug your end device into your computer and open X-CTU. Select enable API mode and use escape characters. On the Modem Configuration tab and click "Read". Find D0 in and set to "3 - DIGITAL INPUT". Now enable I/O samples by setting IR to "1388" (every five seconds) and click "Write" to save the configuration. Now connect the XBee coordinator to your PC and start receiving the samples with the isD0On() method in the ZNetRxIoSampleResponse.java c
lass.

Can anyone help me with how I would do this in Python?

Thanks!
Pelphry17
 
Posts: 7
Joined: Mon Aug 03, 2009 11:41 am

Re: Xbee Wireless Temperature Sensor

by adafruit on Tue Aug 04, 2009 6:41 pm

you want an analog temperature sensor like the TMP36 or TMP35
not a digital one
User avatar
adafruit
 
Posts: 11643
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Xbee Wireless Temperature Sensor

by Pelphry17 on Tue Aug 04, 2009 7:05 pm

LadyAda,

Thanks for the reply!

I wasn't clear in what I was planning to do. I plan on having the analog temp sensor (on order). I want to have the remote XBEE send the temp data every 10 seconds or so, then also have switch (tilt or reed) on the remote XBEE that will set of the digital pins high/low whenever the switch position changes. I would then want to be able to instantly monitor the state of that pin on my computer using a Python script. I plan on having several of these and will want to be able to monitor which XBEE is sending the data as well (I think I can handle that part as well.)

Thanks,

-Jeremy
Pelphry17
 
Posts: 7
Joined: Mon Aug 03, 2009 11:41 am

Re: Xbee Wireless Temperature Sensor

by adafruit on Wed Aug 05, 2009 11:50 am

look at the tweetawatt code and documentation
everything you want is handled inside there, but you will have to do a little work to modify it
User avatar
adafruit
 
Posts: 11643
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Xbee Wireless Temperature Sensor

by chaaaaaaaz on Fri Aug 14, 2009 8:57 am

Here is a python script I have been using to test the analog pin functions on the Xbee with the TMP36 temperature sensor. (all from the Adafruit shop)

This code is from the Tweet-a-Watt page with temperature reading at the very end
Code: Select all | TOGGLE FULL SIZE
from xbee import xbee
import serial

SERIALPORT = "COM4"    # the com/serial port the XBee is connected to
BAUDRATE = 9600      # the baud rate we talk to the xbee

# open up the FTDI serial port to get data transmitted to xbee
ser = serial.Serial(SERIALPORT, BAUDRATE)
ser.open()

while True:
    # grab one packet from the xbee, or timeout
    packet = xbee.find_packet(ser)
    if packet:
        xb = xbee(packet)

# Tempurature reading code
# xb.analog_samples[sample #][A/D pin#] is used to grab the first sample and pin in the xb packet
        mVolts = xb.analog_samples[0][0]  # Report the millivolts from the TMP36
        tempC = mVolts * 0.1              # Convert millivolts to Celcius
        tempF = tempC * 9 / 5 + 32        # Convert to Fehrenheit                       
        print tempC, "C \t", tempF, "F"   # Print formated tempurature readings

The VCC pin of the Xbee shield is +3.3v, which is fed to the TMP36 and to VREF on Xbee to calibrate the analog input, AD0.

Here are pictures of the Xbee w/Adafruit shield and the setup with the sensor.
The components on the breadboard 1-7 are just to provide +5v to the xbee shield.

Image
http://www.flickr.com/photos/11868356@N08/3820575276/

Image
http://www.flickr.com/photos/11868356@N08/3820575318/

-chaz
User avatar
chaaaaaaaz
 
Posts: 5
Joined: Wed Jul 29, 2009 7:03 pm

Re: Xbee Wireless Temperature Sensor

by adafruit on Fri Aug 14, 2009 10:58 am

fantastic work, and great documentation photos!
User avatar
adafruit
 
Posts: 11643
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Xbee Wireless Temperature Sensor

by Pelphry17 on Mon Aug 17, 2009 9:14 am

Chaaaaaaaz,

Thank you very much for the information in your post! I haven't had time lately to 'play', but I will definitely give this a try. I'll let you know how it goes.

Thank You!
Pelphry17
 
Posts: 7
Joined: Mon Aug 03, 2009 11:41 am

Re: Xbee Wireless Temperature Sensor

by Pelphry17 on Mon Aug 24, 2009 10:40 pm

Chaz,

Working perfectly! Thanks!
Pelphry17
 
Posts: 7
Joined: Mon Aug 03, 2009 11:41 am

Re: Xbee Wireless Temperature Sensor

by espie on Sun Nov 15, 2009 2:08 pm

Thanks for the wiring and setup!

The thing that puzzles me though, is that firstly, the 0.5 offset voltage of the TMP36 appears to have been applied to the reading.
Code: Select all | TOGGLE FULL SIZE
       
mVolts = xb.analog_samples[0][0]  # Report the millivolts from the TMP36


If subtracting 500 here as one would expect, one would get a negative value for normal temperatures.

This seems very strange to me atleast, there is no way of the Xbee knowing this as I see it. Also, when reading 742 mV reading from my multimeter (Caltek CM2701), getting an Xbee analog reading of 229 is actually not what I expect. If you calculate using the two methods, you actually get different results as well:

Multimeter: 742 mV = 24.2 C (minus 500 mV offset)
XBee: 0x005e = 229 = 22.9 C (not subtracting anything here)

So I'm a bit confused here, how can the AD reading represent the TMP36 mV out reading?

Another thing is that compared to a reference thermometer the difference is 2 degrees C. Not sure which is wrong :/
espie
 
Posts: 4
Joined: Sun Oct 04, 2009 4:37 pm

Re: Xbee Wireless Temperature Sensor

by adafruit on Sun Nov 15, 2009 8:19 pm

0x5e = 94 (in decimal)
where is 224 from?
User avatar
adafruit
 
Posts: 11643
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Xbee Wireless Temperature Sensor

by espie on Mon Nov 16, 2009 2:13 pm

Oops, typo. 0x00e5 of course.

Anyway, if we factor in the Vref and the fact that the AD converter is 10 bits, the correct conversion would be to multiply by (3300 / 1024) to get the actual mV reading. That will match (almost) the reading from the multimeter.

So in my view the source code is actually not calculating the temperature correctly.
espie
 
Posts: 4
Joined: Sun Oct 04, 2009 4:37 pm