Instructables

TempBug: internet-connected thermometer

Featured
Picture of TempBug: internet-connected thermometer
xively_graph.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 Xively, 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
ai4px21 days ago

THanks.... just what I was looking for! Didn't even know about IMP.

365nice made it!1 month ago

A quick follow up - I added 3 sensors to measure temperature at several points (which works reasonably well). Note: the imp libraries have been changed - with new agent code that runs on a server to connect to Xively (was Chosm). There are examples on the imp site. This said - this was the article that inspired me - so thanks!

IMG_3890.JPG
ygodnik 365nice1 month ago

Hello,

I saw that you added sensors. I am reasonable at making circuits, but am very poor at coding (basic python and a matlab experience). I have two questions. Could I see a copy of your code? Also, if someone is fairly illiterate in coding, is there a place one can go to get the basics on squirrel? I look online and what I find is squirrel-lang.org, which assumes a solid level of coding knowledge initially. It is like he is trying to explain how to speak chinese to me in swahili. I would really like to learn some nuts and bolts so I can modify things and trouble shoot reasonably intelligently.

For example,

therm_en_l <- hardware.pin8;

In this command, it seems like "therm_en_I" is one piece, but is it an built in command? I see the "<-" piece and I don't know what it means. It seems like the "." links objects together, but I am not sure when it is allowed, how it functions, etc.


Thank you for your time, and thank you to the author for the tutorials.

tombrew (author)  ygodnik1 month ago
Hi ygodnik,

I actually did link to the source code for the project in the instructable - it's all at https://github.com/electricimp/examples/tree/master/tempBug.

The line of squirrel you referenced is not a built in command; that line "aliases" the hardware.pin8 object with the name "therm_en_l".

I don't know of any really good squirrel-specific tutorials, but the language is in many ways similar to javascript. There are a boatload of places online to learn how to write decent javascript for free.

Thanks for the feedback and good luck!
ygodnik tombrew1 month ago

Thanks a bunch Tom. I did get everything working with one sensor, but I am afraid if I tried to change to much in your script with my current knowledge, I would just get myself in trouble. I will learn Javascript for dummies and then come back and see if I can get multiple components and new configurations figured out effectively.

Thank you again for the excellent program (with helpful comments) and for your help here.

discostu9562 months ago
Very nicely written. Answered questions that popped up along the way, and explained why you used what at each step. Learned a lot reading this. Thanks for such a good instructable, look forward to making one
(removed by author or community request)
tombrew (author)  smilesfromnowhere3 months ago
Hi smilesfromnowhere,

I've just pushed a small update to the github code that removes a deprecated call that may have caused errors device-side. I'm running this code on my own tempbug right now and things are working properly.

I also added two things to the agent code:

1. The agent now logs the data sent and the return code and message from Xively when attempting to PUT to the feed.

2. The agent now appends the device ID from the specific tempBug to the Xively channel name. This allows you to have many tempBugs on a single Xively feed, so you can view all the graphs on one page if you want.

Give this a try and let me know if trouble persists. If nothing else, logging the response from Xively should give us something to go on.

Thanks,

-Tom
Tom,
I was an *idiot*. The original problem was from having the feed id and the api key switched.

I get errors with the new code:
"the index 'resp' does not exist"
"at postToXively:152"
"from unknown:159"

...I have multiple thermistors wired up to this board but don't know how to 'instantiate' four different thermistors (yet).

Best Regards,
Miles
tombrew (author)  smilesfromnowhere3 months ago
No worries! I've published things with bigger mistakes than that ;)

Have you pulled the code from github again since you switched the Xively parameters back? I believe I pushed a fix for the error you're seeing above.
petewa3 months ago
built one of these the other day... love it... i have already ordered the supplies to make 3 more. this way i can monitor the temp in different parts of the house... i heat with wood so this is PERFECT! First time ever soldering anything and it worked when i was done! hehe.....thanks
frank5633 months ago
Great project, ordered directly from your list and went through the steps. It's been 30 years since I tinkered with electronics and this took about 2 hrs from start to end. I use this to monitor a summer rental property about a mile away that sits all winter, so with this, I can monitor the heat without making a trip over. Plus, it uses my neighbors wifi near the rental property!
ghwood3 months ago
This is very neat and my first Imp project. Spectacular documentation. (I actually built 2 off the bat using exactly the parts list you provide.)

For both, I seem to get through all the steps successfully but then repeatedly get the following log messages in the Electric IMP IDE (timestamps about 5 sec apart) :

2013-12-21 20:40:48 UTC-5: [Status] Device booting; 4.68% program storage used
2013-12-21 20:40:48 UTC-5: [Device] imp.configure command is deprecated
2013-12-21 20:40:48 UTC-5: [Device] ERROR: the index 'temp_sns_en_l' does not exist
2013-12-21 20:40:48 UTC-5: [Device] ERROR: at main:127

