TerraControl – with NodeMCU Webserver

I’m working on making the code as user friendly as possible but it’s going to be a long run. I’d like to have separate html and css files but I’m still figuring it out. For now, few changes…:

! ! ! included mDNS protocol, so from now on you don’t need IP address to connect to your NodeMCU, simply put terracontrol.local in your browser and you are done (you have to be on the same network, of course)

separate file for setting up the variables (setting.h). Unzip the file to your Projects folder, when you open the *.ino file, setting.h should be opened as well.

UPDATE 2: Version 1.2

improved graph displaying range

new values in graphs are moved to the end of array, not starting from the beginning again

improved light setting – it is now unlimited (ON time can now be later than OFF time)

code for manual defining your own server is in one place and commented by default (i.e. it is on automatic setting)

clearer information in serial monitor

unified function for min/max values in array

new function for printing out minute values

UPDATE 1: Please see the version 1.1 I got the graphs and statistics working! Well, sort of…the range is still not as I want it to be, but at least now it is correctly displaying min and max. Plus new mouseover feature for the individual values in the graph.

After my first attempt to create controlled terrarium using Arduino board I got my hands on NodeMCU 12E board and I knew it was going to be a big step up!

I took me a few days before I began to understand how this board works (thanks to a lot of instructables here and google of course) and the possibilities it had. It think I’m on the right path to create exactly what I was dreaming about for several years…

So what is TerraControl v1.2 capable of?

2 automatically controlled relays (light timer and heating)

2 manually controlled relays (fan, second heating)

GMT time change

Simple graphs with highest/lowest temperature/humidity over the last 24 hours

i.e. DHT sensor pin goes to D8 (board’s D3, D4, D8 can’t be used as output but can be used as input), and the relay pins accordingly to the code. Remember, if you are using 5V relay, you need to modify the relay board or use I2C logic converter.

! ! ! IMPORTANT! When uploading the code to the board, you have to disconnect the DHT sensor, otherwise you will get an error when attempting to upload ! ! !

All parts can be powered with 5v power adapter

Step 2: Setup and Customization

Before we upload the code, there are few things that needs to be set up in setting.h:

Step 3: Alwas ON/OFF Relay Connection

One thing I wanted was the relay board to be used as little as possible. As you probably know, relays have two possible ways of connection: ON when not used and ON when used. So I connected the light and heating to “ON when not used” (heating is almost always ON and lights are ON for about 13-14 hours every day) and fan and heating 2 to “ON when used” (I barely need to use one of them).

Step 4: Webserver

When you open the webserver you will see simple page with all information about your terrarium and some features:

Light ON/OFF time can be adjusted (step are: 1 hour for hour setting and 5 min for minute setting). At the moment ON time has to be earlier that OFF time (ON 22:30 and OFF 0:30 will not work – yet) – fixed in version 1.2

Temperature setting (steps are 0.5 degree Celsius)

Manualy turn ON/OFF other two relays – Fan and Heat 2 and adjust timezone when the time changes

Step 5: Disclosure

I know that the HTML and CSS code could be much more simple and the coding is not really user friendly but for the moment it works as it is supposed to (only the graphs are not very accurate but I’m still working on them) and I will get to these points when I start working on version number two. I have already decided to use external power supply (in this version I just stripped the 5v adapter and soldered it inside the box) and I also want the power cables to be more accessible and easier to connect/disconnect. I hope you guys (and your pets) will appreciate this instructable, if you do, please leave a short comment. And of course, suggestions are more than welcome! Thank you