Introduction: Temperature Monitor With ESP8266 - IoT

This project will help you create a temperature monitor using an ESP8266 SoC and a temperature sensor (DS18B20) with next capabilities:

  • Measure Temperature
  • Send an email if temperature goes under a threshold
  • Monitor temperature and set threshold from a mobile App

To complete this project you will have to create three things

  • Hardware - Basically you have to hook up the temperature sensor to the ESP8266 board and upload the Arduino code.
  • Cloud device - Create the logic that drives the decision making using the IC2Cloud platform www.ic2cloud.com
  • Mobile App - Create the mobile App using AppInventor to monitor and control your temperature appinventor.mit.edu

This project can be easily extended to monitor different thresholds and if combined with an actuator it can control a heating/cooling system.

Step 1: Get Your Materials

To complete this project you need a few things

  • A ESP8266 board. I recommend the Adafruit HUZZAH ESP8266 board. The main advantages are:
    • You get a FCC certified ESP8266 board
    • The ESPB8266 board has multiple pins exposed on the PCB
    • It has a voltage regulator on the board
    • It has buttons to trigger programming mode
  • A temperature sensor. I used a DS18B20 from DealExtreme
  • Some female to female cables
  • And optional if you want to make the module stand alone a USB connector and a USB power supply....and an enclosure.
  • To upload the Arduino code on the ESP8266 board you need a programming cable. I recommend this one from Adafruit.

Step 2: Wiring

The wiring is very simple. You have a TOP VIEW diagram here that shows you how to do it. To be more specific you need to do three connections:

  • DS18B20 - Vcc Pin ---> HUZZAH ESP8266 - 3V Pin
  • DS18B20 - GND Pin ---> HUZZAH ESP8266 - GND
  • DS18B20 - Data Pin ---> HUZZAH ESP8266 - #4 Pin

To be able to program it you need to connect as the programming cable too. If you use the Adafruit cable I recommend then you just plug it in with the black wire to the GND pin as shown in the picture above. For more details how to program HUZZAH board with Arduino please go to Adafruit website.

Step 3: Prepare Development Environments

To program this project you will need three development environments:

Arduino IDE for ESP8266 - You will use this to create the "firmware" for your hardware. To set-up this please follow the tutorial on the Adafruit website.

IC2Cloud Device Builder - You need this to create the monitoring code. To set-up this go to www.ic2cloud.com and register. Once you did that go to this section to create an API password.

App Inventor - You need this to create your mobile App (Android). To set-up this please go to App Inventor website and press the button Create Apps. Follow the instructions on the website. You might need a Gmail address to authenticate there.

It might sound complicated but it is fairly fast to execute all these steps.

Step 4: Program the Hardware

To program the HUZZAH board I have opted for Arduino. A lot of people are familiar with this and considering the simplicity of the code I think it can do the job quite well. I assume you followed the instructions from Adafruit tutorial mentioned in the previous step.

I also assume you followed instructions to set-up you IC2Cloud account and the API access.

Once you did that please download the code I provide here (Temperature.ino file from the ZIP file) and load it in the Arduino IDE. You have to modify a few things in the code to make it work

1. Modify "wifi ssid" string with your wifi SSID.

2. Modify "wifi password" string with your wifi password.

3. Modify "authentication" string with your authentication string for IC2Cloud API. Basically you have to append your user name, colon sign and password and encode the whole string using base 64 encoding. You can use this site www.base64encode.org to do that. For example if your user name is "user" and your password is "password" then you create this string:

user:password

and encode it using the tool from the link above. You should get

dXNlcjpwYXNzd29yZA=

VERY IMPORTANT!
The password is the Api Password and not your login password. The user is your email you use for login.