I'm hoping to present one as a Christmas gift to my father-in-law as a wine cellar monitor he can peek in on while he travels, so would welcome any thoughts about what's going on! Thank you.
tombrew (author)  ghwood3 months ago
Terribly sorry for the inconvenience, ghwood - there was a silly bug that is now fixed. Thanks for letting me know about it and Merry Christmas to you and your father-in-law.
ghwood tombrew3 months ago
Thank you! Likewise and I'll add a Happy New Year.
stealth321 year ago
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)  stealth3210 months ago
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.
Hi Tombrew,

I really want to thank you. This instructable helped me more than you can imagine. I have multiple imps in their own clear cases sending me temp data which I watch on Xively, and I could not have done it without you. Thanks!

Regarding this thread, my project is to set up multiple imps monitoring a bunch of solar hot water systems in my area. Each Imp will need multiple thermistors so that I can monitor independent fluid temperatures.

Last night I tried editing your code to work with multiple thermistors, but I obviously do not understand the code well enough. It didn't work. I will keep at it, but...

...I'm just curious if you have another version of the code, say monitoring 3-5 thermistors? Or, could you take a minute to type some basic instructions on how to approach adding more thermistors to your code? No worries if you are too busy. Just wanted to ask.

The Sustainability Workshop
Ithaca, NY
tombrew (author)  Sustainability Workshop5 months ago
Hi Ithacans!

The code on here has actually become a bit dated in the last few months.

I've actually taken the thermistor code and put it into a class that you can instantiate as many times as you want. Check it out here: https://github.com/electricimp/reference/tree/master/hardware/thermistor
rob-atl tombrew4 months ago
I've been studying this code which I think is meant to handle multiple thermisters. I'm struggling though. Perhaps if you could show us code to measure & calculate 3 thermisters, and then go back to sleep 15 min, and maybe even send data to xively? That could REALLY answer most the questions folks have had, and update for xively website. What a great tutorial this is!

For example, in your revised code, you say
this.p_therm.configure(ANALOG_IN
instead of the old code
hardware.pin9.configure(ANALOG_IN);

But I was assuming 4 wires would be soldered together in hole 9? (to power the 3 thermisters every 15 min)? Or would you solder the other 2 thermisters in 5 & 7, and 1&2? If so, I'm not clear what keeps the power on for them.

If you possibly could show us a 3 thermister version of the entire example code, I think it would help us understand how this works:) THANKS!! Rob
tombrew (author)  rob-atl4 months ago
Hi Rob,

Sorry for the long wait to get this updated for you - it's been quite a busy time. Are things going better in your effort to read multiple sensors? There's a quick schematic that shows how to (and how not to) wire it up at http://forums.electricimp.com/discussion/comment/9939#Comment_9939.

Now that the code is wrapped up in a class, you can just instantiate multiple thermistor objects on different pins once it's wired up correctly.

Hope all is going well.

-T
rob-atl tombrew4 months ago
Hi Tom,
I just got my IMP yesterday, and just finished soldering up a 2 thermister version (with the help of you and Sustainability Workshop).

I don't really understand the New "AGENT version" of the code. I bet it would help novices like myself if you could possibly post 2 versions of the code?
a. The version already posted.

and
b. A version showing the PIN NUMBERS and where & how they show up in the code, and the resister & electronic part variables for your datasheets (THEN, I could see clearly WHERE all the PIN 9 references are, to better understand where the enabling pin # gos, that correspond to your PHOTO (Enabled pin 8 & sensing pin 9).

I see lots of PIN references, and NULL and "0"s, but don't know the conventions for entering MY PIN NUMBERS & CONSTANTS from MY datasheets. One example with actual pins from your photo is all we'd need.

Hope this is clear:) Thanks for the great support so far.
Rob
tombrew (author)  rob-atl4 months ago
Hi Rob,

The new code is a little longer, but it's actually pretty well-commented and modular - have you given the source itself a look?

The values for your thermistor from your datasheet are stored as consts at the top of the device code - see line 33.

The pins numbers are assigned on lines 117 and 121:

therm_en_l <- hardware.pin8;
therm_en_l.configure(DIGITAL_OUT);
therm_en_l.write(1);
// pin 9 is the middle of the voltage divider formed by the NTC - read the analog voltage to determine temperature
temp_sns <- hardware.pin9;

Don't edit anything inside the class definition; this is a generic set of instructions for how to operate a thermistor, and it doesn't ever need to change. You work with it just by passing different parameters into the constructor when you instantiate it.

The short version:

1. Your datasheet variables go at the top near line 33.
2. You only need to change two lines to set your pin numbers: 117 and 121.

Thanks!

-T
tombrew (author) 4 months ago
Hi all, a couple of quick updates for you.

1. I've just refactored this instructable to use electric imp's *agents* feature, and to use Xively (the new Cosm) since Cosm is long-gone. It looks quite a bit different, but it's way more powerful. I hope everyone will enjoy this.

