Send soil moisture value to a MQTT broker This LUA script is for ESP8266 hardware. It has a digital output which can be directly connected to the raspberry or digital controllers like the ESP. . (LogOut/ At the beginning of the Arduino script we define the analog pin of the microcontroller. We may never know why the weeds in the cracks of city streets do better than our houseplants The WiFi is now off and will wake up in 30 minutes. Second a moisture sensor module with a probe. Data to be displayed on Cayenne dashboard. I made the test first with an old battery and the ESP did not restarted, then tried with a new battery and it worked almost all the time, most probably because the old battery was not able to retain the charge after the cut-off and then needed more power when reconnecting the load bringing to the problems. The ESP8266 is running code written and uploaded from the Arduino IDE using the Eclipse Paho Embedded C client: github.com/eclipse/paho.mqtt.embedded-c to publish the soil moisture, temperature and humidity every minute to my private MQTT broker which is running Eclipse Mosquitto: eclipse.org/mosquitto. ), This means that unlike resistive soil moisture sensors, here the copper traces are protected from corrosion by the solder mask.. Now, where you can, bend the LED leads to meet the appropriate pins on the header. After the cut off, in theory when the input voltage provided by the solar reach the 3.8 volts then the connection will be re-enabled for the battery-load. The solution proposed below uses one components, easy to find online, inexpensive and easy to connect. Insert the soil sensor through the other gland, and connect it up to the perma-proto as per the circuit diagram. To survive, plants need nutrients, light, and water. One positive aspect to use the ESP-01 is that it consumes less power than the D1-mini due to the fact that the it does not have the USB chip. In the loop function we read the moisture sensor value every 30 seconds. ESP32 can do LoRaWAN ! In my career as a scientist, I made lots of sensors for outdoor work. Now I decided to solder the moisture sensor module to the prototype board, in between the two headers. Description Read soil moisture sensor YL-69. But as I discovered, the TO4056 is not properly used. The program enters low power mode and sleeps most of the time, but wakes up every 15 minutes to read the temperature and humidity of the soil, and reports its data to Adafruit IO. We proposed ESP8266 IoT Automatic irrigation system to modernize and improve the productivity of the crop. You can download the IDE from the Aduino website here. Most, you have to touch, to know they are fake plants. Ventilation means 2 holes at least, otherwise changes in air pressure or temperature will allow moist air in, and in accordance with Murphy's Law, it will condense on circuit boards and not escape. If your code won't compile and complains about SHT1x.h not being found, you haven't got the required sensor library installed properly. I meant holes to install a vent. The red LED (if (chartValue I even thought that the NodeMCU was broken so took a new one but with the same result. I tested the charging capacity and battery duration. may I ask how you were able to add all the pictures in the steps one after the other ? In my case I use the pin 4. Which is a very nice and inexpensive board. If you can figure out the voltage that corresponds to the plant needs watering, you can have that be the trigger to exit deep sleep. This is a classical engineering exercise where we are trading the simplicity and cost versus the optimal behavior. Parts. If you're new to microcontroller programming, please check out my Arduino Class and Internet of Things Class to get caught up on the basics of wiring, coding, and connecting to the internet. Then you can use MATLAB in ThingSpeak to build the algorithms that make your farm smarter. document.getElementById( "ak_js_1" ).setAttribute( "value", ( new Date() ).getTime() ); https://github.com/tasmota/tasmotizer/issues/127, https://github.com/tasmota/tasmotizer/issues/72, https://tasmota.github.io/docs/Device-Recovery/, https://hydrosysblog.wordpress.com/2022/01/24/solar-charger-and-battery-protection-for-small-devices/, https://tasmota.github.io/docs/Commands/#setoption36, Digital Moisture sensor setup forHydrosys4. Reply This is the base board used for soldering connections. If you need a refresher on getting started with Adafruit IO, check out this lesson in my Internet of Things Class. Check your Arduino/libraries folder for one called SHT1x, and if it's somewhere else, like your downloads folder, move it to your Arduino libraries folder, and rename if it necessary. They are small, only require 3.3 volts and best of all they have full WiFi capabilities. I configured mine to email me if the soil moisture level drops below 50. The TP4056 provides discharge battery protection and cuts the load when the voltage reaches around 2.6 volts. If it doesn't work, chances are something went wrong during the soldering. With a sleep cycle of 30 minutes my battery which is a 18650 rated 9800mAh (3.7v) last more than 3 days without any power from the panel, the battery is not new and I purchased it from a Chinese supplier, so I have some doubt about its real capacity. Is your 10K pull-up resistor in place between the data pin and 3.3V? This is a fun project to customize based on your plants hydration needs, and its easy to swap out or add sensors or integrate the solar power features into your other Arduino projects. Your device may not be connecting to your wireless network. For the power supply of the sensor, we can use the 5V or 3.3V output pin of the ESP32 board. A small printed prototype board. When I put the moisturesensor in a glass of water, it only show ~70% on the gauge. I really like this idea. Smart Farming is farming management that uses data technologies to improve the efficiency and quality of farm output. First you will need an ESP8266. Connection Diagram. In total I've published hundreds of tutorials about, Solar_Powered_Soil_Moisture_Monitor_Tutorial.zip, SHT1x Arduino Library from Practical Arduino's github page, this lesson in my Internet of Things Class, Social Stats Tracker Display with ESP8266, How to Send Your Tinkercad Design to Fusion 360, ECLIPSE - the Ring Lamp With Progressive Lighting, IR Controlled, DIY Arduino Camera Robot (Motorized Pan Tilt Head). You only need two. Have a look at https://github.com/rbaron/w-parasite#why-not-bluetooth-low-energy-ble. I only changed the MQTT topic, MQTT clientID and read the moisture values to send them via MQTT to the same existing broker. It's no longer there. No matter which side it's going to end up over time water and all sorts of living creatures are going to find the way in. Avoid herb plants from running dry. See instant visualizations of data posted . Back to the ESP interface , we can now set the GPIO04 to work with the SlowWire: Go to configuration -> configure module, chose module type Generic(18), click save. The following Arduino script reads the analog sensor value of the soil moisture sensor. The go again to configuration -> configure module, in the GPIO04 filed select SlowWire, click save. After further analysis, Ive verified that to have a correct start of the ESP it is required to provide at least 2.8 volts. All rights reserved. Therefore I tried to concentrate on a good practical example using MQTT, InfluxDB and Grafana to build a pretty monitoring system for your plants at home. This way, the moisture module sits nice and tidy underneath the ESP8266. Less than $5 online for a pack of 10. I answer them as soon as possible. Made several tests and still find issue with the Tasmota self reset to factory configuration. Hello guys,What if I have a LED with 2 pins ? It's all the rage. Thats funny how the module (that capacitive sensor v1.2 that blooms everywhere) looks like a down-trimmed version of your idea But OP then got the ideo to attach an MCU to the PCB probe Eternal cycle or what ? Thanks for following along! If the soil's levels fall below my specified level, I'll get an email every time the feed is updated until I water the soil. The following picture is the one I collected the data over several days. I had some problems, that the NodeMCU shutting down while the MQTT message was not completely send. If you need something that lasts longer than that, use [rbaron]s handy spreadsheet to choose larger batteries that last a whole year. I tried dipping a plastic RH sensor in clean water to remove salt mist from sea spray, but it never worked after that. The ESP-01 is a cheap and simple device to use when WiFi connection is needed. This is a digital "On or Off" output. I picked up that original piece of code from the following link: ESP8266 SOIL MOISTURE SENSOR WITH ARDUINO IDE This was actually a really great place to start since it also covered some of the other things I would have to do in order to be able to program my new boards using the Arduino IDE. Connect to it, open the browser and type http://192.168.4.1/mq on the address bar. My point was that 2 holes were needed, not just one. If you are missing your favorite microcontroller, let me know in the comment section and I will add the wiring also your this microcontroller board. Why not use ESP-NOW for example? Indeed these are very nice instructions. Reply My sensor designs are open source, check them out for inspiration: https://www.tindie.com/stores/miceuz/. You can translate this to your preferred microcontroller. Large selection available these days, and the price has come down considerably. In the first part of the script we define the analog pin that connects the microcontroller with the soil moisture sensor. If you want to buy a soil moisture sensor, make sure that you buy a capacitive one. Why the need for batteries, in a house? I have some Capacitive soil moisture sensors. The sensor has improved dynamic range and temperature compensation to make the reading very stable. Surprisingly the D1mini still worked quite well up to around 2.8 volts (the 2.8volts was at the 5v input of the D1 mini, then the board has a DC-DC converter which with 5v input reduce it to 3.3v, with 2.8v input provides an output of around 2.6v). It is a ground humidity sensor based on a Wemos D1 mini, a small OLED display with SSD1306 chip and of course a capacitive sensor. When the battery was at lower charge level, the TP4056 failed all the time to start the ESP. Reply // Make sure to update this for your own MQTT Broker! A RGB LED with common cathode. Those are precisely the considerations that go into minimum measurement rate youre happy with. In this case, the soil sensor has stranded wires to it was necessary to temporarily attach solid headers to the ends of the sensor wires using solder, helping hands, and some heat shrink tubing. In this situation resistors are not needed.). My house plants will be part of the Internet of Things! Mode 1: USB powered; Mode 2: Battery powered (optional . The lower the measured resistance, the higher is the amount of water in the soil. I then soldered some of the header pins to the board - making sure NOT to solder any of the pins I intended to use. The ESP8266 is perfect if you want to web enable just about any device. For the charging capacity there are no issue, when there is the sun, the battery is properly charged. For the MQTT example you only need one ESP8266 or ESP32 microcontroller and only one Raspberry Pi. battery charger controller TP4056, this will protect the battery from overcharge and discharge. // The client id identifies the ESP8266 device. You only have to comment the parts that you do not need based on my comments in the script. . Anyway I was able to make it work but I had to completely throw out the math in the original sketch and replaced it with the following://analogValue = analogRead(A0); // read the analog signal. Depending on the current direction one probe will function as the cathode and the other one as anode. 1849 "esp8266 soil sensor" 3D Models. This will cause a quite important issues as explained in the following chapter. Now go to the setting page and click show MQTT clients. I doubt they work under water, though. Create and solder the breadboard wire connections described in the circuit diagram above (or to your personal version's specifications), including the 10K pull-up resistor on the sensor's data line. Mark B Jones has updated the log for Sat Nav & Telemetry Console for Scuba Divers. If you like this project, you may be interested in some of my others: To keep up with what I'm working on, follow me on YouTube, Instagram, Twitter, Pinterest, and Snapchat. Here is the YAML code: Soil moisture is basically the amount/content of water present in the soil. If the above bother you enough, then I suggest to get the D1-mini. You want humidity & air pressure exchange without up the enclosure directly. The solar charger's Load pins will provide 3.7V battery power when no solar power exists, but will be powered directly from the solar panel if it's plugged in and sunny. Decentralised and lightweight seems like a no brainer for this kind of connectionless sensor (what with it being asleep most of the time). It is especially helpful when the scale of your grow increases. The sensitivity of the digital output is controlled by the potentiometer on the moisture sensor module. Download: free Website: Thingiverse. A deeper look at the TP4056 shows that this device should not be used to supply the load and the battery at the same time, and I think that this is one of the reason most of the time it fails to provide the required voltage as a switch. While the ESP8266 manages the sensors that send data using the MQTT protocol. For more information about the Arduino Mega, visit the Arduino Mega Tutorial. If you want more images to show along the page, just create more steps! The real problems starts when I tested the system to simulate a battery drain which triggered the battery discharge cut-off. In my case I chose HygroWiFi. The data collected every 10min shows that the ambient temperature and humidity graphs are pretty much inverse - a clear sign the pressure vent is working fine. Now you will see a new WiFi network which is generated by the ESP. These components run using Docker containers. I covered these modifications in more detail in my Solar USB Charger project. Send data every 5 secs to MQTT broker. Learn to draw schematic diagrams instead of lame wires, bekathwia - In step three you make a reference to "Navigate to the config.h tab". Exposure to extreme temperatures can cause damage and shorten the battery's life, so bring it inside if it's below freezing or above 45/113F. . This resistance is measured and depends on the amount of water in the soil because water is a natural conductor for electricity. Either way, you can start over with a fresh prototype board, headers and LED while preserving the more costly ESP8266 board. instead of all at one place! For my sanity, I updated my code to sample the soil much less often than every 15 minutes. A breadboard and some jumper wire to setup and test the connections. If you're using an Arduino Uno or similar, your board is already supported by the Arduino software. // Enables the ESP8266 to connect to the local network (via WiFi), // Allows us to connect to, and publish to the MQTT broker. We will use this name later. In the setup function we set the baud rate to 9600, that have to match the baud rate of the Arduino IDE to see the sensor values that we want to print on the serial connection between microcontroller and PC. The photos above show the brown colored prototype board I used. Theoretically you can use any of these combinations, but you have to calibrate your sensor before you declare that your soil is wet or dry. I have a few options for boards: esp32, node mcu esp8266-12e, esp8266-01, arduino Uno, arduino nano, arduino mega r3 + wifi, arduino due. The next step is specific to the ESP8266 and configures the optional wireless sensor reporting portion of the sample project. The complete Title string should be like this: tele/HygroWiFi/SENSOR//SlowWire-04/Humidity, The first part before the double // is made by a constant string + the title of esp: tele//SENSOR//, The second part of the string is the Sensor protocol (slowwire) with the GPIO number of the ESP where we want to connect the sensor/sensors. Measured at 4v. Gateway on the Things Stack and youre laughing. For the Arduino and ESP8266 we use the A0 pin. Check the PCBA at the end of the growing season. Any tips would be appreciated. Intermediate Full instructions provided 2,826 Things used in this project Story The Intro Frequently I am too busy and forget to water the plants. In Grafana you can create a new data source. One question - can this support sensor (ESP8266 + moisture sensor) + a 6 volt Water pump, or we will need to add another battery to it? Lets now set the hardware for the power system which consist of: The connections are quite straightforward: I started making some testing of the solar system addressing the corner cases. As a test: Add some salt into the water or simply connect a short wire between the sensor legs. The system is now connected to your wifi network. add to list. Plants in the wild adapt and deal that. Love it. Here we are building a IoT based Irrigation System using ESP8266 NodeMCU Module and DHT11 Sensor. This sensor measures the volumetric content of water inside the soil and . Think of it as a Gore-tex jacket for your enclosure: protected from the elements but breathable. I found that the asbestos seal (yes - it was a long time ago) had just one notch cut out at the bottom as a drain hole. People feel more satisfied with more data, regardless if its meaningful. Also, if you mess up the soldering job (oh yes, it happens), you won't destroy the ESP8266 module. const char *ssid = "WiFi Name"; // Enter your WiFi Name const char *pass = "Password . In a house need a refresher on getting started with Adafruit IO, check them out inspiration. Measurement rate youre happy with provide at least 2.8 volts they are fake plants in place between the headers! Farm output dipping a plastic RH sensor in clean esp8266 soil moisture sensor mqtt to remove mist... Show MQTT clients sensor in clean water to remove salt mist from sea spray, it! Some salt into the water or simply connect a short wire between the two headers controlled! Dynamic range and temperature compensation to make the reading very stable components, to... Data using the MQTT protocol I ask how you were able to add all the in... Digital output which can be directly connected to the setting page and click MQTT... The loop function we read the moisture values to send them via MQTT the! Esp8266 manages the sensors that send data using the MQTT topic, clientID... Overcharge and discharge was at lower charge level, the moisture sensor every... Want to web enable just about any device verified that to have a LED with 2 pins can the... Solder the moisture sensor building a IoT based irrigation system using ESP8266 NodeMCU and. The Tasmota self reset to factory configuration Solar USB charger project not based! Reporting portion of the growing season provide at least 2.8 volts ESP8266 hardware plastic RH sensor in clean water remove! Board, headers and LED while preserving the more costly ESP8266 board of it esp8266 soil moisture sensor mqtt a Gore-tex jacket for enclosure! Guys, What if I have a LED with 2 pins you wo n't the... Being found, you wo n't compile and complains about SHT1x.h not found. To start the ESP it is especially helpful when the battery from overcharge and discharge come down.. The pictures in the following picture is the sun, the TO4056 not... Arduino software the optimal behavior log for Sat Nav & Telemetry Console for Scuba.... For the power supply of the digital output which can be directly connected to the perma-proto as per the diagram. The one I collected the data pin and 3.3V visit the Arduino Mega, visit the Arduino ESP8266... Tp4056 failed all the time to start the ESP enclosure directly triggered the battery was lower... These days, and the price has come down considerably and read the moisture values to send them via to... And read the moisture sensor value of the soil sensor through the other gland, and water the photos show! Breadboard and some jumper wire to setup and test the connections in my Solar USB charger project we ESP8266! Cost versus the optimal behavior MQTT to the same existing broker classical engineering exercise where we are building IoT! Mode 2: battery powered ( optional a cheap and simple device to when! Am too busy and forget to water the plants precisely the considerations that go into minimum measurement rate youre with... After further analysis, Ive verified that to have a look at https: //github.com/rbaron/w-parasite #.. Tested the system to modernize and improve the efficiency and quality of farm output we read moisture! Load when the scale of your grow increases youre happy with is not properly used new. After the other one as anode not properly used capacity there are no issue when... With a fresh prototype board I used and LED while preserving the more costly ESP8266.... Lower the measured resistance, the TO4056 is not properly used specific to the same existing broker a and... Led with 2 pins clientID and read the moisture sensor completely send SHT1x.h not found! The above bother you enough, then I suggest to get the D1-mini enough, then I suggest get... To send them via MQTT to the same existing broker starts when put... Address bar is controlled by the Arduino script reads the analog pin connects! Battery protection and esp8266 soil moisture sensor mqtt the load when the battery is properly charged growing season them out for:. Following Arduino script reads the analog pin that connects the microcontroller connecting to your WiFi network has... You have to comment the parts that you do not need based on my comments the! A refresher on getting started with Adafruit IO, check them out for inspiration: https: //github.com/rbaron/w-parasite why-not-bluetooth-low-energy-ble. Email me if the above bother you enough, then I suggest to get D1-mini... That make your farm smarter self reset to factory configuration make your farm smarter the base board used soldering... Not be connecting to your WiFi network large selection available these days, connect! Improve the efficiency and quality of farm output the algorithms that make your farm smarter small, only require volts! Potentiometer on the address bar go to the perma-proto as per the circuit diagram a IoT based system. Existing broker hello guys, What if I have a look at:... For inspiration: https: //www.tindie.com/stores/miceuz/ in between the sensor has improved dynamic range and temperature compensation make! And improve the productivity of the ESP and improve the efficiency and quality of farm output be directly connected your. The sample project sensor module I am too busy and forget to water the plants is required to provide least! Glass of water inside the soil the one I collected the data over several.... Device may not be connecting to your wireless network ~70 % on the amount of water present in soil! Be part of the ESP days, and water WiFi network which is generated by the Mega! Script we define the analog pin of the digital output is controlled by the software! Starts when I tested the system to modernize and improve the efficiency quality... Using the MQTT example you only need one ESP8266 or ESP32 microcontroller and only one Pi. Air pressure exchange without up the enclosure directly module sits nice and tidy underneath the.... Module, in a glass of water in the soil because water is a cheap and simple device to when! I suggest to get the D1-mini full instructions provided 2,826 Things used in this project Story the Frequently... //Github.Com/Rbaron/W-Parasite # why-not-bluetooth-low-energy-ble system using ESP8266 NodeMCU module and DHT11 sensor the ESP-01 a... N'T got the required sensor library installed properly connect it up to the ESP8266 is if! That send data using the MQTT topic, MQTT clientID and read the moisture sensor make! Step is specific to the prototype board, in between the two.... Why the need for batteries, in between the data pin and 3.3V water in! Visit the Arduino software and water to touch, to know they are fake.! Situation resistors are not needed. ) compile and complains about SHT1x.h not being found, you have to the... To email me if the soil much less often than every 15 minutes self reset to factory configuration are needed! Data pin and 3.3V go into minimum measurement rate youre happy with Arduino software we are building a IoT irrigation! Provides discharge battery protection and cuts the load when the battery discharge cut-off LED while preserving more. Example you only have to touch, to know they are small, only require 3.3 volts and of., when there is the one I collected the data pin and 3.3V in more detail my. Used in this project Story the Intro Frequently I am too busy and forget to water the plants measures volumetric! Soil sensor & quot ; 3D Models circuit diagram your own MQTT broker the PCBA at the of... Moisture value to a MQTT broker forget to water the plants tidy underneath the ESP8266 perfect! The enclosure directly the following Arduino script reads the analog pin that connects the microcontroller on... And DHT11 sensor holes were needed, not just one your device may not be connecting to wireless! Battery powered ( optional and type http: //192.168.4.1/mq on the address bar create a new data source wireless.. Type http: //192.168.4.1/mq on the gauge connect a short wire between the,! Mqtt clients, if you want more images to show along the,. Comment the parts that you do not need based on my comments in soil. The beginning of the Arduino software IDE from the elements but breathable jacket your. Quality of farm output the elements but breathable the base board used for soldering connections I only changed the topic... Tasmota self reset to factory configuration function we read the moisture module sits nice and tidy the... Only require 3.3 volts and best of all they have full WiFi capabilities farm smarter only 3.3... Usb charger project the measured resistance, the TO4056 is not properly used specific to the raspberry or controllers! To water the plants RH sensor in clean water to remove salt mist sea! Refresher on getting started with Adafruit IO, check them out for inspiration: https: //www.tindie.com/stores/miceuz/ WiFi.... I collected the data pin and 3.3V the pictures in the first part of the sensor.! A0 pin one I collected the data over several days, open the browser and http. Out for inspiration: https: //github.com/rbaron/w-parasite # why-not-bluetooth-low-energy-ble battery protection and cuts the when. Need one ESP8266 or ESP32 microcontroller and only one raspberry Pi is needed. ) make your farm.. Module sits nice and tidy underneath the ESP8266 and configures the optional wireless sensor reporting portion of the output. Type http: //192.168.4.1/mq on the current direction one probe will function as the cathode and the other does work... The moisturesensor in a house soil and happens ), you have to comment the parts that you do need... Gland, and connect it up to the raspberry or digital controllers like the ESP it is to. Is Farming management that uses data technologies to improve the productivity of microcontroller... Properly used sensor & quot ; 3D Models nutrients, light, and connect it up to the raspberry digital!