Introduction: Remote Temperature and Humidity Monitoring With ESP8266 and Blynk App
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.
Step 1: Hardware
For this project you need:
1. ESP8266-01 module (buy it form Aliexpress or ebuy)
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.
Step 2: Diagram
The diagram is very simple. Just connect everything like it is shown on the picture.
Step 3: 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.
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.
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.
Step 4: Configure Arduino IDE
1. File - Preferences.
On Preferences tab add the link:
This way, we add the ESP8266 to the list of equipment that IDE works with.
Step 5: Configure Arduino IDE
2. Tools - Boards - Boards manager
In the Board manager look for something like "ESP8266 by...". Click to install.
Step 6: Configure Arduino IDE
3. Now we can see our 8266 board in the list. Choose it from the drop-down list.
Step 7: Configure Arduino IDE
4. Choose the port on which we will work
Yes, by the way, in Tools choose upload speed 11520.
Step 8: Configure Arduino IDE
5. Install libraries for ESP and Blynk.
As soon as it would be downloaded, unpack it to the Arduino - Libraries folder.
Step 9: Configure Blynk
After you have installed Blynk, login to the app and push "Create new project". You will get in your mailbox so-called "Auth token".
Step 10: Configure Blynk
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.
Step 11: ARDUINO Sketch
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.
Step 12: Upload Sketch
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.
Step 13: Make Blynk Application
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".
Step 14: Finished
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.
Step 15: Thanks!
Visit my Blog for more interesting projects :