Mesh Network Soil Moisture Sensor

Solar-charged mesh network soil moisture sensor utilizing the ESP32

Public Chat
Similar projects worth following
This goal of this project is to create a wireless network of soil moisture sensors. Each sensor will be controlled by an ESP32 microcontroller, which measures and transmits the soil moisture across the wireless mesh network. The circuit will be powered by a lithium cell, charged by a small solar cell. A real-time clock (RTC) will also be added to synchronize each sensor to turn on at designated times and transmit their values across the wireless network to a host device.
The sensor will be laid out on a single-board, including the capacitive soil probe. Sensitive electrical components will be covered with a conformal coating to increase water resistance. An enclosure will be developed for the top of the board to further protect the components, hold the battery, and to mount the solar panel. A separate daughter board will also be designed to flash the board through USB.


  • Utilizes an ESP32 as the microcontroller
    • Code will be written in C using Espressif's ESP-IDF
  • Sensor transmits data over ESP-Mesh network
  • Board will be programmable with a daughter board and micro USB cable
  • Soil moisture will be calculated by measuring the soil’s dielectric permittivity instead of resistivity
    • Will use capacitive touch sensor on ESP32 to measure the changes in permittivity
  • Circuit powered by a small rechargeable battery recharged by a solar cell and managed by a solar charger component
    • Planning on using the BQ24210 Solar Battery Charger
  • A real-time clock (RTC) chip with alarm function will be used to wake ESP32 to transmit data
    • Planning on using the DS3231 RTC
      • Can use RTC's thermometer to measure environment's approximate temperature

Testing Plan

  • Initially prototype and breadboard with ESP32-DevKitC
    • Test ESP32’s capacitive touch sensors ability to detect soil moisture
    • Interface ESP32 with RTC chip over I2C and test sleep and wake functionality
  • Ensure that final device can measure and send data over a wireless connection
  • Measure final device’s current consumption when device is both awake and asleep to calculate sensor’s battery lifetime
    • Use data to pick optimal battery size and possible time intervals to measure and transmit data


Second presentation - Design details, prototyping, board design, and initial test results

presentation - 5.03 MB - 12/04/2018 at 23:25



Initial presentation - Abstract, specifications, testing plan, and preliminary prototyping

presentation - 2.33 MB - 12/04/2018 at 23:25



Bill of materials for both boards

sheet - 11.10 kB - 12/04/2018 at 03:47



Soil probe Multisim schematic

ms14 - 376.79 kB - 12/04/2018 at 03:47



Programmer board Multisim schematic

ms14 - 255.11 kB - 12/04/2018 at 03:47


