Simple wireless temperature sensor updating web site with electric imp and Thermistor by tvdl
Contest WinnerFeatured
fig2.jpg
fig1.jpg
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.
 
Remove these adsRemove these ads by Signing Up

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

fig1.jpg
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.
dlemesh says: May 15, 2013. 11:23 AM
hi,
first of all amazing site!!!
i am using your code with a few changes to build a digital meter and i have a question:
you the red box i the picture? how do i get rid of that??
i have never used php...
Untitled.png
tvdl (author) says: May 16, 2013. 3:16 AM
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:

// Create the file that can be read for live updates in a web browser.
$fw = fopen("latestImpData.txt", 'w');
if(flock($fw, LOCK_EX))
{
  fwrite($fw, $target . "|" . $channel . "|" . $dateTime . "|" . number_format($temp, 1) ."|" . number_format($volt, 2) . "|" . $location);
  fflush($fw);
  flock($fw, LOCK_UN);
}
?>


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.

The contents of your latestImpData.txt file should have:
300e600a779951c4|1|2013-02-09 14:54:54|28.8|3.28|location

I've also posted the files at http://trev.id.au/imp/imp.zip if this makes it easier.

bull.steve says: Feb 26, 2013. 11:57 AM
What is the temperature range of this device? For example, can it measure freezing temperatures accurately?
tvdl (author) says: Feb 26, 2013. 12:52 PM
Hi Steve, the sensor I used for this project is a NTC Thermistor from Vishay. It has a temperature range of -40C to +125C so I'd say anything above -40C it will provide a measurement for.
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 "if it's 2 degrees out, will it hurt".
tvdl (author) says: Feb 1, 2013. 7:04 PM
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. :)
mikesoniat says: Jan 26, 2013. 6:58 AM
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!
tvdl (author) says: Jan 26, 2013. 1:21 PM
That's great. If you have any questions, feel free to ask.
tvdl (author) says: Jan 11, 2013. 2:57 AM
To display your local time zone, see the comment on the bottom of step 18 (back one).
Then just change the text in the this to suit so people know what timezone they are seeing.
tvdl (author) says: Jan 11, 2013. 2:55 AM
To change the date/time to your timezone, find the line: date_default_timezone_set("Australia/Adelaide"); and change the part between the quotes to your timezone as per: http://php.net/manual/en/timezones.php
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!