TempBug: internet-connected thermometer

 by tombrew
Featured
imp_installed.jpg
Screen Shot 2013-02-18 at 10.45.51 AM.png
Last January, we had some trouble with the heat in my office. Specifically, the kind of trouble wherein the heat is not on, you turn it up, and it still not on. This went on for more than a few days, and finally ended a day or two after we got an email announcing that the heat was broken and speculating that it had probably been down for a few days. My teammates and I laughed a bit at this - we knew exactly when the heat had stopped working. We had a continuous record of the temperature in the office going back months, with 10-minute resolution. 

You can do this too, and it's quick, cheap, and easy! This little gadget is built around an electric imp, and you can push the data from the imp out to anywhere you want. In my case, I found it handy to push the data to a neat service called Cosm, which stores and graphs the data for free. 

This project takes about an hour to two hours, if you've never done a project with an electric imp before, and when you're done you'll have a thermometer that you can toss anywhere with wifi and collect data for months to years on a single battery, depending on how often you check the temperature. 
 
Remove these adsRemove these ads by Signing Up

Step 1: Gather the parts

IMG_0169.jpg
board.jpg
battery.jpg
IMG_0178.jpg
100k_res.jpg
100k_NTC.jpg
Here are the parts you'll need to build your internet-connected thermometer:
  1. An electric imp (currently available on Sparkfun and Adafruit) - $30
  2. An electric imp breakout board (again, Sparkfun or Adafruit) - $12.50
  3. A 9V battery - $2.00
  4. A 9V battery clip, like this one from Sparkfun (we're just going to cut the end off of it, so the connector doesn't matter) - $1.25
  5. A big capacitor, like this one on Digikey (220 uF, 50V). Make sure it's at least rated to 16V if you're going to connect it to a 9V battery, or you'll have a bad time. - $0.40
  6. A 100kΩ resistor, preferably 1% tolerance, like this one on Digikey. - $0.10
  7. An NTC (negative-temperature-coefficient) Thermistor. I used this one on Digikey. It needs to have a room-temperature resistance equal to your resistor (#6) - this one is 100kΩ at room temperature. - $3.25
Parts total: $49.50

You'll need some tools and supplies, as well:
  1. Soldering iron
  2. Solder
  3. A bit of foam tape or other thick, double-sided tape for securing the battery to the breakout board
  4. Angle cutters / wire cutters
  5. Wire strippers
  6. A smart phone for using BlinkUp to put the imp on your wifi network
  7. A computer to program the imp 
Alright! Let's get started!
harleen says: Feb 20, 2013. 7:01 AM
Instead of making it a temperature sensing device, can it be converted into some other sensor would it be a noise sensing device(with the help of electric imp)?
tombrew (author) in reply to harleenMay 24, 2013. 10:11 AM
Sure, absolutely. The imp's analog input pins can be used to read any analog voltage between 0 and 3.3 volts, so other analog sensors like this thermistor could be used with a small adaptation of the code I posted.

Even better, the imp is easy to set up to interact with other devices via I2C, SPI, or UART, which opens the door to communicating with virtually any sensor you can possibly lay hands on.

For general noise sensing, I've seen projects that use a vibration switch as a digital input on one of the imp's pins. That might be quick route to where you're trying to go.
stealth32 says: Apr 2, 2013. 6:24 PM
Excellent solution, however i want to know if i can add more than one temp sensor, in case its positive, how many?
And about the length of the temp sensor wire, what is the max length i can use without affecting the accuracy of the measurement.
Thanks in advance.
tombrew (author) in reply to stealth32May 24, 2013. 10:08 AM
The imp card has six user-accessible pins, so you could set a device up like this to use as many as five thermistors directly. If you want to read more sensors with a single imp, you could consider setting up an I2C bus and using some simple I2C temperature sensors.

Any length of wire affects the accuracy of the measurement, as that wire is going to have a finite and temperature-dependent resistance not factored into your temperature calculation. I built this device primarily to show me, plus or minus maybe half a degree, what the weather is like in front of my house. With that purpose in mind, a foot or two of wire isn't going to cause you much grief.

If you're looking for accurate temperature measurement, you should really go for a digital temperature sensor.
imppa22 says: Apr 22, 2013. 7:56 AM
your firmware link doesnät work :(
tombrew (author) in reply to imppa22May 24, 2013. 10:03 AM
Fixed, sorry about that!
autolib says: Feb 28, 2013. 4:53 AM
I have everything working on the imp end but nothing ever gets to Cosm. I keep receiving an error code of 43. Can you give an exact example of what needs to be entered on the imp node end concerning Cosm and on the Cosm end too.
Guyp says: Feb 17, 2013. 3:15 AM
Excellent, I've been looking for a project for my Imp. How long does the battery last on average? Are we talking about days, weeks or months here?
tombrew (author) in reply to GuypFeb 18, 2013. 11:52 AM
As shown: 6 months or more.

This depends far and away on your polling interval. I've done power profiling on my own setup, benchmarking the amount of time the imp is awake (about .226 s), and the amount of time that the thermistor network is switched on (about .104 s, with us taking 10 readings and averaging them).

When the imp is deep asleep, it draws approximately 6 uA. When it's awake with wifi powersave on, it draws about 7 mA. The thermistor network draws about 16.5 uA, which is not very significant when the imp is already awake and drawing 7 mA.

With these numbers, using a 15-minute polling interval, the imp is asleep 99.97% of the time.

A 9V (PP3) battery is generally good for about 565 mAh (http://en.wikipedia.org/wiki/Nine-volt_battery), and we'll take the nominal voltage to be about 7V (instead of the quoted 9) over the life of the battery. This gives us 3955 mWh. The buck power supply on the imp breakout is good for about 90% efficiency, leaving us with 3556 mWh. At the 3.3V output voltage of the supply, that's 1078.63 mAh.

If we run the numbers on the imp power profile from above, we see our average draw is about 0.188 mA. Now we can find hours: 1078 mAh / 0.188 mA = 5734 hours. 5734 hours = ...

238.9 days
34.13 weeks
About 0.66 years

So you probably don't need to put batteries on the shopping list just yet!
zawy in reply to tombrewFeb 18, 2013. 2:36 PM
Did you measure current usage when it's asleep? The capacitor has a max leakage of 110 uA (at 50V) which translates to about a max of 20 uA (actual should be about 10 uA). If users choose the less expensive brother to this capacitor then leakage can be as high as 0.06*C*V+10uA = 130 uA for 220uF at 9V. If a smaller cap will work, then there will be less leakage as determined by the C*V.
DSPNRG says: Feb 17, 2013. 8:36 AM
This is awesome! Years ago I attempted to do this but gave up when I realized I needed to learn ZigBee mesh network blah, blah blah. I gave up and decided to go pro with WebComfort by Jackson Systems (Highly recommended BTW).

You clearly put a lot of effort into your writeup as it is very well done. Regarding the NTC thermistor, readers should be aware there are different types which can produce different R-F curves and are cautioned to take a close look at the data sheet to determine if a modification to the resistance/temp curve fitting needs to be modified in the software.

In my case I used an NTC-10K Type 2 thermistor. The data sheet I found only gave a list of R/F values so I needed to perform a curve fit to this data. The best fit I came up with (using Igor Pro by Wavemetrics - a fantastic piece of software BTW) was in the form of a power curve: R = R0+K1*F^K2 where R is the resistance of the thermistor, R0 is the constant offset, K1 is a scalar for the temperature F in degrees F, and K2 is the power coefficient. The respective values for a best fit of the table data in the range of temperatures between 32degF and 194degF were: R0 = -12878, K1 = 6.7938e+5, K2 = -0.77833. Of course the fit formula would need to be re-arranged to swap the F/R axis to R/F.

I never did get to characterizing the theoretical fit to actual controlled measured thermistor groups, so the curve fit is theoretical and only based on the data sheets I found on the web. So my results are only as accurate as what I got on the interwebs - i.e. your mileage may vary.

I will have to take another look at the imp thingy though - I can revisit many ideas I have for remote monitoring and data logging. Thanks for posting.
tombrew (author) in reply to DSPNRGFeb 18, 2013. 11:08 AM
A very good point! There are a lot of different thermistor characterization curves (and a couple different ways of actually measuring them), and if you're looking to actually get scientific accuracy out of your device, you'll definitely want to implement a more sophisticated curve fit in your formula. I've found, so far, that getting the correct beta value and doing a quick linear fit like this gives me a good idea of whether or not I need a coat when I head out the door, so I'm satisfied for now, but that could be a fun project....
zawy says: Feb 17, 2013. 2:35 PM
I didn't think thermistors had good accuracy. I would have guessed 5 F error. There's a 3-pin solid state "thermometer" LM34 that looks like a typical small plastic package transistor and it outputs a voltage that is linear with temperature, with a choice of F or C. I see 10 mV per F at allelectronics website's datasheet, so 75 F = 750 mV. Guaranteed accuracy of +/- 0.5 F at room temp, which is as good as I would hope for without a thermocouple. It uses only 90 uA
tombrew (author) in reply to zawyFeb 18, 2013. 11:04 AM
You're right, they're not a terribly accurate sensor, but they're handy for "within a degree or two", and for watching trends over time - I like watching the temp in my living room climb when the sun clears the neighbor's roof and hits my front windows.

One thing that *is* rather nice about this setup, in terms of power: the thermistor and its partner 100k resistor draw only 3.3V / (100k + ~100k) = 16.5 uA when "on".

At the end of the day, you're absolutely right - an actual IC is going to give you the best accuracy and you will likely be able to find one low-power enough for just about any need.
jeffstearns says: Feb 17, 2013. 12:07 PM
I note that the temperatures are being displayed with 5 digits of precision. That seems misleading. The resistor and thermistor are 1% tolerance, and the ADC may widen the error window even further. Without better parts and careful calibration, most of those 5 digits are meaningless.

This is a nice little project and it's truly useful, so I'd like us to be careful to not spread confusion among new developers and budding engineers. They're not measuring temperatures to 0.001 degree with this thing. Not even close.
tombrew (author) in reply to jeffstearnsFeb 18, 2013. 11:01 AM
Screen shots and code are all updated to show one tenth of a degree. Thanks for your diligence.
tombrew (author) in reply to jeffstearnsFeb 18, 2013. 7:40 AM
String formatting error! Good catch, thank you.
carl87gt says: Feb 17, 2013. 8:16 PM
Pretty cool . . . with a few modifications I could get an email when my fish tank falls outside a temperature range. Had a heater break on me and I don't know when. Didn't know until I went to clean the tank at it was cold! Nice write up.
tedgar says: Feb 17, 2013. 6:07 AM
Hey-
Can you set this up to make alerts for temperature variances and email or SMS someone to address it??
tombrew (author) in reply to tedgarFeb 17, 2013. 5:49 PM
Yes and yes! The imp can send data to an "HTTP Out" node just the same is we set it up to send data to a COSM node here. You could create a port that outputs some data whenever a certain event occurs, then point that at your server, or at a mail API like mailgun, or Twilio for SMS. Imp has a new feature coming very soon called "agents" which let you run squirrel in the imp cloud, like a mini web server, and has a full-featured HTTP API.
christhecomputerguy says: Feb 17, 2013. 8:28 AM
Nice. Can it be done with multiple temp sensors (http://www.adafruit.com/products/165) like a 1-wire system? Would be nice to keep track of multiple coolers and freezers with one unit.
tombrew (author) in reply to christhecomputerguyFeb 17, 2013. 5:47 PM
The imp doesn't support 1-wire (yet, it's on the list), but you could absolutely set up multiple sensors this way. You've got six user-accessible pins on the imp, so you could do one of these with three thermistors set up this way, or (much better) set up an I2C bus and talk to some better sensors that way. Check out a tutorial on I2C with the imp here: http://devwiki.electricimp.com/doku.php?id=i2c
F22-Raptor says: Feb 17, 2013. 9:05 AM
This is really cool, I think I'll build one. Thanks for posting.
Build_it_Bob says: Feb 16, 2013. 5:56 AM
Very nice ! Thanks for taking the time to explain each step in detail. I have an Imp I have not put to work yet ...this looks like a good one to try.
Build_it_Bob
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!