There is one more thing that we recommend to change (but let's not do it until you understand the inner workings of the entire project) is the device Id.

Last thing is to compile and upload the code on your ESP board. I assume you are familiar with Arduino IDE and once you are properly set up for the ESP board this should be easy.

Step 5: Verify Communication With the Cloud

Once you completed the previous step it is recommended that you verify the communication with the cloud.

If you are familiar with the debug in Arduino please use serial communication to check if everything is OK. You can also go to the Signal Manager on the IC2Cloud website to test if the TEMPERATURE signal is sent to the cloud. The picture above shows you how to do it.

Please be aware that the signal is sent every few seconds.

If this is working properly then your hardware is up and running.

Step 6: Create the Cloud Device

Using the IC2Cloud Device Builder import the BasicSecurity.vcd file on the online IDE. You should see the picture above. The steps you need to do are:

  • Set your own email address as destination.
  • Save the Device with a Name (Le's say "Temperature Monitor").

The logic is fairly simple. The cloud device will read the TEMPERATURE and THRESHOLD and it will send an email if the temperature goes under the threshold. The THRESHOLD signal is set by the mobile application you will create in the next step.

Once that is done you need to start this cloud device.

Go to the Device Manager on the IC2Cloud site and press the button start next to it. You should get a confirmation the device is started and it runs.

Step 7: Create the Mobile App

Using App Inventor from MIT you will create the mobile application. Once you are set-up with App Inventor you can go and import the Temperature.aia file. Once you open the project you should see the user interface designer. Switch to blocks section and you will see the picture above.

The only thing you need to change is your authentication string you have created in the previous steps.

VERY IMPORTANT!
The password is the Api Password and not your login password. The user is your email you use for login.

Once that is done you can build and download the App on your phone and you have everything ready. Follow the instructions on the App Inventor site how to execute the steps.

Step 8: Using the Temperature Monitor

Open the mobile application you have created and you are gong to get a screen like the one above.

Here you can see your temperature from the sensor and the current threshold.

You can change the temperature threshold by using the slider.

Whenever temperature goes under threshold the system will send you an email.

This concludes the project. You have a temperature monitor IoT style ;-)

You can improve it. Here you have a few ideas:

  • Add multiple sensors.
  • Create different thresholds
  • ...and whatever you come up with ;-)

Anyway, if you managed to get to this point then you have the basic skeleton of a temperature monitor that will notify you whenever the temperature is going down.

Please keep in mind this is experimental and you need to make your own judgements how you use this project.

Good luck!

Comments

author
opo.socialintrend (author)2017-06-15

app error

attempt to get item number 2 of a list of length 1: AUTHERROR

19238535_1618297221522538_1186512197_o.jpg
author

i can fix my problem but now my application show Arial

19249872_1618778964807697_1735443712_o.jpg
author
tbarritt made it! (author)2016-02-16

On my phone, all I get is Arial for both the temp reading and threshold. I assume that is the font style.

Screenshot_2016-02-16-13-46-56.png
author

you can fix this problem ? please tell me

author
tbarritt (author)tbarritt2016-02-16

I used an adafruit bme280 to get the temp. Here is the code. It shows up correctly on the signal builder.

String url = "/Wire/connector/set?id=" + devId + "&TEMPERATURE="+bme.readTemperature();

author
TreyH17 (author)2017-05-17

What would it take to make it alert on rise of temperature?

author
TerryS130 made it! (author)2017-01-15

nice and easy, other than Pins on digital thermometer were wrongly labelled (mine were GND, Data, Vcc as per http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf), also the D4 pin on NodeMCU seemed to actually come out on D3.

nodeMCU thermometer.jpg
author
UmangV4 made it! (author)2016-11-30

Hello, I am Stuck in Step 4, I have connected ESP8266 12-E LoLin board, Vin (3.3V) ,Vout(Pin4(That is S3)) and Gnd(Gnd) and DS18B20 onewire (Metal Shielded_Waterproof).

I am Getting Error ERR1. Please help.

