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:
3. Power supply shield(Optional, you can power D1 via USB).
9. Dupont cables
10. Running Domoticz server ( I am using Raspberry Pi Zero)
11. Pyhon files. All files you will need are here.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Firmware and Micropython Drivers
I will not delve into how firmware is installed on the device. The procedure is described in details 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 am installing 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 files mentioned above in 11.) except main.py, by using ampy for instance. You will need to edit main.py later, so do not upload it now :).
Step 2: Connections
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
Red ======> +3.3V
Black ======> GND
White (data) ==> D6, also via pull up 4.7kOhm resistor connect to +3.3V
GND ======> GND
VCC ======> +3.3V
OUT ======> D3
Step 3: Add Sensors to Domoticz
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.
Enter idx numbers for every sensor into main.py file. You need it in your Python script to address data from sensors to virtual sensors.
To see the devices list, click on SETUP tab and then select DEVICES.
Also, enter the IP addressof you Domoticz server to main.py file.
Now you can upload main.py to Wemos D1 mini Pro.
Step 4: Result
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.
Mark sensors like "favorite" by clicking the star sign, to see thme all on "Dashboard" tab.
Since the errors handling is implemented in the code, the device will not crash, but only reboot in case of an error.
So now you will know, what i going on in your Greenhouse.
Good luck :)