2. The question about reading multiple thermistors has come up a bunch of times, here and elsewhere, and it got some good attention on the electric imp forums, here: http://forums.electricimp.com/discussion/comment/9939#Comment_9939.

Happy hacking!

-Tom
jeb123 tombrew4 months ago
Thanks Tom! That's very helpful. Mine is happily chugging away at our vacation house, and making me feel much better about the cold weather. It's nice to know the pipes aren't freezing.

Fyi, when putting mine together, I noticed the b_therm and resistance numbers in the device code were for a 10K thermistor/resistor combo, not the ones specified in the link on the parts list. Changed to 100K in the code and put the new b_therm value of 4540 and all is working fine. Actually the change didn't make a huge difference - a few degrees.

Thanks again for putting this together - it's simple to do, and gives me great peace of mind!

Jim
jeb1234 months ago
I found something that works. I used the agent code at: https://github.com/joel-wehr/Tutorial_Electric_Imp_MAX31855/blob/master/agent.nut. I deleted the twitter-related code, since I don't use it, and initially it didn't work. However, there are 6 lines at the end that are necessary:
device.on("Xively", function(v) {
channel1 <- Xively.Channel(Channel_ID);
channel1.Set(v);
feed1 <- Xively.Feed(Feed_ID, [channel1]);
client.Put(feed1);
});
Also added this after line 65 in Device code:
// Send Xively data
agent.send("Xively", f);
So, now it works. Don't completely follow the code, but it does.
It would be great if the TempBug instructable could be updated for the new IDE.
Thanks,
Jim
jeb1234 months ago
Thanks for your TempBug instructions. It's exactly what I've been looking for. I used the device code from https://github.com/tombrew/ei-fw-tom/blob/master/demos/tempbug/tempbug.device.nut, which seems to work fine so far - I can see the temp & voltage, etc. on the IMP server log. However, I haven't been able to find an agent side code to connect to Xively. I've tried modifying some of the code I've found, but short of diving headlong into squirrel, I'm not getting it. Is there a set of available code that works for the new agent IDE? Thanks for the great instructions and any help you may be able to provide with the agent side.
lathyrus6 months ago
Wow! Despite not having soldered anything for about 30 years, I was able to build this thermometer without any real difficulty in a couple of hours, and I understand how it works! Thanks Tombrew for the excellent instructions. The only problem I had was that the guy in Maplins gave me the wrong size fixed resistor, so the first time I built it the reading in my livingroom was a chilly -159 degrees C... but with the correct 100k Ohm resistor everything is fine. I also couldn't get blinkup to work with my Sony Android phone so I had to borrow my wiffe's iPhone to do the setup. And getting Xively (Cosm) to draw graphs was tricky until I figured out that I needed a MASTER API key, available under the Settings tab.
tempbug.png
365nice10 months ago
Really nice article- I found it when searching to buy an internet thermometer (weather station) to track temperature in my cellar... this was way more fun and instructive!

I was easily able to find similar parts in Maplin the UK, and it seems to work quite well too.

There are a few mistakes/changes since the article was published though
1) My imp breakout board doesn't have a batt/usb jumper - so you need to buy a 3 way female header (and jumper) and solder them in (which is easy)
2) Cosm is now called Xively - most of your instructions seem to work (it worth doing the Xively demo if you are new to it, like me - it helps interpret your instructions). In the UK it initially didn't work - I kept getting a 411 error in the planner - but I left it overnight, thinking I might need an imp beta account, however it seems to have sorted itself out now. It might be worth clarifying that you hook up the numeric temperature value instead of the String.
3) I decided to graph the Battery voltage too - however I note in your code there is a little typo, the battOut voltage is declared as a number but its actually a string. I corrected this and added a second value, battOutStr for the string value.
khenderson1210 months ago
Hi Tombrew - when running on USB, do you still need the capacitor? Thanks again!
tombrew (author)  khenderson1210 months ago
No, you can skip the cap on USB.

The goal with the cap is to reduce the instantaneous power demand on the battery; the imp doesn't need much energy from the battery on average, but transmit events draw a lot of current all at once, in short pulses. The capacitor helps hide this from the battery, and I've seen some substantial improvement in battery life when using a nice big input cap.
khenderson1210 months ago
This is a great write up, thanks for sharing! What modifications would be necessary to run it off of the USB power instead of the 9v?
tombrew (author)  khenderson1210 months ago
Just leave off the 9V battery and flip the power jumper from "BAT" to "USB" - the thermistors are run off of the regulated 3.3V supply on the board, so no other changes are necessary :)
harleen1 year ago
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)  harleen10 months ago
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.
imppa2211 months ago
your firmware link doesnät work :(
tombrew (author)  imppa2210 months ago
Fixed, sorry about that!
autolib1 year ago
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.
Guyp1 year ago
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)  Guyp1 year ago
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!
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!