TerraControl V3.0 - ESP8266 + BLYNK
Intro: TerraControl V3.0 - ESP8266 + BLYNK
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 finally got new version of TerraControl I'm satisfied 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 fixed 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.
STEP 1: What You Need...
- NodeMCU 1.0 12E board - $3.32
- Relay board - for example - $5.90
- Temperature and humidity sensor DHT22(11) - $2.87
- 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 - $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...
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
- Notification
- Eventor
- History Graph (optional)
- Use the widget settings as seen on the last picture (if you set it up differently 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
STEP 3: Eventor
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.
STEP 4: The Code
Connect your board to the computer fire 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 first version. See the picture. Heat has states HIGH when the Blynk button is ON, LOW when OFF. The Heat2 has the opposite states.
STEP 5: Working...? Great!
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 first switch the relay to the desired state and then fire 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 fix it asap. Thank you for reading!
13 Comments
fendisg 3 years ago
PraetorianCZ 3 years ago
hargard 5 years ago
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.
PraetorianCZ 5 years ago
xirixx 5 years ago
PraetorianCZ 5 years ago
kaju666 6 years ago
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 :(
PraetorianCZ 5 years ago
As for the usage... This suppose that you have optimal elements used in your setup. If you are using heating elements that are constantly being turned on and off and your temperature rising and falling, you might want to use heating element with lower wattage for example. I have been using this setup for 3 years now and I haven't had any problems. But it might also depends on where you live.
Sajovicd 6 years ago
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.
PraetorianCZ 6 years ago
Sajovicd 6 years ago
Hello,
Well if I saw your answer only today, I must say you answer me very fast :)
Well however I did manage to get all working perfectly I combine the code something from your code and something from someody alse and something from someone third... and it finally works fine. If you are interested I can send you new code if you would like to see it.
Thanks and best regards
Damjan
Javierc182 6 years ago
Is it possible that during the day it turns on to catch a temperature and at night another?
PraetorianCZ 6 years ago