[Edit 2014] The planner that was used by Electric Imp is no longer used and not available anymore.[/Edit]

This is a small project to get you started with the electric imp and a Thermistor so you can see how you can get temperature readings updating live on a web site. This instructable will address both the hardware and the web site along with all the parts in between. I've tried to keep it as simple as possible which means there are plenty of ways you can expand on it.

The first part will address the electric imp and how we connect a resistor and Thermistor to create a very simple circuit called a voltage divider and use the imp's built in analog to digital converter to take a reading and calculate what the temperature is. I'll also go into some detail on how the circuit and it's components work.

Step 1: How it all fits together and what you need

We’re going to create a voltage divider network using a 10k resistor and the 4.7k Thermistor. The Imp will read the voltage between the resistor and thermistor. The Imp then does some calculations on this and stores the value. It does this 50 times every 5 seconds (or there about) to get an average reading. This average reading is sent to HTTP Request node (which lives in the Amazon Cloud) which in turn sends it to your web server.

Your web server receives this as parameters attached to the URL, logs it, and displays the result.

You're going to need the following:
electric imp
Sparkfun electric imp Breakout (April board)
Thermistor - NTC 4.7Kohms 2% Radial as the temperature sensor.
10k ohm Resistor 1% 1/4W
• Some connectors (I used):
   o Stackable Header - 1 x 10 – Standard as it allows me to plug into a breadboard, but also access from the top.
   o Break away headers - straight - brake off three pins for the jumper connection to select USB/Battery
• Some hookup wire (I use a 40P 80mm dupont wire, male-male terminated with pins and tear off what I need).
• And a breadboard to put it together on
• A USB cable for power.