Also While commenting "Find Chip, CRC, and Proper Chip", I am getting -0.06 as output and value form portVout(Pin4(That is S3) is reading as 255.

Also not able to detect Get Signal output.

Do I need to put "==" sign or "=" equal sign after "dW1hbmd2YWlAZ21haWwuY29tOnNoYWlsZXNoYmhhaWt1bWFy"?

Please help me out. Thank you in Advance.

ERR1.pngzero.PNGget_signal.PNG
author
muhammedy12 (author)UmangV42016-12-27

i have the same problem i stick whit err1 i use also ESP8266 12-E LoLin board. could you solve the problem.

author
Gibber8 (author)2016-10-29

Well if anyone is still interested, the cloud based device manager appears to be up and running again!

author
Gibber8 (author)2016-07-14

Hi. Is anyone else having a problem with running devices in the cloud? When I open device manager and click on START the indicator goes yellow, then red, then it just hangs and I have to close the browser. When I go back in the device may show as ON or it may not but it never shows RUN.

author
MuhammadD19 (author)2016-06-18

Hello, i can do it so far until Step 4.
but in Step 5, i found error when running the program.
the error sounds like this,
"#error "Please define I/O register types here"
anyone can help?
Thank you.

author
PoojaK31 (author)MuhammadD192016-07-06

Even i am getting the same error. Any updates yet? did you resolve?

author
MuhammadD19 (author)PoojaK312016-07-08

still no update :/

author
yiluo (author)2016-06-23

How can i get the ESP8266WiFIi.h and onewire.h?

author
PoojaK31 (author)yiluo2016-07-06

You can get it from here: http://playground.arduino.cc/Learning/OneWire

author
Giovanni A.M made it! (author)2016-05-16

ciao, a very nice work !

I've tested this nice mix of tech and art.

it work fine, I've modified a part of the esp8266 sketch relatives to the sensor, I use an dht11, now send to android side all available data for display on relative app, now it show temp and humidity.

but I'm stopped because this system isn't bidirectional, can you suggest wich use about (on android side) the "APISetThreshold" ? in wich way I can send some data for ordering that the esp8266 acts something with the gpo02 ? now using the gpo2 like input for the sensor.

regards

ps all of my work around this project is available for sharing, just ask me .

photo_2016-05-16_22-10-48.jpg
author
idunnowtf (author)2016-05-13

how did this work for anyone. kept getting ERR1, data pin for the DS18B20 is the middle pin. looks like i cooked mine after connecting 5 volts to that pin (5 volts is acceptable). Should I have looked it up ... yes. but still.

author
CameronJ4 (author)2016-04-26

Great write-up, thanks for all the information!

I'm using an ESP8266 ESP-1 so I'm connecting the data line from the temp sensor to GPIO2. What do I change in the code?

Thanks for any help!

author
shivayla (author)CameronJ42016-05-13

just change begining line in the code with this line

OneWire ds(2);

author
shivayla (author)2016-05-13

hi, it's a nice project..

but im stuck at the app side..it shows arial on the screen..

it shows error as could'nt communicate with www.ic2cloud.com..pls try to fix this anybody

author
soznik (author)2016-03-26

Error App Inventor

Select list item: Attempt to get item number 2 of a list of length 1: (*empty-string*)
Note: You will not see another error reported for 5 seconds.

author
chrisb50 made it! (author)2016-01-12

it works great good job on the design. I built this for my boss her freezer kept going down and she kept losing a lot of product in her small business. it took a day to build the circuit and a few days todo the programming due to just understanding the different steps in the process. I'm now looking at adding a piezo buzzer to it so there's an alarm at the store itself along with the email warning.

IMG_20160108_141112.jpgIMG_20160108_113238.jpgIMG_20151230_151155.jpg
author
anistor (author)chrisb502016-01-14

Cool!

author
Abdul_Asiiss (author)2016-01-04

help,..

how if using arduino uno and esp8266??

author
johna151 (author)2015-12-10

In file included from C:\Users\antaras\Desktop\ temp test_\Arduino\Temperature\Temperature.ino:1:0:

C:\Users\antaras\Documents\Arduino\libraries\OneWire/OneWire.h:108:2: error: #error "Please define I/O register types here"

#error "Please define I/O register types here"

^

exit status 1

Error compiling.

Hello Word

have anyone something in mind for this error ??

author
MarcinA (author)2015-11-26

Is this possible to do something similar with non-android system?

I mean iPhone...

author
anistor (author)MarcinA2015-11-27

Yes it is possible. There are a few challenges though:

- You need to use iOS SDK (as far as I know there is no equivalent to App Inventor for iOS). You need to be a fairly skilled programmer to use the that SDK.

- You cannot sideload applications as easy as you can with Android.

author
DIY Hacks and How Tos (author)2015-11-21

Great internet of things project

author

Thank you.

author
імартинюк (author)2015-11-22

Good project, thank...