Remote Temperature and Humidity Monitoring With ESP8266 and Blynk App

by BorisV2 in Circuits > Microcontrollers

2721 Views, 11 Favorites, 0 Comments

Remote Temperature and Humidity Monitoring With ESP8266 and Blynk App

blink9.png

It was my first project with ESP8266 chip. I have just built a new greenhouse near my house and it was interesting for me what is going on there during a day? I mean how temperature and humidity changes? Is the greenhouse ventilated enough? So I decided that ESP8266 with DHT22 sensor is a good solution. Next question was, how to monitor the data from the sensors. After a while, I found that Blynk is a perfect app especially for a beginners or non-professional people who wants to build a project for the Internet of Things (IoT).

You can read more about Blynk here.

Hardware

espmodule.jpg
ttlmodule.jpg
dhtblog.jpg
downconv.jpg

For this project you need:

1. ESP8266-01 module (buy it form Aliexpress or ebuy)

2. TTL converter or dedicated programming board for ESP8266. I am using programming board

3. DHT22 (AM2302) - temperature and humidity sensor:

4. Voltage converter. For the ESP modules to be powered, a DC voltage of 3.0V-3.6V is required. Ideally, 3.3V. ESP can be powered from batteries or from a network, by converting AC 220V to DC. In any case, an additional voltage converter will be needed, to manage 3.3V DC voltage.For example, a fully charged 18650 lithium-ion battery gives us up to 4.2 V. Such voltage most likely will kill ESP module. That is why we need a converter.

In this case I am using step-down converter, which let me decrease power supply voltage from 12V to 3.3V.

5. Power supply.
Like I mentioned above I used 12V acid lead battery for this project. It happened only because of I had one spare battery on the shelf. So of course you can use any power supply you want. Only keep in your mind that ESP chips accepts voltages from 3.0 to ,3.6V.

Diagram

diagramm.jpg

The diagram is very simple. Just connect everything like it is shown on the picture.

Software

To build the project, you need to install on your personal computer a program that allows you to flash the module. ARDUINO IDE is very suitable for this - the software development environment for ARDUINO components. ESP8266 is ARDUINO compatible module, so you can use it to program the ARDUINO IDE.

The data is transferred to the phone by using Blynk application.

ARDUINO IDE

Download ARDUINO for your operating system. I am using ARDUINO 1.8.3 on my PC with Windows 10. After installation of ARDUINO IDE, you need to configure it, for using with ESP8266 chips.

BLYNK
Next we need to install Blynk library to Arduino IDE. Download it from here. How to install here.

After you have installed library for Blynk, you will need an app for your phone. Download and install Blynk app from Google Play for Android, or from App Store for iPhone. Of course must have your account on Blynk to use it.

Configure Arduino IDE

ide1.jpg

1. File - Preferences.

On Preferences tab add the link:

http://arduino.esp8266.com/stable/package_esp8266c...

This way, we add the ESP8266 to the list of equipment that IDE works with.

Configure Arduino IDE

ide2.jpg
ide3.jpg
ide4.jpg

2. Tools - Boards - Boards manager

In the Board manager look for something like "ESP8266 by...". Click to install.

Configure Arduino IDE

ide5.jpg

3. Now we can see our 8266 board in the list. Choose it from the drop-down list.

Configure Arduino IDE

ide6.jpg

4. Choose the port on which we will work

Yes, by the way, in Tools choose upload speed 11520.

Configure Arduino IDE

ide7.jpg

5. Install libraries for ESP and Blynk.

As soon as it would be downloaded, unpack it to the Arduino - Libraries folder.

Configure Blynk

blink1.jpg

After you have installed Blynk, login to the app and push "Create new project". You will get in your mailbox so-called "Auth token".

Configure Blynk

blink2.jpg
blink3.jpg
blink4.jpg

Next, enter the name of the project, for example "ESP8266". In the "Hardware model" field, you must select the type of device to work with. In our case this is ESP8266. And the last thing you have to enter is "Auth token".

The "Auth token" is a secret key which is used during the connection with Blynk server. So do not share it with anybody. After clicking the "Create" button, the field for the graphical interface of your application will appear.

Click on the plus sign at the top right - the "Widget Box" toolbar will appear. It allows to add widgets to your control panel.

Looking ahead, I will say that our project will need widgets: "Button", "LCD" and "History graph".Let's say it was the general part. All of this is useful for any project ESP8266 / Blynk.

ARDUINO Sketch

ide8.jpg
ide9.jpg

So let's write a sketch. To do this, we use the previously mentioned Arduino IDE.

If you are going to power the device from the battery, then in line 30, it makes sense to play with the "delay"value. In this sketch, the data is transferring every 2s. Increase dealy time on line 30, to increase the battery life of you device. For example if you will put 300 000 here, data will be transferred every 5 min.

Upload Sketch

ttl.jpg
ide10.jpg
ide11.jpg

Next, plug the ESP8266 module into the TTL converter as shown in the photo below, and connect it to the USB port. If you have the same converter as me, then by itself you need to change the switch to the "Prog" position.

Run the Arduino IDE, and upload the sketch: file - open - your sketch.

Click the "upload" button ( in a yellow circle on the photo). If the firmware download process was successful, the message "Done uploading" appears below.
Below you can see the progress of the upload. There may be reports of incorrect libraries, as on the photo. But latter I found out that everything is working. So the advice is - upload the firmware, check - it will probably work.

Make Blynk Application

blink5.png
blink6.png
blink7.png
blink8.png

Well, the last step, let's the application on Blynk.So open Blynk, and in the "Widget Box" toolbar, select the "Button" widget.

A virtual button will appear on the application desktop. Click it, and get into the settings (see photo).

I have set a button to "Switch". It means the data is transferred while the button is switched on. As soon as the button is switched off, data transfer stops .You can enable "Push" mode. In this case, the data will be transmitted while the button is pressed with a finger. V1 is a virtual button port. Must coincide with the one indicated in the sketch. You can also specify the text that will be displayed on the button in the on position. and off.

Next, from the widgets, select the LCD. Again, go to the settings.

Set the temperature and humidity limits (V2 and V3) and the PUSH mode.
Of course it's interesting to see the history of the sensors. Here you can use the widget for plotting - "History Graph".

Finished

blink9.png
20526239_495622594125393_2217796104544470420_n.jpg

The finished application looks like it is on the picture.

Press the triangle in the upper right corner, and if everything is done correctly, after a few seconds there will be readings from the sensors, and later the graphs will appear.

On the second picture, you will see assembled device.

Thanks!

Visit my Blog for more interesting projects :

https://verysecretlab09.blogspot.com/

Youtube channel:

https://www.youtube.com/channel/UCl8RTfbWUWxgglcJM...