Greenhouse automation. Step 1: sensors.




Hey. I want to present one more project of mine to the wide society.

The project aims to automate the greenhouse I have built in my backyard. This is the first step- creation of a complex of sensors for the greenhouse. Later in the future, based on data from sensors, I plan to automate irrigation and ventilation.

The device is based on Wemos D1 mini Pro. Software for this project is written in MicroPython. Data from sensors flows to Domoticz server running on Raspberry Pi Zero.


Now let‘s go deeper into details.


For this project you need:


1. Wemos D1 mini Pro


2. Wemos tripple base


 3. Power supply shield (Optional, you can power D1 via USB).


4. OLED display


5. DHT22 sensor


 6.  SOIL sensor


 7. 18b20 temperature sensor


    8. Housing


    9. Dupont cables


    10. Running Domoticz server

  

    11. Pyhon files. All files you will need are here.


I will not delve into how firmware is installed on the device. The procedure is described in one of my previous posts here.

Although there is one thing you have to know about installing firmware on WemosD1 mini Pro.

Normally when I install firmware I use the following command:


python esptool.exe --port COM5 --baud 460800 write_flash --flash_size=detect 0 C:\path_to_firmware\


But it doesn't work with D1 mini Pro version. It works with D1 mini, but not with Pro.

After installing firmware in this way, D1 goes into infinite loop – it reboots constantly.

Somewhere on the internet I found that it is necessary to describe flash memory size it will use.

You have to use command below:


      python esptool.exe -p COM8 write_flash -fs 4MB 0 C:\path_to_firmware\


So after you have installed firmware, upload all files mentioned above in 11.)  by using ampy for instance. Do not forget to make changes in main.py file: put there idx numbers of your sensors, IP address of your Domoticz server.


Connect all hardware.


1. Soil sensor:

     Red wire ======> +3.3V

     Black      ======> GND

     Yellow (data) ===> A0


2. OLED display:

     GND     ======> GND

     VCC     ======> +5V

     SCL      ======> D1

     SDA     ======> D2


3. ds18x20:

     Red       ======> +3.3V

     Black    ======> GND

     White (data)  ==> D6, also via pull up 4.7kOhm resistor connect to +3.3V


4. DHT22:

    GND     ======> GND

    VCC     ======> +3.3V

    OUT     ======> D3


Some pictures showing how everything looks like inside :)








DHT22 sensor is mounted inside.


Add sensors to your Domoticz server.


1. Select SETUP/HARDWARE to add hardware.


2. Add "Dummy" from drop-down menu.

  When hardware is added, the overview of all defined hardware will be shown.


The new hardware should be in the list and there should be a button "Create Virtual Sensors".

Click this button. Choose type of the sensor you have created.

Please note IDX number of your sensor. You will need it in your Python script to address data from sensors to virtual sensors.

Do the same for all sensors.

To see the devices list, click on SETUP tab and then select DEVICES.


Power on the device.


After ESP starts, find a new WiFi network called "Wifimanager". Connect to it with your PC or phone by using password: "tayfunulu", then go to IP address 192.168.4.1.. Here you can connect your ESP to local WiFi network. Choose WiFi network you are going to use, type in password, hit "Submit".


If everything is correct, you will see message " ESP successfully  connected to XXXX network". 


Your ESP now is  connected to your WiFi network and ready. As soon as it connected to WiFi it will connect to Domoticz server and start to send data from sensors.

You can track the process in "Setup"/"Log".

Display newly created sensors by clicking "Temperature" tab.

The sensor image will be shown.


Soil sensor will be shown under "Utility" tab.



If you will mark sensors like "favorite" by clicking star, all of them will be displayed on "Dashboard" tab.


Results





Soil and DS18B20 sensors


At the moment the device has been working for a week. As I see, from time to time an error occurs. I am not sure what causes the error: is it because of the weak wifi signal, or ds18b20 sensor. Need some time to investigate. In case of an error the device just reboots, and goes on again. 

So generally it works. I can access my Domoticz server via web browser from the local network to see data from sensors, and I hope I will be able to set remote access from outside of my private network.

On the next stage I am planning to automate irrigation in my Greenhouse, and later on also to automate ventilation.



If this project was interesting for you, you could buy me a cofee :)