I got all my parts from Electron Hobbies.
<p>I've combined this code with another tutorial to make the temperature sensor work with the Plotly system:</p><p> http://dylandylandylan.com/?p=170</p>
<p>hey , did you ever update this code? </p><p>i have gotten most of it to work except it's read temperatures in the 620's . I think it maybe a squigden hight, as i'm not living in a volcano.</p>
<p>haha (re volcanic temps)</p><p>No I haven't as yet. Life has been a bit busy. It is time though :) Hopefully in the next month.</p>
<p>coool . this stuff is hard! so hard, I had to get my wife to help me with the maffs bits . TILL NEXT MONTH </p><p>wish I did have a volcano lear though </p>
<p> imp has changed a lot in year or so . But we fixed some of the bugs in the code !</p><p>so cut and past away </p>
<p>line 105 to 114 ! Make the formatting match , dont just cut and past </p>
<p>// We're going to use an extended Steinhart&ndash;Hart equation to</p><p> // calculate the temperature based on the calculated</p><p> // resistance of the thermistor. We'll include the</p><p> // conversion factor from Kelvin to Celsius</p><p> local tempC = 1.0/(A + B * math.log(ohms) +</p><p> C * math.pow(math.log(ohms), 2) +</p><p> D * math.pow(math.log(ohms), 3)) - 273.15;</p><p> return tempC; // and return the temperature </p><p> }</p><p>}</p>
<p>Hey! I have been trying to do this same tutorial but I am getting the following error: </p><p><strong>Warning</strong>: fopen(data.csv) [<a href="http://lifetym.me/function.fopen" rel="nofollow">function.fopen</a>]: failed to open stream: Permission denied in <strong>D:\Hosting\12193764\html\JSON.php</strong> on line <strong>32</strong><br><strong>Warning</strong>: flock() expects parameter 1 to be resource, boolean given in <strong>D:\Hosting\12193764\html\JSON.php</strong> on line <strong>33</strong><br><strong>Warning</strong>: fopen(latestImpData.txt) [<a href="http://lifetym.me/function.fopen" rel="nofollow">function.fopen</a>]: failed to open stream: Permission denied in <strong>D:\Hosting\12193764\html\JSON.php</strong> on line <strong>41</strong><br><strong>Warning</strong>: flock() expects parameter 1 to be resource, boolean given in <strong>D:\Hosting\12193764\html\JSON.php</strong> on line <strong>42</strong></p><p>Can you tell what am I doing wrong? The imp shows posted successfully everytime. I am posting asynchronously to http://www.lifetym.me/JSON.php file in the new Agent format of electric imp.</p>
<p>I am using Godaddy for the hosting service!</p>
<p>So I was able to fix the issue that I was facing. But now I notice that the data from the imp is reaching the JSON.php file but the file is not accepting the data hence it always finds variables from the imp as null! Any clues why?</p>
<p>Hi :) The tutorial is super, BUT... There is no more planner ot imp's IDE site ... Please update the tutorial O:-)</p>
Awesome tutorial! <br>Just what i was looking for. <br>Cheers from India. <br> <br>I suggest to upload more tutorials on Graph API , aka sensor data plotter on a website <br>that would be much helpful for me as a novice <br> <br>
hi, <br>first of all amazing site!!! <br>i am using your code with a few changes to build a digital meter and i have a question: <br>you the red box i the picture? how do i get rid of that?? <br>i have never used php...
Hi dlemesh, I think the problem exists in the last part of the JSON.php file. When I look at your 'latestImpData.txt' file, it shows the extra info in there. I notice I do have a comment in that last part which does not need to be there. Maybe re-do the last part of your JSON.php file with:<br> <br> <strong>// Create the file that can be read for live updates in a web browser.<br> $fw = fopen(&quot;latestImpData.txt&quot;, 'w');<br> if(flock($fw, LOCK_EX))<br> {<br> &nbsp; fwrite($fw, $target . &quot;|&quot; . $channel . &quot;|&quot; . $dateTime . &quot;|&quot; . number_format($temp, 1) .&quot;|&quot; . number_format($volt, 2) . &quot;|&quot; . $location);<br> &nbsp; fflush($fw);<br> &nbsp; flock($fw, LOCK_UN);<br> }<br> ?&gt;</strong><br> <br> This is the file that is read by the web page. You can see the fwrite line which creates the string and then writes it to the file.<br> <br> The contents of your latestImpData.txt file should have:<br> 300e600a779951c4|1|2013-02-09 14:54:54|28.8|3.28|location<br> <br> I've also posted the files at <a href="http://trev.id.au/imp/imp.zip" rel="nofollow">http://trev.id.au/imp/imp.zip</a> if this makes it easier.<br> <br>
What is the temperature range of this device? For example, can it measure freezing temperatures accurately?
Hi Steve, the sensor I used for this project is a <a href="http://electronhobbies.com/sensors/95-thermistor-ntc-47kohms-2-radial.html" rel="nofollow">NTC Thermistor</a> from Vishay. It has a temperature range of -40C to +125C so I'd say anything above -40C it will provide a measurement for.<br> As to accuracy, I haven't used it below freezing (0C) but what I have found is Thermistors are pretty good for general use. I've used this project next to a known outdoor temp sensor for my weather station and it's been within 1C. I would base my decision to use on &quot;if it's 2 degrees out, will it hurt&quot;.
Step 9: Corrected a copy/paste error in the switch(port) section. It will work now with ports higher than 2. Thanks Chrischi from the electric imp forum. :)
Great project! I've been interested in the Imp and have been looking for an excuse to learn about it. I'm definitely going to build this!
That's great. If you have any questions, feel free to ask.
To display your local time zone, see the comment on the bottom of step 18 (back one). <br>Then just change the text in the this to suit so people know what timezone they are seeing.
To change the date/time to your timezone, find the line: date_default_timezone_set(&quot;Australia/Adelaide&quot;); and change the part between the quotes to your timezone as per: <a href="http://php.net/manual/en/timezones.php" rel="nofollow">http://php.net/manual/en/timezones.php</a>

About This Instructable


154 favorites


More by tvdl: Simple wireless temperature sensor updating web site with electric imp and Thermistor
Add instructable to: