Instructables
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

Step 1: Gather the parts

Picture of Gather the parts
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!

Step 2: Wire it up

Check out the breadboard diagram in the photos to see how we'll be wiring up your tempbug. 

First, connect the battery clip to the breakout board.
  1. If your battery clip has a connector on the end, cut it off. Strip about 1/8" off the end of each wire and twist the strands to keep them together. If you don't want long leads hanging off your tempbug, you'll want to cut the wire to about 2" long or a little less.
  2. Secure your electric imp breakout board to your work surface and heat up your soldering iron.
  3. One pad at a time, use the soldering iron to heat the "P+" and "P-" battery pads on the breakout board. For each pad, when it gets hot, flow a good-sized bead of solder onto the pad. Take care not to short the pads together.
  4. Place the red lead from the battery clip against the bead of solder on the "P+" pad and heat the pad and wire together with the soldering iron. When the solder flows, hold the parts together and remove the iron. Let the solder cool, then let go.
  5. Repeat previous step with black lead and "P-" pad. Refer to photos to see how this should be arranged. Note that you should follow the label on the board, not right vs. left, as your breakout board may have the pads on opposite sides.
Connect the Capacitor

When the imp turns on its WiFi transmitter, it can draw a lot of current (up to 400 mA, during initial calibration) from your power supply. To keep this sudden current draw from "drooping" the power supply and browning out your tempBug, we've got a BIG HONKING CAP. We'll connect the capacitor in parallel with the battery, the battery will charge the capacitor to the same voltage as the battery, and if the imp suddenly demands more current than the battery can dish out, the capacitor will pitch in to help out. 
  1. The leads on the capacitor go through the breakout board at "VIN" and "GND" which are next to each other along the bottom edge of the board. Note that the negative side of the capacitor is marked with a big stripe with a "-" sign in it, and should go to ground
  2. One pad at a time, use the soldering iron to heat the wire and the pad, then flow some solder onto the joint and remove the iron.
  3. When you're all secure, trim the excess from the capacitor leads with your angle cutters or wire cutters.
Connect the Resistor
  1. The 100kΩ resistor can go either way around and is connected between pin9 and 3V3 on the electric imp breakout board. 
  2. Bend the wire leads to fit and push them through the holes marked "3V3" and "Pin9".
  3. Just as you did with the capacitor leads, solder ONLY THE 3V3 SIDE to the breakout board. The thermistor needs to share the Pin9 pad with the resistor, so don't solder that side yet!
Connect the Thermistor
  1. Just like the resistor, the thermistor is a passive component and can go either way around. If you bought the same one as me, the wire ends come pre-stripped. Push one end through the Pin9 hole and the other through the hole marked "Pin8". 
  2. Now, solder the resistor and thermistor leads together through the Pin9 pad.
  3. Lastly, solder the last thermistor lead into the Pin8 pad.

Alright, all wired up! Let's take a look at what you just built.

Step 3: How's this thing work?

Picture of How's this thing work?
100k_NTC.jpg
The operating principle behind the tempbug is really simple. All we're doing here is making a resistive divider using a resistor and a thermistor, and measuring the voltage in the middle using an Analog-to-digital converter in the electric imp.

Wait, what's a thermistor?

A thermistor is a temperature-dependent resistor; it has a specific resistance at room temperature, and its resistance varies in a known proportion with the temperature of the component. In our case, we've selected a NTC, or negative-temperature-coefficient thermistor; the resistance of the part will decrease as temperature increases.

Got it, but what's the deal with the resistor? 

Together, the resistor and thermistor form a resistive divider; the two resistors, wired up in series (end-to-end) have an effective resistance equal to the sum of their individual resistances. This determines the amount of current that flows through them: V=I*R (ohm's law), V=3.3V (from the imp breakout board's 3.3V on-board power supply), R = the 100kΩ + the thermistor's resistance at the current temperature -> now we know how much current is flowing through the circuit. 

Going back to Ohm's Law, we know that the voltage across the thermistor = I*R, where I is the current through the divider (they're in series, so both components see the same current), and R is the current resistance of the thermistor. Therefore, if we can measure the voltage at pin 9, we can solve for the resistance of the thermistor. Given the thermistor's resistance, we can determine the temperature of the part.

Hey wait, the other side of the thermistor isn't connected to ground!

Right you are. It's connected to pin 8. This is a sneaky trick we'll use to save the battery. Current flowing through the resistive divider drains the battery, so we'll only let the current flow when we want to measure the temperature. We do this by programming pin8 to be a digital output. When we set pin 8 high, the voltage drop across the divider is 0V, so no current flows. When we want to take a measurement, we drive pin 8 low and sink current from the divider through the imp. 

How do we actually do the measuring?

To measure the voltage across the thermistor, we set up pin 9 as an analog-to-digital converter, which allows us to take an accurate measurement of the analog voltage on the pin using the imp. Check out the software in a few steps to see how that's done. 



Step 4: Power up!

Picture of Power up!
done.jpg
blinkup_position.jpg
blinkup_cover.jpg
Ok, enough math, let's get to the actual temperature-measuring part. 

Connect the battery

