Project circuit
I will measure the temperature and humidity levels and soil water moisture content and detect if there is rain in the garden. A pump will be driven if the plants require water. The sensors which I am using in the project are
- DHT-11 Temperature and humidity sensor
- Arduino soil and moisture level sensor
- Nodemcu esp8266-12e WiFi module
DHT-11 is a one-wire digital temperature and humidity sensor. It can measure temperature from 0 degrees Celsius to 50 degrees Celsius with a 2% margin of error. It can measure humidity levels between 20 and 80% with a 5% margin of error. It requires 3 to 5 volts for its operation. I have another simple tutorial on interfacing DHT-11 with the nodemcu Wi-Fi module. You can learn more from that tutorial. Click the button below to learn more.
Nodemcu works on 3.3 volts TTL logic. Its I/O pins also provide 3.3 volts as output. Relays need typically 5 volts to 12 volts for proper activation of coils. 3.3 volts are not enough to activate the relay coils, alternatively drive the motor/pump. To tackle this, I connected an NPN transistor with a relay and controlled its base with a nodemcu digital pin output. Now, the nodemcu 3.3-volt digital pin can drive a 12-volt relay. When the digital pin is high, the motor starts, and when it is made, it will stop. I also have another tutorial on interfacing relays with Nodemcu and controlling heavy loads. Click the below button to learn more.
Project Circuit
Soil moisture sensor analog output is connected to nodemcu analog channel 0. The digital output of the soil/water/rain sensor is connected with GPIO-16 or D0 pin of nodemcu. The soil moisture sensor is powered with nodemcu 3.3-volt output. DHT-11 temperature and humidity sensor data output is connected to GPIO-0 or D3 of the nodemcu esp-8266-12e WiFi module. A 3.3-volt output of nodemcu also powers DHT-11. Note that there is one void pin out of dht-11. DHT-11 comes in two different pinouts. One has four pins and the other has 3 pins. I used the one with four pins. If you will interface the three-pin sensor, please check the correct pinout before connecting it with the nodemcu. Both the three-leg and four-leg dht-11 sensors work the same, there is no difference in the working method. T used the GPIO-13 or D7 pin of the nodemcu esp8266-12e WiFi module. to control the relay
Note: The transistor’s ground must be grounded with the nodemcu ground and also with the source power supply, Vs. Vs is the external power supply to the transistor to drive the relay. Vs depends on the relay you are using. If it’s a 12-volt relay, then Vs must be a 12-volt power supply.
Connect the ground of the motor or pump with the power supply ground if it’s a DC pump. Connect the anode + lead of power to the relay’s NO(normally open) pin. Connect the com(common) pin of the relay to the motor anode. If the pump is working on alternating 110 or 220 volts, connect one lead of the pump directly to one end of the power rail and NC contact of the relay to another line of rail and comm of the relay to the second lead of the pump.
const char* ssid = “Your SSID”;
const char* password = “Your Wifi Password”;
One thing to take care of: Both the client and server must be on the same network, or in other words, they must be connected to the same WiFi. If they are not on the same network, there will be no communication between the client and server. So please be sure both are on the same network.
The headings and buttons above in the code are due to the HTML code in the Arduino ide. They are visible above because you are viewing them in a browser.
Just make the circuit and upload the code in nodemcu. After uploading the code, enter the Arduino serial monitor from Arduino ide. You will see nodemcu rebooting. They first connect to your WiFi router and then start the server. After the server starts up, it will show a web address. This web address is the address of the web page on which the user can see the smart garden status and weather update. The web address will be something like the one on the right side. To load the status web page, the user must enter this IP in his desktop, laptop, mobile, etc., browser.
|
The web page also contains three buttons. Pressing the update button will update the readings displayed on the page. Two other buttons turn off and on the motor/pump manually. You can turn the motor on and off through the web page.
Filed Under: ESP8266, Microcontroller Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.