Picture of TempBug: internet-connected thermometer
Screen Shot 2015-01-30 at 8.23.02 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 Sparkfun's Data Stream service, which stores the data for free. Even better, I can use's Sparkfun Data Stream frontend to get nice graphs of the data I've collected.

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
1-40 of 89Next »
alpha01011 month ago

Could you use a 9v wallwart or a USB wall charger instead of a battery(you could use a small solar panel and run indefinetly) ? And, could you print the data to an excel sheet? Could you manage several of these and have them all printed in one excel?

This Seems more practical for me at least. Im no expert but these conversions dont seem very difficult.

lathyrus1 year 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.
lathyrus lathyrus10 months ago

Follow-up: The tempbug has been running smoothly in my attic for 9 months now. My first 9 volt battery lasted only a month, checking the temperature every 15 mins. So I changed the interval to 2 hours and my second battery lasted 6 months. I also noticed that the first temperature reading in each cycle is a bit higher than the others (by about 0.5 degree, I don't know why) so I modified the code to ignore the first reading and average the next 10:

2014-07-14 06:00:08 UTC+1[Device]ignore: voltage: 3.315 temp: 19.4 C2014-07-14 06:00:08 UTC+1[Device]loop: 0 voltage: 3.313 temp: 18.9 C2014-07-14 06:00:08 UTC+1[Device]loop: 1 voltage: 3.311 temp: 18.4 C2014-07-14 06:00:08 UTC+1[Device]loop: 2 voltage: 3.311 temp: 18.2 C2014-07-14 06:00:08 UTC+1[Device]loop: 3 voltage: 3.311 temp: 18.1 C2014-07-14 06:00:08 UTC+1[Device]loop: 4 voltage: 3.313 temp: 18.2 C2014-07-14 06:00:08 UTC+1[Device]loop: 5 voltage: 3.309 temp: 18.3 C2014-07-14 06:00:08 UTC+1[Device]loop: 6 voltage: 3.311 temp: 18.2 C2014-07-14 06:00:08 UTC+1[Device]loop: 7 voltage: 3.313 temp: 18.2 C2014-07-14 06:00:08 UTC+1[Device]loop: 8 voltage: 3.311 temp: 18.6 C2014-07-14 06:00:08 UTC+1[Device]loop: 9 voltage: 3.311 temp: 18.1 C

Building and programming the Imp was so much fun that I bought 2 more and made a phone-controlled electric gate opener, and a gizmo for forcibly rebooting my Wowwee Rovio...

Thanks again Tombrew for the great intro and instructions!

how did you change to a 2 hour interval? was it in the code inserted into electric imp? if so where?

Here's the complete Device and Agent code that I'm using. It logs the temperature on odd-numbered hours (1 a.m., 3. a.m. etc). It uploads to Xively the temperature (Celsius), WiFi signal strength, battery voltage, and lag (how long it took to do the measurement cycle).

//KW tempbug device code v2 20nov2013
// April with a 100k resistor from 3V3 to pin9 and 100k NTC Thermistor from pin9 to pin8
// pin8 TEMP_READ_EN_L - drive low to enable temp reading (great for batteries!)
// pin9 ANALOG NTC value
// benchmarking runtime: first tick with hardware.micros
local tick = hardware.micros();
// turn on WiFi powersave to reduce power consumption when awake
// WiFi is not used until line 44 (no communication with agent until end of program)
// Configure Pins
// pin 8 is driven high to turn off temp monitor (saves power) or low to read
// pin 9 is the middle of the voltage divider formed by the NTC - read the analog voltage to determine temperature
// all calculations are done in Kelvin
// these are constants for this particular thermistor; if using a different one,
// check your datasheet
const b_therm = 4450;
const t0_therm = 298.15;
// turn on the thermistor network
// gather several pin9 ADC and battery voltage readings and average them
// (just takes out some noise)
local val = 0;
local v_high = 0;
//skip first measurement (always low)
local v_high_now=hardware.voltage();
local v_therm = v_high_now * val_now / 65535.0;
local r_therm = 100000.0 / ( (v_high_now / v_therm) - 1);
local ln_therm = math.log(100000.0 / r_therm);
local t_therm = (t0_therm * b_therm) / (b_therm - t0_therm * ln_therm) - 273.15;
local t_str = format("%.01f", t_therm);
local batt_str = format("%.03f",v_high_now);
server.log("ignore: voltage: " +batt_str +" temp: " +t_str+" C");
//then measure 10 times
for (local i = 0; i < 10; i++) {
val_now =;
v_high_now = hardware.voltage();
v_therm = v_high_now * val_now / 65535.0;
r_therm = 100000.0 / ( (v_high_now / v_therm) - 1);
ln_therm = math.log(100000.0 / r_therm);
t_therm = (t0_therm * b_therm) / (b_therm - t0_therm * ln_therm) - 273.15;
t_str = format("%.01f", t_therm);
batt_str = format("%.03f",v_high_now);
server.log("loop: " +i +" voltage: " +batt_str +" temp: " +t_str+" C");
val += val_now;
v_high += v_high_now;
val = val/10;
v_high = v_high / 10.0;
// turn the thermistor network back off
// scale the ADC reading to a voltage by dividing by the full-scale value and multiplying by the supply voltage
local v_therm = v_high * val / 65535.0;
// calculate the resistance of the thermistor at the current temperature
local r_therm = 100000.0 / ( (v_high / v_therm) - 1);
local ln_therm = math.log(100000.0 / r_therm);
local t_therm = (t0_therm * b_therm) / (b_therm - t0_therm * ln_therm) - 273.15;
// format into a string for the string output port
local t_str = format("%.01f", t_therm);
server.log("Current temp is "+t_str+" C");
// update the current battery voltage with a nicely-formatted string of the most recently-calculated value
local batt_str = format("%.03f",v_high);
server.log("Battery Voltage is "+batt_str);
// benchmarking runtime
local tock = hardware.micros();
server.log(format("Read cycle took %d us", (tock-tick)));
local lag = ((tock-tick)/1000000.0);
local lag_str = format ("%.06f",lag);
//log WiFi signal strength
function ReportRSSI() {
local rssi = imp.rssi();
if (rssi < -87) {
server.log("WiFi signal is: " + rssi + " dBm (0 bars)");
else if (rssi < -82) {
server.log("WiFi signal is: " + rssi + " dBm (1 bar)");
else if (rssi < -77) {
server.log("WiFi signal is: " + rssi + " dBm (2 bars)");
else if (rssi < -72) {
server.log("WiFi signal is: " + rssi + " dBm (3 bars)");
else if (rssi < -67) {
server.log("WiFi signal is: " + rssi + " dBm (4 bars)");
else {
server.log("WiFi signal is: " + rssi + " dBm (5 bars)");
return rssi;
local rssi = ReportRSSI();
//attempt to send it to Xively...
agent.send("Xively-temp", t_str); // send data to Xively
agent.send("Xively-lag", lag_str); // send data to Xively
agent.send("Xively-battery", batt_str); // send data to Xively
agent.send("Xively-rssi", rssi); // send data to Xively
// wake up every 2 hours on odd-numbered hours (prevents drifting on slow DHCP)
imp.onidle( function() {
local secsToEvenHour = (1+ 120*60 - (time()%(120*60)) );
local secsToOddHour = secsToEvenHour - (60*60);
if (secsToOddHour < 0) {secsToOddHour += (120*60);}
local snoozelength = secsToOddHour;
server.log("snoozing for " + (snoozelength / 60) + " minutes and " + (snoozelength % 60) + " seconds" );
// full firmware is reloaded and run from the top on each wake cycle, so no need to construct a loop
##################### CUT HERE ######################
//KW tempbug agent code v2 20nov2013
//********************BEGIN XIVELY********************
//Code written by @beardedinventor modified for use by Joel Wehr
API_Key <- "pdyL6p9fp9zVtakiNqFGTaKGXPwqnMuxCdfM7258b1D8D6LI"; //Type your Xively API Key
Feed_ID <- "1282406454" //Type your Feed ID
/// Channel_ID <- "thermistor"; //Type your Channel ID -- modified by KW - see bottom of program
Xively <- {}; // this makes a 'namespace'
class Xively.Client {
ApiKey = null;
triggers = [];
constructor(apiKey) {
this.ApiKey = apiKey;
* method: PUT
* IN:
* feed: a XivelyFeed we are pushing to
* ApiKey: Your Xively API Key
* OUT:
* HttpResponse object from Xively
* 200 and no body is success
function Put(feed){
local url = "" + feed.FeedID + ".json";
local headers = { "X-ApiKey" : ApiKey, "Content-Type":"application/json", "User-Agent" : "Xively-Imp-Lib/1.0" };
local request = http.put(url, headers, feed.ToJson());
return request.sendsync();
* method: GET
* IN:
* feed: a XivelyFeed we fulling from
* ApiKey: Your Xively API Key
* OUT:
* An updated XivelyFeed object on success
* null on failure
function Get(feed){
local url = "" + feed.FeedID + ".json";
local headers = { "X-ApiKey" : ApiKey, "User-Agent" : "xively-Imp-Lib/1.0" };
local request = http.get(url, headers);
local response = request.sendsync();
if(response.statuscode != 200) {
server.log("error sending message: " + response.body);
return null;
local channel = http.jsondecode(response.body);
for (local i = 0; i < channel.datastreams.len(); i++)
for (local j = 0; j < feed.Channels.len(); j++)
if (channel.datastreams[i].id == feed.Channels[j].id)
feed.Channels[j].current_value = channel.datastreams[i].current_value;
return feed;
class Xively.Feed{
FeedID = null;
Channels = null;
constructor(feedID, channels)
this.FeedID = feedID;
this.Channels = channels;
function GetFeedID() { return FeedID; }
function ToJson()
local json = "{ \"datastreams\": [";
for (local i = 0; i < this.Channels.len(); i++)
json += this.Channels[i].ToJson();
if (i < this.Channels.len() - 1) json += ",";
json += "] }";
return json;
class Xively.Channel {
id = null;
current_value = null;
{ = _id;
function Set(value) {
this.current_value = value;
function Get() {
return this.current_value;
function ToJson() {
local json = http.jsonencode({id =, current_value = this.current_value });
return json;
client <- Xively.Client(API_Key);
//********************END XIVELY********************
device.on("Xively-temp", function(v) {
channel1 <- Xively.Channel("temperature");
feed1 <- Xively.Feed(Feed_ID, [channel1]);
device.on("Xively-lag", function(v) {
channel1 <- Xively.Channel("lag");
feed1 <- Xively.Feed(Feed_ID, [channel1]);
device.on("Xively-rssi", function(v) {
channel1 <- Xively.Channel("WiFi");
feed1 <- Xively.Feed(Feed_ID, [channel1]);
device.on("Xively-battery", function(v) {
channel1 <- Xively.Channel("battery");
feed1 <- Xively.Feed(Feed_ID, [channel1]);

Great. Thanks! How would I have it run every 6 hours starting at 8:00 am? I can see where to do it every 6 hours - just 60 *6. But how would I make it start the 6 hour cycle at 8:00 am, 2:00 pm, 8:00 pm, or 2:00 am?

lathyrus lathyrus8 months ago

Here are the graphs on Xively for 3 months

lathyrus lathyrus8 months ago

And here's what my code writes to the Electric Imp IDE log window every 2 hours.


Is there a way to send the remaining battery life data as well as the temperature reading?

StuartH23 months ago

This is really great and the simple to follow instructions got me up and running very easily. I'm trying to take this to the next level now and I've created an amazon cloud instance with running. I'm not a great coder, certainly not for squirrel, and I was wondering what I need to change in the IMP agent code to redirect to my own cloud instance running rather than sparkfun. Any help much appreciated.

Ryan1219787 months ago

Thanks for making this easy to build! but I'm having a problem Xively isn't allowing any new accounts now. so i have this but have no where to sent the info. i tried to use another site but the code wont work with the way its wired. i was wondering if you have any ides what i can do. thanks for any help you can give!

tombrew (author)  Ryan1219787 months ago
Wondered if that would happen. has a nice graphing front end for devices like this. They built their front end on top of Sparkfun's data store. It looks pretty good - I should get around to switching my examples all over to it. Try it out here:

Hi, I just found a blog entry about temperature logging using the Electric Imp and using a graph from ThingSpeak here:

I'm a novice at programming, but do you think it would be possible to reuse the code from Slickstreamer in the Tempbug project?

ThingSpeak graph.png
tombrew (author)  kenny.carlsson3 months ago

Absolutely, though I haven't dug into slickstreamer at all. If you can send HTTP requests to post data, then the imp can do it!

tombrew (author)  Ryan1219783 months ago

Just updated this instructable to use Sparkfun and, so no more Xively troubles!

BenC48 months ago

What kind of wireless range does the imp have?

tombrew (author)  BenC43 months ago

It's very good! Better than your phone or computer; it has the same WiFi chip in it your phone probably has, but the antenna isn't surrounded by a battery and a metal frame.

lathyrus BenC48 months ago

Similar to a laptop's wifi card. My Imp in the attic and the router is in the hallway 2 floors below it on the opposite side of the house. When the Imp's battery begins to run out, the WiFi signal it detects drops, and when if falls below about -93 dBm it can't connect anymore.

Pizzadragon 4 months ago

hah, finally read through all the comments and my Qs are answered. Thanks again for the writeup. This will be perfect for my situation!

Pizzadragon 4 months ago

wow! awesome instructions! I was planning on hacking sth together with an arduino I've got hibernating in a drawer since last xmas, but you won me over with this tutorial.

going to set this up in a utility room at home. I already set up a raspi webcam for visual access, now for temp readings. I've got water pipes that are at risk of freezing in severe weather and this puppy will help me set up alarm notifications for my computer and phone when the temp gets too low.

After that I plan on adding a wifi connected water sensor with notification to monitor for leaks.

If I have an outlet nearby I assume that I can simply use a usb power supply for the board instead of the battery, right?

I assume squirrel enables the option for sending temp readings to anywhere I like, right? I'm building a simple website with a dashboard of info from a bunch of devices, like a couple home security webcams i made with raspis and probably two or three of these tempbugs. Got any advice on whether SQLite would be a good choice or another database? Or perhaps I can tap into the Xively API to feed my webpage dashboard...

Thanks for a great project idea!

achary5 months ago

hello sir i need to build a wake up signal with int pin with other exisiting pins through pushbutton, like pin1 can be wake by pin2 and pin5 via pushbutton pressed..

raydlettca8 months ago

I had the thermometer up on Xively yesterday, but was having trouble with measuring temperature. Then I tried to modify the code, made a mess, and then decided to start from scratch and got rid of everything on electric imp. I started by attempting to relink via BlinkUp and can't get it to link up. Any thoughts on how to get BlinkUp to work again?

tombrew (author)  raydlettca7 months ago

You actually don't need to BlinkUp again; you can just edit the code in the model you've already created. When you hit "build and run" in the IDE, the code you have in the IDE is built and sent to the imp, wiping out the previous code.

BlinkUp is only needed when initially configuring or changing the WiFi credentials on the imp. As long as you're in the same Electric Imp account and on the same WiFi network you were on before, there's no need to do it again.

If you've lost your WiFi configuration and are now having trouble using BlinkUp to get it back, you can take a look at the documentation and tips on BlinkUp here:

KRS Test9 months ago

Thanks for a great list of instructions. You really have done an outstanding job making this manageable for a for someone with limited tech skills!

I have been able to setup the code and the integration to Xively but am having trouble with the readings. The readings remain steady at say 50 for quite a while then spike up to 120 or plunge to -119. Sometimes they stay at say -10 for an extended period of time. Attached is a picture of the Xively graph.

Have tested the readings by placing the E-Imp next to hot and cold items but there is little fluctuation in the readings.

No doubt I have made a simple error somewhere but am struggling to find it.

For the moment the power supply is by USB from a laptop. Am planning on soldering on the battery once the readings work properly.

Any feedback or suggestions would be appreciated.

Thanks again!

Electric Imp output.jpg
tombrew (author)  KRS Test7 months ago

Sounds like a flaky connection somewhere in your thermistor circuit. Go back over your solder joints and make sure they're all holding together properly. It might be a good idea to look up a tutorial on soldering if you're unfamiliar; I've covered the basics here but a more in-depth of cold solder joints and how to avoid them might save you some time.

raydlettca8 months ago

Thanks for the instructions, there were one thing that was not mentioned in putting this together, the 2 pin jumper. I temporarily made one from wire. One problem that I am having is I am not getting temperature reads. The request log is running properly - there are request and responses - but nothing shows up in the graph to the left. Any thoughts?

Try to write the temperature as a server.log() statement in the Imp IDE first, to make sure the thermistor is working correctly, before you try to draw graphs in Xively. Uploading data to Xively is tricky - I eventually got something to work, but I don't really understand how it works!

lenny20201 year ago

I tried to build it--great, thorough, easily understandable instructions, but I am not getting any info posted to Xively. I copied the info for lines 7 and 8, and although the project seems to cycle as expected, the log states:

Posted to Xively: 120.21, got return code: 56, msg: <html>

<head><title>400 Bad Request</title></head>

body bg color="white">

<center><hi>400 Bad Request</hi></center>




I am getting no data posted, and the Request log sits empty with the "waiting for requests area" just cycling. Where have I screwed up? I could send you any additional information you request, if needed

tombrew (author)  lenny20201 year ago

Hi Lenny,

Sorry, that sounds frustrating! Let's look over your code on a direct message.

davemack tombrew10 months ago

I have also just built this and get this message when it tries to send data to Xively. Perhaps I have the same issue as Lenny.

2014-07-21 14:45:04 UTC-4
Posted to Xively: 71.60, got return code: 56, msg: <html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>

davemack davemack10 months ago


With Lenny's help I found the problem! The Feed ID is a number and should not have quotation marks around it.

My unit now works.



HandyFrank11 months ago

I've been wanting to create a wifi thermometer for a while, this plan looks perfect! I'm a newbie when it comes to building electronics so I have a few questions if you can share some knowledge.

Are the 2 breakout boards you link to different from each other, or one an older version or something? I noticed one is the April breakout and is green, and the other just lists as a plain breakout board and is red. Any different and is one better than the other? I see in your pics you used the green april breakout board I think.

Any way to add a humidity sensor into the mix? Would that require a whole set of different details, or can it be blended into the existing coding and add either a combo temp/humidity sensor, or a separate humidity sensor?

I can in theory build this on a mini breadboard before doing any soldering, right? Maybe i'll do that and practice my soldering skills on a test board so I don't mess up the breakout board.

Any recommendations on a soldering iron that is decent, but won't break the bank for someone who hardly does soldering? Any tips on resources for getting into learning more about how all of this works? I'm a complete newbie so I can use tips on soldering, recommended entry level equipment, understanding of circuits and all the components, etc. I see that Amazon (and AdaFruit) sell breadboard starter kits that mention Arduino. Is that a good thing to buy to start playing and learning? Is Arduino way harder to use vs. Electric Imp?

Seems like DigiKey has everything needed to build this, I think i'll order from them.


tombrew (author)  HandyFrank11 months ago

The green and red breakout boards are identical - use either of the ones I linked to.

This instructable doesn't cover what you need to do temperature and humidity sensing, but you might take a look at the electric imp reference code for the DHT11:

You certainly can build this on a breadboard, but you'll need to make sure you get an electric imp breakout board with headers, or put headers on your breakout board. You should check with google for the best soldering iron recommendations; I've got a pretty nice one and am therefore spoiled.

Arduino vs. Electric Imp isn't really harder/easier; they're different device with different purposes. I can't speak to much on Arduinos goals as a project or tool, but I can say the Electric Imp is made specifically to connect things to the internet, and it does that quite well.

Best of luck and have fun!

illiac41 year ago

I have made it but it shows around 80. I assume thies is in fahrenheit. What do i need to change that it will be displayed in celsius? TNX

tombrew (author)  illiac412 months ago
Yep, it defaults to fahrenheit. You can change it to celsius by calling "read_c" instead of "read_f" on line 103 of the device code.
dbehman1 year ago

Excellent article! I'd like to build this for a swimming pool thermometer. Do you think this would work with the sensor submerged?

tombrew (author)  dbehman1 year ago

I think it could (not the imp and power supply, though!) The longer the leads on your thermistor, the less accurate it will be. A creative mechanical design could help, or you could look into thermocouples.

byron1121 year ago

hi im trying to build the temp bug and i have it all wired up and i have used the imp before to turn on and off a light. but now that i have it programed and all hooked up and cap hooked up the right way. the imp card blinks red 3 times then flashes green for half a sec then it turns off. what does this mean??? Ive tried powering it via usb and 9v battery. same thing... any help would be great!

tombrew (author)  byron1121 year ago

That's actually just it working! The three red blinks are the imp attempting to connect to your WiFi, the one green blink happens when it connects. As soon as it connects, it runs the entire firmware and uploads the measurement in about a second, then goes to deep sleep - which is why you see it stop blinking. You should see it do this once every 15 minutes.

ai4px1 year ago

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

1-40 of 89Next »