To secure the battery to the breakout board, a little square of foam tape will do the trick. Cut a small piece off with a pair of scissors and stick the sticky side to the back of the breakout board. Peel back the backing film, and stick the battery on, making sure to keep it nice and square - this stuff is sticky! Once you've got it stuck in place, go ahead and connect the battery clip.

Check the jumper

Make sure the jumper on your breakout board is set to connect the middle pin and the "BAT" pin. Check the photos if you're not sure. If your imp doesn't power up when you click it into the socket, double-check the jumper.

Plug in the imp

Insert your imp into the socket on the breakout board, and it should start to blink red or orange (unless you've connected it before on this network, in which case it will just connect again). Congrats! You're powered up and ready to blink up and program.

BlinkUp

If you haven't already registered as an electric imp developer, you'll need to do that now. Head to ide.electricimp.com to sign up (it's free). You'll also need to download the electric imp app on your smart phone, which is also free - just search for "electric imp". Log into the app with the same account credentials you used to register at plan.electricimp.com. 

Once you're logged in, add your wireless network to the list of networks in the electric imp app. If you're on iOS, it will prompt you to allow it to use the network you're already on, and you'll just need to add the password yourself. To add a new network manually, select "other network" and type in your SSID and password. Check the "save this network" button!

Once you've added the network, you're ready to configure the device with BlinkUp. Make sure the imp is powered up. If it's powered up but stopped blinking, reset the power by "push-pushing" the card (push once to disconnect, count to 3, push again to reconnect) so you can be sure it's listening for the BlinkUp signal. 

Hold the screen of your phone against the top edge of the imp and press "send BlinkUp" in the electric imp app. The screen on your phone will begin to blink quickly for about 10 to 20 seconds, then stop. The imp should blink green once ("got it!"), then start to blink red/orange ("found the network, connecting to the electric imp server"). After a second or so, the imp should be able to phone home to the electric imp server, and will start to blink green. You're connected. Excellent.

Now it's time to program the imp! Head to the next step.



Step 5: Setting your imp firmware

Picture of Setting your imp firmware
device_settings.png
creating_model.png
device_configured.png
ide.png
Point your browser to ide.electricimp.com again and log in. This takes you back to the IDE window.

If you've connected this imp breakout board before (you pro), it will pop back up in the IDE under the model it was last a part of. If this is a brand-new breakout board, it will appear in the IDE's left-hand nav panel under "New Devices", at the top of the panel. You'll see a little number in this panel showing the number of new devices there waiting to be configured - probably just one!

Click "New Devices" to see the list of new devices. Again, if you've never configured this device before, it won't have a name, so it will default to a long hex string (this device's Device ID). Click on the device to open up the settings for the device. This is where you can name the device and assign it a model. Go ahead and name it whatever you like, and create a new model by typing a name for your new model in the model drop-down. When you hit "save changes", you'll be taken to the code window for this new model, and you'll see your new device is now listed under that model in the left-hand nav.

A model has two parts: an agent and a device. The device firmware is simply the code that runs on the imp itself. The agent is that device's partner - a tiny server that runs in the electric imp cloud. The device and agent can send information back and forth, and the agent can talk to the rest of the internet and has its own URL. You get to write code for both of them.

... Or you can use the code that's already written for you :) Head to github, and notice that there are two files here - one for the agent and one for the device. Accordingly, there are two windows for you in the IDE - one will say "agent" and the other "device". Copy the correct code into each window.

If you hit "Build and Run" now, you'll see the device read the temperature and then go to sleep, but the agent will have an error when it tries to log the data to Xively because you haven't added your Xively account yet. Let's do that next. If you did do this, and your device has gone to sleep for 15 minutes, you can disconnect and reconnect power (by simply pulling and re-inserting the jumper) to get the imp to wake up again. 

Let's connect your new thermometer to Xively to log the data, then we can come back and take a look at what makes the firmware work. 

Step 6: Connecting to Cosm

Picture of Connecting to Cosm
xively_adding_device.png
xively_new_channel.png
adding_xively_info_to_agent.png
xively_view_feed.png
xively_graph.png

To connect your thermometer to Xively, you'll first need a Xively account. Head to https://xively.com and register if you haven't already (again, it's free). When you register, you'll be taken to a page which enthusiastically encourages you to create a new device. Go ahead and click the big plus button. Creating a new device is quite simple: name it, describe it, click the "Private Device" radio button (unless you want a public device!), and click the "add device" button. This will take you back to the dashboard for your new device, where there's some important info waiting for you.

Inside the dashboard for your newly-created device, you'll find your API key and a "feed ID" for the feed you've just created. You need to add these parameters to the agent in order to get things working. Copy each from the channel dashboard and use them to fill in lines 7 and 8 of your agent firmware.

The agent is set up to create a temperature channel for you inside this feed, so you don't even need to do that. You can go ahead and hit "Build and Run" in the agent now, and you're off to the races.

After a few updates, you'll have a nice graph of the history of your datastream!

Let's head back to the code editor and take a look at how the imp is working this magic.

Step 7: Digging into the Code

Picture of Digging into the Code
xively_graph.png

Imp firmwares are written in an object-oriented language called squirrel, which looks and feels a lot like javascript. Squirrel runs in a virtual machine on top of the imp OS inside the imp, so runtime errors won't knock your device offline, and you have access to a lot of nice OS-based features, like buffered serial input and easy one-line APIs to set GPIOs or communicate with peripheral devices.

To take a look at all the things you can do in your imp firmware, check out the electric imp API reference and electric imp worked examples page. To see which pins can do what, check out the imp pin mux.

Our code here is pretty simple. Here's our basic operating procedure:

  • Set some constants
  • Define a class for our temperature sensor
  • Instantiate our class to create a temperature sensor object
  • Read the Temperature Sensor
  • Send the datapoint to the agent
  • Schedule ourselves to wake up in a bit and do it all again

The constants on lines 9 to 12 look a little ominous, but they're simple. These are the parameters for your thermistor - you can find them on the datasheet for the thermistor you're using. If you're using the thermistor I linked to earlier, you can even keep the parameters already set here.

Lines 22 to 83 are a class definition - this is basically a set of instructions for how to do various important things with a thermistor, like read the temperature. This comes straight from github - it's a nice, modular piece of code so that it can easily be reused.

After that, we just need to define our high-level logic. On lines 91 to 95, we configure the two pins we're using. Remember from when we built the device - one of the pins is an enable pin, which will allow current to flow through the thermistor when it is set low. The other pin is our analog input pin, which we'll use to read the voltage across the thermistor.

// Configure Pins
// pin 8 is driven high to turn off temp monitor (saves power) or low to read
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;


On Line 99, we call on our class definition from earlier to create a thermistor object. This object takes in the constants we set earlier, and has methods that allow us to read the temperature in Celsius or Fahrenheit.

// instantiate our thermistor class
myThermistor <- thermistor(temp_sns, b_therm, t0_therm, r_therm, 10, false);

Lines 101 to 109 are where the magic happens - we enable the sensor, take a reading, send it to the agent, and disable the sensor again to save battery.

// enable the temperature sensor
therm_en_l.write(0);
imp.sleep(0.001);
local id = hardware.getdeviceid();
local datapoint = { "id" : id, "temp" : format("%.2f",myThermistor.read_f()) } agent.send("data",datapoint);
therm_en_l.write(1);

And lastly, schedule a wakeup in fifteen minutes. We'll go to deep sleep in the mean time, saving the battery:

//Sleep for 15 minutes and 1 second, minus the time past the 0:15
//so we wake up near each 15 minute mark (prevents drifting on slow DHCP)
imp.wakeup(3, function() { server.sleepfor(1 + 15*60 - (time() % (15*60))); });
// full firmware is reloaded and run from the top on each wake cycle

That's the device firmware - let's take a look at the agent. You've already seen part of the agent - we set the Xively API Key and Feed ID on lines 7 and 8 of the agent earlier. Below that, we have more class definitions - three of them. Just like the class definition that gave instructions for working with a thermistor, these class definitions give instructions for sending and receiving data from Xively over HTTP.

Lines 135 to 137 are a really interesting bit of code - this is the hook that the agent uses to receive new temperature data from the device. This is done by registering an agent "callback" with agent.on. This says, "when the device sends you an event called "temp", call the following function with the data marked with that tag". Looking back at line 108 of the device firmware, we see that we sent data marked "temp" with a function called "agent.send". This is where that data went!

device.on("data", function(datapoint) {
postToXively(datapoint.temp, datapoint.id); });


Lastly, we see the agent do two things when it first starts running. The first: it sends a log message letting us know that it started and is ready to get data. Second, it instantiates two of the Xively objects we defined earlier, letting us use the methods of those classes to send data to Xively as it comes in.

The agent doesn't restart or sleep; it starts the first time the device boots with this model, and continues to run forever, handling each new datapoint when it comes in by calling the "device.on" callback. It's the device's brain in the cloud!

That's the firmware! Enjoy your new internet-connected thermometer.

1-40 of 68Next »
lenny20203 months 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>

<hr><center>nginx/1.1.19</center>

</body>

</html>

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)  lenny20203 months ago

Hi Lenny,

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

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
[Agent]
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>
<hr><center>nginx/1.1.19</center>
</body>
</html>




Tombrew,

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.

Thanks,

Dave

lathyrus10 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

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!

HandyFrank2 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.

Thanks!!!

tombrew (author)  HandyFrank2 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: https://github.com/electricimp/reference/tree/mast...

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!

illiac42 months 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)  illiac42 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.
dbehman3 months 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)  dbehman3 months 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.

byron1123 months 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)  byron1123 months 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.

ai4px4 months ago

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

365nice made it!6 months 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 365nice5 months 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)  ygodnik5 months 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 tombrew5 months 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.

discostu9566 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)  smilesfromnowhere7 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)  smilesfromnowhere7 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.
petewa7 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
frank5637 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!
ghwood8 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)  ghwood7 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 tombrew7 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)  stealth321 year 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 Workshop9 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 tombrew8 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-atl8 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 tombrew8 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-atl8 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) 8 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 tombrew8 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
jeb1238 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
1-40 of 68Next »