Instructables

Simple wireless temperature sensor updating web site with electric imp and Thermistor

FeaturedContest Winner
Picture of Simple wireless temperature sensor updating web site with electric imp and Thermistor
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

Picture of 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.
tsingh152 months ago

Hey! I have been trying to do this same tutorial but I am getting the following error:

Warning: fopen(data.csv) [function.fopen]: failed to open stream: Permission denied in D:\Hosting\12193764\html\JSON.php on line 32
Warning: flock() expects parameter 1 to be resource, boolean given in D:\Hosting\12193764\html\JSON.php on line 33
Warning: fopen(latestImpData.txt) [function.fopen]: failed to open stream: Permission denied in D:\Hosting\12193764\html\JSON.php on line 41
Warning: flock() expects parameter 1 to be resource, boolean given in D:\Hosting\12193764\html\JSON.php on line 42

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.

tsingh15 tsingh152 months ago

I am using Godaddy for the hosting service!

tsingh15 tsingh152 months ago

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?

Ah-che5 months ago

Hi :) The tutorial is super, BUT... There is no more planner ot imp's IDE site ... Please update the tutorial O:-)

Awesome tutorial!
Just what i was looking for.
Cheers from India.

I suggest to upload more tutorials on Graph API , aka sensor data plotter on a website
that would be much helpful for me as a novice

dlemesh1 year ago
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)  dlemesh1 year ago
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.steve1 year ago
What is the temperature range of this device? For example, can it measure freezing temperatures accurately?
tvdl (author)  bull.steve1 year ago
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) 1 year ago
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. :)
mikesoniat1 year ago
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)  mikesoniat1 year ago
That's great. If you have any questions, feel free to ask.
tvdl (author) 1 year ago
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) 1 year ago
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!