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
Xbee Wireless Temperature Sensor
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: Xbee Wireless Temperature Sensor
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
- rmcdona413
- Posts: 2
- Joined: Thu Jul 16, 2009 8:09 am
Re: Xbee Wireless Temperature Sensor
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
Chris
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
- pelphry17
- Posts: 7
- Joined: Mon Aug 03, 2009 12:41 pm
Re: Xbee Wireless Temperature Sensor
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 class.
Can anyone help me with how I would do this in Python?
Thanks!
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 class.
Can anyone help me with how I would do this in Python?
Thanks!
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: Xbee Wireless Temperature Sensor
you want an analog temperature sensor like the TMP36 or TMP35
not a digital one
not a digital one
- pelphry17
- Posts: 7
- Joined: Mon Aug 03, 2009 12:41 pm
Re: Xbee Wireless Temperature Sensor
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
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
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: Xbee Wireless Temperature Sensor
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
everything you want is handled inside there, but you will have to do a little work to modify it
- chazcheadle
- Posts: 5
- Joined: Wed Jul 29, 2009 8:03 pm
Re: Xbee Wireless Temperature Sensor
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
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.
http://www.flickr.com/photos/11868356@N08/3820575276/
http://www.flickr.com/photos/11868356@N08/3820575318/
-chaz
This code is from the Tweet-a-Watt page with temperature reading at the very end
Code: Select all
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
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.
http://www.flickr.com/photos/11868356@N08/3820575276/
http://www.flickr.com/photos/11868356@N08/3820575318/
-chaz
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: Xbee Wireless Temperature Sensor
fantastic work, and great documentation photos!
- pelphry17
- Posts: 7
- Joined: Mon Aug 03, 2009 12:41 pm
Re: Xbee Wireless Temperature Sensor
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!
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 12:41 pm
Re: Xbee Wireless Temperature Sensor
Chaz,
Working perfectly! Thanks!
Working perfectly! Thanks!
- espie
- Posts: 4
- Joined: Sun Oct 04, 2009 5:37 pm
Re: Xbee Wireless Temperature Sensor
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.
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 :/
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
mVolts = xb.analog_samples[0][0] # Report the millivolts from the TMP36
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 :/
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: Xbee Wireless Temperature Sensor
0x5e = 94 (in decimal)
where is 224 from?
where is 224 from?
- espie
- Posts: 4
- Joined: Sun Oct 04, 2009 5:37 pm
Re: Xbee Wireless Temperature Sensor
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.
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.
Please be positive and constructive with your questions and comments.