View all 9 files

  • Successful Initial Testing!

    Colin McAllister12/11/2018 at 20:32 0 comments

    After many hours I can proudly say that I have a functional prototype!   Several days were spent getting all of the components on the board working properly and working towards the point where the soil probe board is programmable.

    Thankfully not many issues were encountered getting the programmer board working.  The first board I populated did have an issue with a defective transistor for the ESP32's autoprogrammer.  The two transistors on the board toggled the enable and io0 pins on the ESP32, triggering the ESP32 to enter bootloader mode.  The defective transistor was not pulling the io0 pin all the way down.  This issue was found by trying to use the programmer board to program the ESP32 DevkitC I had.  This allowed me to test the programmer without having the soil probe board acting as a random variable.  The transistor issue was diagnosed with an oscilloscope.  When I tried to remove the defective transistor, I accidentally ripped off one of its pads, ruining the board.  Thankfully I had a couple extra boards and was able to populate a second board that worked properly.

    The next issue I found was I made the classic mistake of not swapping the Tx and Rx pins between the programmer and soil probe, connecting Tx to Tx and Rx to Rx.  To solve this mistake I made a wire bus and crossed the two wires.  I will plan to permanently fix this issue in the next soil probe revision.

    The most frustrating problems I encountered were on the soil probe board.  The first problem came from an improperly soldered switch mode power supply (SMPS).  After populating the soil probe, I noticed from the test points that the battery management controller was working properly, but its output voltage was not regulated by the SMPS.  Using my multimeter to check for continuity issues or solder bridges, I found that two pins were not properly seated and connected to one side of the inductor.  Using a hot air rework station, I was able to properly re-seat the component.  Probing the board again showed that the correct voltage was now being output from the SMPS.

    Excited as I thought this would be the only issue, I was disappointed to find that my board was still not able to program.  Another setback was encountered when I improperly connected the soil probe to the programmer, reversing the polarity and frying the battery management controller.  After swapping out the battery management controller with a new component, I was still having issues.

    I checked that both the enable and io0 pins were toggling properly, the TX and RX pins were correctly connected between the USB to UART chip and the ESP32, and any other possible issues.

    The final issue was found after watching the incoming serial debug messages coming from the ESP32.  I saw that the device was able to enter some type of bootloader mode, but was unable to be programmed by the ESP-IDF.  After reading the documentation online, I found my mistake.  When designing the board, I allocated io2 on the ESP32 as the pin to receive interrupts from the real-time clock (RTC).  The RTC's interrupt pin is configured to act as a drain, and I used a pull-up resistor with the pin.  The problem I found in the documentation stated that io2 must be held low to enter serial programming mode.  Testing if this was my issue, I soldered a wire to connect io2 to ground.  Sure enough, the board programmed correctly!

    This goes to show that you should always read all the documentation and be careful with your pin assignments!

    Will give another update soon documenting how well the board works once the final code is programmed on the board.

  • Boards arrived!

    Colin McAllister12/04/2018 at 04:12 0 comments

    The prototype boards arrived today and they look beautiful!

    The components should arrive from Digikey tomorrow so one of the boards should be populated soon!  I'm a little nervous about making sure I solder all the smaller packages correctly, especially the TPS63021 SMPS (Can be found to the right of the QFN footprint on the front of the soil probe.

    If board population goes well I expect to have a demo working on the board by next week.  Coincidentally, I'll also be presenting it in my final class session next week.

  • Boards submitted for fabrication

    Colin McAllister12/04/2018 at 03:35 0 comments

    On November 23rd the finalized board design for the soil moisture probe and the programmer daughter board was sent to OSHPark for fabrication.  There were actually a couple changes made to the probe board since the last post, but the overall design did not change.

    The pair of pull-up resistors for the i2c bus connecting the ESP32 to the external RTC were removed since the ESP32 features internal pull-up resistors.  Debugging the code for the RTC revealed that I made a mistake with the interrupt pin from the RTC.  I either forgot or didn't realize that the interrupt pin on the RTC is an open-drain pin, so I added a pull-up resistor.  Why not use the ESP32's internal pull-up resistor for the interrupt pin as well?  The interrupt pin will be used when the ESP32 is in deep sleep mode, so the device will be effectively powered off, so I'm not sure that the pin configuration will be persistent.

    I also tried my best to reduce the number of decoupling capacitors.  Lastly, I needed to add a huge 4700 uF capacitor to the circuit.  I realized the need for it by looking further into Adafruit's design for the USB/Solar charger.  Talking with an EE friend of mine, we figured the large cap is needed to smooth the voltage from the solar cell and acts as a "poor man's" maximum power point tracker.  Forward annotating the new capacitor to the board design was a challenge due to low space, but I was thankfully able to find a spot for it on the back of the board.

    The Ultiboard and Multisim design files are now uploaded to the project site along with the gerber files.  I also uploaded the bill of materials.

  • Completed prototype schematics

    Colin McAllister11/07/2018 at 21:15 0 comments

    This week I was able to finish the two board designs for the initial prototype.  As I said in the previous log, I want to design a daughter board that is able to create a serial interface between the soil probe and a computer.  This will allow the soil probe to initially charge the battery and also be programmed.

    Programmer Board

    The daughter programming board was pretty simple to build.  The design incorporates a similar design to the USB to Serial circuit used on the ESP32 DevKitC and Adafruit HUZZAH32.  I really like the design's ability to auto program the ESP32 by toggling the EN and IO0 pins.  I wanted to use this feature to avoid having to place reset & bootloader buttons on the soil probe.  The programmer is powered by the 5 volts supplied by the USB port and regulated with a fixed 3.3v linear regulator.  The USB bus is also protected with a schottky diode and ESD protection devices.  I also added a small surface mount LED to indicate when the device is powered on.

    Laying out the components was not too difficult either.  I did challenge myself to try and place components on both sides of the board and felt like I saved a little bit of space in the process.  The programmer and probe will be connected with a standard 8-pin header.  For the final design I hope to only have exposed pads which will rest on a bed of nails.

    Soil probe

    The soil probe was a much more complicated design compared to the programmer board.  The number of components was much larger, and featured an odd component that was hard to make a footprint for in Ultiboard.

    The most difficult part of the design was the circuitry that will manage the battery and power the ESP32.  I was inspired by Adafruit's battery management board.  I decided to also use the MCP73871 lithium battery charger.  Since this device will be on its own, I figured it would be best to actually use a thermistor to monitor the battery's temperature.  To simplify the circuitry, I added no protection for the solar panel if the device is powered by USB, but figured this was not necessary anyways because the solar panel will be added after programming.

    Based off my understanding the output for the load from the MCP73871 is not regulated, so I decided to use a buck-boost regulator to ensure the output for the ESP32 is regulated to 3.3 volts.  I used Texas Instruments' WEBENCH tool to get a design for the buck-boost circuit.  The last element of the power circuit is the LM3724, which is a microprocessor reset circuit.  This component watches the battery's voltage and will ensure that the ESP32 does not power on if the voltage drops below 2.5 volts.

    The last important part of the circuit is the DS3231 real-time clock, which will preserve the current time and also wake the ESP32 at certain time intervals.  This will allow a network of probes to power on at the same exact time to create the mesh network that the sensor data will be transmitted over.

    Laying out the above circuit was definitely challenging.  I tried my best to minimize the size of the board and am happy with the final size.  Components were mostly placed on the front of the board, with the exception being the backup battery for the real time clock.  I would like the final board to have an empty back so the lithium battery can be affixed to the back.  I included two images of the board to show the traces along with an image of the planes.  The image with the planes clearly shows the capacitive probe that will measure the soil moisture.

    I also added some test points to ensure that the SMPS and battery charger are working correctly.

    Once the boards are ordered I will upload the gerber files.  If you would like to see the Multisim or Ultiboard files please contact...

    Read more »

  • Code repo is up!

    Colin McAllister10/24/2018 at 18:00 0 comments

    Besides working on the schematic for the prototype, I have also been working on writing the software for the ESP32.  The repository is linked on the project page, but I'll include it here as well.

    Working with the ESP-IDF so far has been fantastic.  The documentation is great and I have had no trouble working with the NVS, Sleep, and GPIO library.  I have saved the best for last and will eventually start working with the Mesh library to set up the wireless networking.

    Another note to add to the log is how I have decided to move forward with flashing the boards.  I decided that I wanted to leave the router information out of what's compiled and flashed.  In addition the device ID could be given at run time as well.  Lastly, I would like to give the time to the device at runtime so the ESP32 can program the RTC over I2C.  My plan is to flash the board using Espressif's build system, then when the device boots for the first time it will wait for a UART package to be received with all the needed data.  I'll probably write a python script that starts the flash and then reads the runtime data from a config file before packaging and sending over UART.

    In order to save money on parts and also decrease board size, I thought it would be cool to create a daughter board with the USB to UART bridge (CP2102).  This way I can route EN and IO0 to the daughter board to use the auto program feature.  Initially I'll connect the daughter board via a multi-pin header, but for a final prototype I would like to create a mount for the main board to sit on a bed of nails for easy programming.

  • Testing the feasibility of an ESP32 capacitive soil meter

    Colin McAllister10/22/2018 at 15:28 0 comments

    The most critical component of this project is the capacitive sensor that detects the permittivity of the surrounding soil to calculate the moisture content.

    After doing some research online I found this study that showed promising results by using a capacitive touch sensor to detect soil moisture content.  After already deciding that I would be using an ESP32 as the MCU for the project, I knew that the chip had several I/O pins that could be routed to capacitive touch pads.

    To see if the ESP32's touch pins could be used, I created a crude capacitive probe by mounting two copper plates to each side of a wooden stake.  Each plate was isolated from the steak and soil by wrapping the stake and the plates in electrical tape.  Wires were also placed in the tape to connect the two plates to the ESP32-DevKitC.  One plate was connected to ground while the other was connected to the pin that is Touch0.  I then compiled and ran the Touch Pad Read Example from Espressif on the dev kit.

    The results from running the program look promising.  Touch0's value definitely had a significant change when placing the probe into a container of damp soil.  The next step will be making a container of dry soil to compare the results to.  Once I have data from both containers I will make a follow up post and upload the values.

View all 6 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates