You are on page 1of 12

 (/) Circuits (/circuits/) Workshop (/workshop/) Craft (/craft/) Cooking (/cooking/) Living (/living/) Outside (/outside/) Login (/account/login/)

Login (/account/login/) | Sign Up

Teachers (/teachers/) (/account/register/)

instructables (/circuits/)
circuits
Projects (/circuits/projects/) Contests (/contest/) Let's Make... 
advertisement

TerraControl V3.0 - ESP8266 + BLYNK


By PraetorianCZ (/member/PraetorianCZ/) in Circuits (/circuits/) > Wireless (/circuits/wireless/projects/) 6,347 59 11 Featured

Download Favorite

(https://cdn instructables
auto=webp&frame=1&fit=bounds&md=1509322843)
com/ORIG/FIB/Z48W/J98RL5BZ/FIBZ48WJ98RL5BZ jpg?

(/member/PraetorianCZ/)
By PraetorianCZ
(/member/PraetorianCZ/)
More by
www.terracontrol.cz
the author:
(http://twitter.com/praetoriancz)

Follow

About: Technology geek, love discovering new possibilities... More About PraetorianCZ » (/member/PraetorianCZ/)

QUESTION: Would you be interested in new version using Wemos D1 mini and both DS18 sensor
(for temperature) and DHT22 (for humidity)? Let me know in the comments. Thanks!
/
If you like this project, please VOTE for it in the Wireless contest... Thank you all very
much!

Hey guys,

after few months of playing with ESP8266 I nally got new version of TerraControl I'm satis ed
with and willing to share with you. Some of you might notice I'm skipping version 2.0...that's
because that version was using mostly the old code with few additions but it was still messy as
hell. Thanks to Blynk I was able to cut over 600 rows of code to 100 rows of much simple code!

What's changed?

Little adjustments is the physical connections. Mainly because of the DHT sensor which could
not be connected while booting up in the old version. It is all xed now and no power
blackout will mess with your settings.
No ESP8266 WebServer. Which is a good thing, trust me on this.
Total control via Blynk app. From anywhere in the world, you can control anything you want. I
know this might sound as an advertisement, but I really grew to like Blynk.
Much more possibilities - whole household connected and controllable/monitored via one
app.

 Add Tip V Ask Question | Comment Download

advertisement

Step 1: What You Need...

(https://cdn instructables
auto=webp&frame=1&fit=bounds&md=1509326405)
com/ORIG/FWE/9WL9/J98RL6X5/FWE9WL9J98RL6X5 jpg? (https://cdn instructables
auto=webp&frame=1&fit=bounds&md=1509326406)
com/ORIG/F84/3ENU/J98RL6XF/F843ENUJ98RL6XF jpg?

/
NodeMCU 1.0 12E board - $3.32 (https://www.ebay.com/itm/ESP8266-ESP-12E-CH340G-WIFI-
Network-Development-Board-Module-For-NodeMcu-Lua/201743743504?
epid=581455279&hash=item2ef8dd3a10:g:Qk8AAOSwF3JZga5A)
Relay board - for example - $5.90 (https://www.ebay.com/itm/NEW-4-Four-Channel-relay-
module-with-opto-isolated-compatible-3-3V-and-5v-signal/122712496311?
hash=item1c923c18b7:g:tR4AAOSwna1Zv8Kj) (https://www.ebay.com/itm/NEW-4-Four-
Channel-relay-module-with-opto-isolated-compatible-3-3V-and-5v-signal/122712496311?
hash=item1c923c18b7:g:tR4AAOSwna1Zv8Kj)
Temperature and humidity sensor DHT22(11) - $2.87 (https://www.ebay.com/itm/1PCS-
DHT11-DHT22-AM2320-AM2302-Digital-Temperature-Humidity-Wemos-Sensor-
M85/152363526589?hash=item237992e9bd:g:kS0AAOSwhdRYWQPB)
Given the nature of NodeMCU board (its output is only 3.3v) you will either have to buy 3.3V
relay board (in the link above), or modify 5v board, or buy I2C logic converter module - for
example (https://www.ebay.com/itm/2Pcs-4-Channel-IIC-I2C-Logic-Level-Converter-Bi-
Directional-Module-5V-3-3V/221919114584?hash=item33ab68f558:g:NvIAAOSw5VFWJwmj)-
$0.9
5V source (I'm using older usb charger)
wires
solder
case/box
Arduino IDE

Connections --> NodeMCU

DHT22/11 data pin --> D6

relayLight --> D1
relayHeat --> D2
relayHeat2 --> D5
relayFan --> D9 (RX pin on NodeMCU)

You need to power the modules according to their specs. If you are using 3.3v relay board, you
can power it straight from the NodeMCU, otherwise you need to use external 5V.

I'm using my old parts and case, only needed to switch two wires...

 Add Tip V Ask Question | Comment Download

Step 2: Blynk Setup

/
For those who don't know what Blynk is, it is a Platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet. It's a digital dashboard where you can
build a graphic interface for your project by simply dragging and dropping widgets. You might
need to purchase some energy in the Blynk app but I think $4-5 is a good price for project like
this.

Let's start on Andorid device (iOS version doesn't allow adding widgets or editing Eventor
events yet):

Download the Blynk app


Sign up or login (if you already have an account)
Tap "+" to create New Project Give the project a name and select device you are using (in our
case it is ESP8266) and tap "Create" You will receive an Authentication token in you mail box,
we are going to need it later
On the Blynk Project page tap "+" and add:
4 buttons
4 LEDs
2 (labeled) displays
Real-Time clock
Noti cation
Eventor
History Graph (optional)

Use the widget settings as seen on the last picture (if you set it up di erently you will need
to modify the code)
In the project settings (nut icon on the top) "Send app connected command" to ON.
Close the settings and open Eventor

/
 Add Tip V Ask Question | Comment Download

Step 3: Eventor

(https://cdn instructables com/ORIG/F7V/M97K/J98RL9PY/F7V


auto=webp&frame=1&height=1024&fit=bounds&md=15093300

Let's continue with creating Eventor events...

First set up the Light control:

Add new event


When...TIME (select time when you want light to turn ON) set pin...(V10) to 1

Add new event


When...TIME (select time when you want light to turn OFF) set pin...(V10) to 0

Now the Heat control

Add new event


When Temperature V8 is lower than 30 set pin...(V11) to 1

Add new event


When Temperature V8 is higher or equal than 30 set pin...(V11) to 0

When you are done, close the Eventor and hit the play button on you project.

I hope you get the idea. If you start playing with Eventor you will discover more possibilities and
options. In the current setup, the Light and Heat is automated and Heat2 and Fan manually
controlled, but all four features can be controlled simply via pushing the button and it will
override your current settings until the next condition is met.

 Add Tip V Ask Question | Comment Download

Step 4: The Code /


(https://cdn instructables
auto=webp&frame=1&fit=bounds&md=1509337810)
com/ORIG/FAX/HM0G/J98RLGCG/FAXHM0GJ98RLGCG png?

Connect your board to the computer re up the Arduino IDE, open the source code and let's
have a quick look at it...

Libraries

You need to download three libraries to get the code working:

ESP8266WiFi.h
DHT.h
BlynkSimpleEsp8266.h (from the Blynk library)

Settings (change to your own needs)

const char ssid[] = "YOUR WIFI SSID";


const char pass[] = "YOUR WIFI PASSWORD";
char auth[] = "YOUR BLYNK PROJECT TOKEN"; (you will receive this in the e-mail after creating a
project in the Blynk app)

That's it! You can upload the code and check on you phone that it is connected.

For full disclosure I'm still using the opposite states for relay 3 & 4 (Heat2 & Fan) from the rst
version (https://www.instructables.com/id/TerraControl-V10-With-NodeMCU-Webserver/). See
the picture. Heat has states HIGH when the Blynk button is ON, LOW when OFF. The Heat2 has
the opposite states.

TerraControl_v3.0_INS…
Download (https://cdn.instructables.com/ORIG/FJ7/T8JM/J98RLFV8/FJ7T8JMJ98RLFV8.ino)
(https://cdn.instructables.com/ORIG/FJ7/T8JM/J98RLFV8/FJ7T8JMJ98RLFV8.ino)

 Add Tip V Ask Question | Comment Download

/
Step 5: Working...? Great!

(https://cdn
auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=1509338414)
instructables com/ORIG/F0V/TWIK/J98RLGXZ/F0VTWIKJ98RLGXZ jpg? (https://cdn auto=webp&frame=1&height=1024&fit=bounds&md=1509330014)
instructables com/ORIG/FKK/5OXW/J98RL9PW/FKK5OXWJ98RL9PW png?

You might come up with even better solution of using the Eventor. To clarify the use of LED
widgets: When you press a button or the Eventor sends a switch event, the code will at rst
switch the relay to the desired state and then re a virtualWrite to turn the corresponding LED
ON/OFF. This way you always know whether or not was your action successful (might be cause
of connection issues but it did not happened while I was using this app for the last two months).

History graph is not necessary but a nice feature to have, it is using the same data we are
sending to the Labeled values and stores them on Blynk server. You can have much more data
available to you with the export option, which was not possible with the previous version.

This setup is universal. I believe I managed to clear up the code as much as it was possible with
the same functionalities and more. You can use it to control your terrarium, aquarium, garden,
aqua-phonic systems, incubators, etc. Just have fun and if you like this project, leave a
comment. I'm sorry if I skipped some setup or something is not clear enough. In that case, send
me a PM and I will x it asap. Thank you for reading!

 Add Tip V Ask Question | Comment Download

advertisement

advertisement
/
Participated in the
Wireless Contest (/contest/wireless2017/)

View Contest

1 Person Made This Project!

/
robert.stark.73 (/member/robert.stark.73/) made it!

Did you make this project? Share it with us!

I Made It!

Recommendations

(/id/Build-a-Pocket-RGB-LED-Light-for-Your-
Home-Photo-S/)

Build a Pocket RGB LED Light for Your


Home Photo Studio (/id/Build-a-Pocket-
RGB-LED-Light-for-Your-Home-Photo-S/)

 8
3 469

(/contest/puzzles2020/) (/contest/handsfree/)

 Add Tip

V Ask Question

/
| Post Comment

We have a be nice policy.


Please be positive and constructive.

Add Images Post

11 Discussions

(/member/hargard/) hargard (/member/hargard/) 1 year ago


Reply / Upvote
Just a Brill project.
Have got the project working OK :)
But I am going to play with the Blynk editor a little to adjust to what I want .
Thank YOU.
1 reply F

(/member/xirixx/) xirixx (/member/xirixx/) 1 year ago


Reply / Upvote
I have tried this project with blynk free, adding only v8 a v9 labels and at the the sensor work intermittently,
and show levels like 3300 % humidity and 9800 ºC. I will not buy credit for the aplicacation till know than It
will work correctly, so can you tell me if this it´s normal with blynk free? The dht22 work correctly and show
correct values with other scripts. Thank you in advance.

(https://cdn.instructables.com/ORIG/FXO/ZX3H/JTYNDW7L/FXOZX3HJTYNDW7L.jpg?
(https://cdn.instructables.com/ORIG/F7U/M8HW/JTYNDW7S/F7UM8HWJTYNDW7S.jpg?
fit=bounds&height=1024) fit=bounds&height=1024)

/
(https://cdn.instructables.com/ORIG/FWO/0OOI/JTYNDW7W/FWO0OOIJTYNDW7W.jpg?
(https://cdn.instructables.com/ORIG/FWO/0OOI/JTYNDW7W/FWO0OOIJTYNDW7W.jpg?

fit=bounds&height=1024)

1 reply F

(/member/kaju666/) kaju666 (/member/kaju666/) 1 year ago


Reply / Upvote
You should add wifi manager to your script. Its easy and really helpful becouse you can type wifi name and
password and blynk token from your phone :)

PS: Ok i looked into the code and in my option is useless to use with live animal. The problem is that all the
computing is on blynk side, so when the heater is on and we lost internet connection in house we can cook
our snake or other animal :(

1 reply F

(/member/Sajovicd/) Sajovicd (/member/Sajovicd/) 2 years ago


Reply / Upvote
Hello, greta project!
Can you help me.?
I am building terrarium for chameleon and I will use reading for temperature and humiditiy, timer for light,
timer for misting pump. I would like to add also a sensor for tank water level. So if there is not enough water,
pump will not start and it will send me notification about water level.
The question is what level sensor to use ,how to connected and how to build a blynk project...
I would be realy happy for any help.
Thanks.
2 replies F

(/member/Javierc182/) Javierc182 (/member/Javierc182/) 2 years ago


Reply / Upvote
Is it possible that during the day it turns on to catch a temperature and at night another?
1 reply F

Post Comment

advertisement

advertisement

/
Categories About Us Resources
 Circuits  Living Who We Are Sitemap (/sitemap/)
(/circuits/) (/living/) (/about/) Help (/id/how-to-
 Workshop  Outside Why Publish? write-a-great-
(/workshop/) (/outside/) (/create/) instructable/)
 Craft  Teachers Jobs (/jobs/) Contact (/contact/)
(/craft/) (/teachers/)

 Cooking
(/cooking/)
Find Us

(https://www.instagram.com/instructables/) (https://www.pinterest.com/instructables) (https://www.facebook.com/instructables) (https://www.twitter.com/instructables)

© 2020 Autodesk, Inc. Terms of Service (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721)


Privacy Statement (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079)
Privacy settings
Legal Notices & Trademarks (http://usa.autodesk.com/legal-notices-trademarks/)
(http://www.autodesk.com)

You might also like