The current version of the Sparkfun BWSN Basics Kit includes a TMP36 temperature sensor in place of the LM335 sensor described in the Building Wireless Sensor Networks book. To use this component, simply replace the instructions on page 147 with the following:
Temperature input
This project uses the TMP36 low-voltage analog temperature sensor. This sensor has a linear output of +10 mV per degree Kelvin and it comes pre-calibrated. You can get the entire data sheet for the TMP36 at:
http://www.analog.com/static/imported-files/data_sheets/TMP35_36_37.pdf:
- The TMP36 temperature sensor has three leads. When the sensor’s flat side is facing you, the leads from left to right are positive, output and negative. Insert the TMP36 so that each lead is in its own row on the breadboard.
- Use a red wire to connect the leftmost, positive lead to one of the power rails.
- Use a black wire to connect the rightmost, negative lead to one of the ground rails.
- Insert 0.1uF capacitor so that it’s connected as close as possible to the TMP36 power lead on one end and to its negative lead on the other. This will help suppress any noise in the circuit.
- Use a jumper wire to connect between the center output lead to XBee digital input 0 (physical pin 20).
Program
Download this updated Simple_Sensor_Network.zip program for Processing. To use the TMP36, uncomment its code (around line 100) and comment out the LM335 code (around line 92).
Fritzing breadboard layout
Fritzing schematic
TMP36 data sheet
from Analog Devices
I have a TMP36 hooked up per this drawing. When having the xbee s2 send the ADC value every 10 seconds I get inconsistent results, the vary by +- 50 Anyone ever see this behavior? Is ther a fix, or is the XBee ADC just flaky?
The ADC is very stable. You can check this by putting in a pull-down or pull-up resistor to check if your readings stabilize. Look for noise in your circuit. Decoupling capacitors may help a lot, or arranging your components to avoid noise. Good luck!
I know that doesn’t help a lot but in my project (see URL of Website). I use a TMP36 as a remote sensor and only pull the value every 28 seconds (=activate the TMP36) and I get very constant readings.
Did you try to substitute the capacitor adjacent to the TMP36? And is the power supply for the TMP36 stable? Do you have other devices attached to the analog ports?
Markus
The commented out line of code for the TMP36 currently reads:
// float temperatureCelsius = ((data.value/1023.0*1.25 – .5) *100);
Should it not be 1.2 (rather than 1.25) as the XBee max ADC voltage is still 1.2v?
It should 1.2 in the equation, as can be simply checked by replacing the TMP36 with a voltage source of 0.75v to see if you get 25 Deg C from the program output.
It seems as if the author doesn’t read comments.
Hi, I have a question, I don’t know, why use 1,25 in the equation, I understand that I need data.value/1023 is for ADC, and the other part -0,5)*100 converting from 10 mv per degree wit 500 mV offset to degrees, but the 1,25 I don’t know from where appearing
From the TMP36 docs, I found that TMP36 is 750mV at 25 deg Celsius at 3 volts.
It says it’s linear with 10 mV per 1 degree Celsius.
(The range for TMP36 is -40 deg Celsius to 125 deg Celsius.)
This would create this equation:
d degrees Celsius + 50 degrees Celsius = v mV / 10 mV/C
If you plug the numbers in, v = 750. You should get d=25.
Then from the XBee product manual on page 95, it says:
AD(mV) = (A/D reading * 1200mV) / 1023
I had to rearrange the equation to have it make sense to me. I made it a ratio. The analog reading is scaled such that 0x0000 represents 0V, and 0x3FF = 1.2V.
So,
scaled_reading / 1023 = V mv / 1200 mV
(it’s the same thing as the other equation)
So, if you combine the top equation with the one right above, you get:
scaled_reading / 1023 * 1200 / 10 – 50 = d degrees Celsius
so, I too don’t understand where 1.25 comes from. However, since I’m getting 3.3 volts in the circuit, perhaps 1.25 represents a scaling factor to address the slightly different voltage. (i.e. these equations are for 3 volts)
For me, 1233 was a more accurate number instead of 1200 or 1250.
So, for more experienced people, was all of the above right?
okay last post, I swear…
I’m using this. If I’m plugged into the wall, I get 3.3 volts. If I have my 2 AA batteries, I switch the scaling factor to scaling28. This way, I kept the “clean” equations and just applied a scaling factor. I came up with the scaling factors by using another digital thermometer.
float scaling33=23.4/18.4;
float scaling28=23.4/16.04;
float scaling=scaling33;
float temperatureCelsius = data.value/1023.0*1200/10 – 50;
temperatureCelsius *= scaling;
float tempf = (temperatureCelsius / 100 * (212-32) + 32);
Hi,
I am having trouble with building the Xbee temperature sensor. I followed the instructions from the book and I am using TMP36 and also using relevant code in Processing software Simple sensor network.
The input voltage both to Xbee and the sensor is 3.3 volts.
The output of the sensor I am getting is around 0.75 which when I looked into TMP36 Datasheet gave the temperature to be around 25 degrees.
But the program, Simple Sensor Network, gives out weird values starting from 13 degrees. I dont know where I am wrong.
It would be very much appreciated if someone could help.
Best Regards,
Ahmed.
The current kit only contains 10uF and 1uF capacitors. I’m hoping using a 10uF for 2.5 volts fits the bill. It appears to.
I believe it should be 1.2 too. (Based on the better temperature readings)
To make it more portable, I used the 2 AA battery pack to power and move the sensor around. I’m measuring 2.82 volts across the battery pack at this time. I’m also measuring about 7 degress F less than when powered at 3.3 volts for the same temperature.
From this, I’m concluding that the voltage driving the temperature sensor affects the accuracy — the temperature sensor specs say it’s accurate to 1 degree Celsius within this temperature range. Furthermore, I’m concluding that as batteries continue to lose voltage over time, the measurement for an analog device continues to drift.
So, what I’m wondering is, what is a electronics novice to do? I tried messing around with the temperature equation and wasn’t exactly sure how best to apply the voltage difference to get a better temperature reading. I could apply a simple factor based on the 7 degrees difference, but I was hoping to apply the voltage difference somehow.
And the next question is, I would assume a battery powered device that depends on the accuracy of a reading would need to monitor the batteries themselves to account for any readings that are affected by voltage differences.
The analog reading to degrees celsius and farenheit
// // *** ENABLE THIS CODE FOR TMP36 temperature sensor ****
// // process the data value into a Celsius temperature reading for
// // TMP36 with no voltage divider
// // (value as a ratio of 1023 times max ADC voltage times
// // minus 500 mV reading at zero Celsius
// // times 100 to scale for 10mv per degree C)
float temperatureCelsius = ((data.value/1023.0*1.2 – .5) *100);
float tempf = (temperatureCelsius / 100 * (212-32) + 32);
My guessis that it is not the TMp that is getting affected by voltage variation of the cells, but the XBees ADC (Vref)
Hi, today I connect my xbee for sensing t°, and don’t works, i don’t know what happens, when press run in processing, appear a grey windows and nothing more, the following text is show in processing:
Available serial ports:
WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
[0] “COM3”
[2012-02-27 11:23:42,496] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x42, discarding
[2012-02-27 11:23:42,498] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x58, discarding
[2012-02-27 11:23:42,499] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x10, discarding
[2012-02-27 11:23:42,499] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x4d, discarding
[2012-02-27 11:23:42,500] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0xe8, discarding
[2012-02-27 11:23:42,509] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0xe8, discarding
[2012-02-27 11:23:42,511] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x00, discarding
[2012-02-27 11:23:42,512] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x92, discarding
[2012-02-27 11:23:42,512] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0xc1, discarding
[2012-02-27 11:23:42,513] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x05, discarding
[2012-02-27 11:23:42,513] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x01, discarding
[2012-02-27 11:23:42,514] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x01, discarding
[2012-02-27 11:23:42,514] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x00, discarding
[2012-02-27 11:23:42,515] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x02, discarding
[2012-02-27 11:23:42,515] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x01, discarding
[2012-02-27 11:23:42,516] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x00, discarding
And if open XTU software I see that de coordinator xbee is transmiting, can you help me, thanks.
Try one of these solutions:
http://forum.processing.org/search/RXTX%20Version%20mismatch
I am having a few of the same issues with the sensor arrangement. The temp seems to be a bit off. I am looking at a discrepancy of about 5 degrees. Not sure that matters for the scope of the project but it would be nice to figure out how to get accurate measurements from a homemade system. I was building up to a project that had an individual temp monitor in each room of the house but we need to be a little more accurate than this. Homes should stay within a degree or two… I guess i need the “Sensor Book” to learn a little more about the details of some of these sensors.
Hi Rob,
I was wondering if you could please help.
All i am getting from the Simple Sensor Network sketch is…
“Available serial ports:
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
[0] “COM1”
[1] “COM4″
”
Then nothing appears. Could you please explain what this means and how to correct it? Many thanks
Have you selected the correct serial port? Are you sure you have incoming data?
Thanks for your reply,
The frustrating thing is, i had the whole project working perfectly unti i used the same COM port for another project with Arduino (which was reading serial data from a sensor). Ever since, the sketch displays the above.
I have tried running it on two seperate machines (Win 7 & 8), changing and reprogramming thr Xbee co-ordinator in API to no avail. In XTC-U, both XBees are recognised, read/write and test queries run fine. I can only assume its a conflict caused by Arduino and Processing both using COM3, but still after changing the port in both programs (and in the sketch) nothing works.
Any advice would be muchly appreciated, i’ve been excited to get this up and running!
i’ve also attempted to run the WSN project by Dino Tinitigan (http://www.eeweb.com/project/dino_tinitigan/wireless-sensor-networks) and it has produced the identical [0] “COM3″ response. very strange, beginning to think i might have a faulty Xbee Explorer (although the communication with X-CTU seems fine!)
no RX blink receive either 🙁
OK – the Xbee’s are now communicating (purchased a new xbee explorer) however all i receive is the “Got error in data frame”. How could i remedy this? Thank you
Thanks for the book, could not have done what i have done without it, well worth the money.
For my question below all are xbee s2.
I have 2 xbee setup as endpoints (that sleep) transmitting temperature data to a coordinator hooked to an arduino and the arduino is reporting data from end points and is being read by a PC. That hook up is working fine. They are set up in the API mode.
Next I want that data transmitted to another xbee hooked to a Uno Arduino that has a LCD display to display and store the data. Eventually I will use that display that has touch screen to give commands to the coordinator arduino.
The xbee/arduino with the LCD display how do I setup the xbee (router or endpoint doesn’t matter to me). What are the commands for the coordinator (in API mode) to send data to the xbee hooked up to the arduino/display?
How does xbee hooked up to the LCD transmit data to the coordinator?
Thanks, I put this question in the Digi forum but did not get an answer.
I keep getting the following error:
** Error opening XBee port: com.rapplogic.xbee.api.XBeeException **
Is your XBee plugged in to your computer?
Did you set your COM port in the code near line 20?
YES and YES to both.
In fact, my router is communicating fine to my coordinator, as viewed through CoolTerm. Data is being sent every 1 sec. and i can view (as HEX) the incoming data. I believe i have configured the coordinator properly, (Function Set= ZigBee Coordinator API, ATAP = 2)
Any suggestions? I feel like i am really close here!
***Also, in the processing sketch, i believe there needs to be a / before the log4j.properties in this line of code, otherwise there are errors trying to find it.
PropertyConfigurator.configure(dataPath(“”)+”/log4j.properties”);
Hi… Thanks. Your book helped me a lot. I am Brazilian.
But, i bought sensor the temperature/humidity RHT03, Digital Output (http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Weather/RHT03.pdf). With Arduino works fine, but in direct mode Xbee (without Arduino) not. Can you give me help? I need too.
That sensor is MaxDetect 1-wire bus output. The XBee you are using only directly reads analog (via ADC) and digital high/low sensors. While you could also use a Programmable XBee to read it, I’m guessing that you’ll find it easier to work with Arduino + XBee if you need to use that sensor since libraries are already available. Arduino + XBee is what we used in the Data Sensing Lab for a similar temp+humidity sensor, by the way.
Faludi, thanks for the reply, I did not want to use the Arduino in end device, but ok, the prototype is being tested, and there are alternatives.
Hi Rob,
Shouldn’t the capacitor be between the voltage supply line and the TMP36 sensor instead of behind, as shown here?
https://lh3.googleusercontent.com/-MO3JpzDzt68/UewNzM8HIBI/AAAAAAAAA04/XqFLGPJhf_o/w876-h612-no/TMP36_CAPA_XBEE.png
Either position will decouple it electrically.
Been trying to build a transmitter of LM335 data using the circuit in BWSN with no success. The voltage at the xBee pin 20 is correct and varies with the temp … but somehow the xbee is not transmitting it.
Why was LM335 replaced with TMP36? is there a fault in the original design (a part from the obvious couple of typos)?
The TMP36 is simpler to install because it does not require any passive components, so Sparkfun included it in their BWSN kit. However the LM335 still works and people are still successfully building that circuit as well.
If the 0.1uF capacitor is an electrolytic or Tantalum capacitor, the polarity is important because they are polarized. The voltage rating is also important. I have seen electrolytics explode when a shorted transistor applied 12V to a 3V electrolytic.
Wikipedia explains capacitors well. Just skip the math you don’t understand.
https://en.wikipedia.org/wiki/Capacitor
Pingback: BWSN Remote Temperature Sensors | Misadventures in software
I have a xbee series 1, what line in the source code must to be modify? and the circuit?
Pingback: Trying to get Robert Faludi’s Simple Sensor Network to run – gr33nonline
Pingback: Temperature sensors – gr33nonline
You may find that some S2B radios (older ones, possibly) have an offset voltage on the ADC pins that needs to be accounted for when measuring voltages. For best accuracy, model the offset by using a 10K pot as a voltage divider and taking measurements from 1200 mV every 100 mV down to zero, then fitting using regression to y = mx + b. Once this is accounted for, the ADC returns accurate results across the full 1.2V measurement range.