In my last post I talked about the irrigation controller I have been working on for my parents farm. The project is still a work in progress due to having problems getting a reliable cell signal out on the farm. I’ll definitely be writing a post soon that gives more detail about where that project currently is at.
While working on the irrigation controller, I was thinking that the system could be greatly improved by using soil moisture as a metric for watering. With the current design where a remote user is able to dynamically schedule waterings, the user must also pay attention to weather conditions to make informed schedules. Getting real time data back to the user would help aid in schedule making. Ideally, the user wouldn’t even need to worry about scheduling, instead specifying a rule-based system where waterings occur until all sensors are in a nominal range.
One of the classes I decided to take for my last semester is Electronic Systems Design (EE 333) taught by Dr. Gary Tuttle. For this class we are able to choose two projects to work on over the semester, creating a schematic and placing it on a board. The first project is an analog soil moisture sensor, which I’ll write a post about once the boards arrive and are populated.
The second project is for EE 333 is much more challenging and the main subject for this post. I decided to tackle creating a soil moisture that fits the application I described above. To make a successful sensor, I determined it must be completely wireless. This means the communication must be through some wireless protocol and the device must also be charged with solar energy. I have been a long-time fan of the ESP32, so it only seemed like the natural choice for this project. I have used the ESP32 before with MicroPython installed on the Pycom FiPy dev board. I wanted to go lower level this time, so I decided to use the ESP32-WROOM module and use the ESP-IDF to program the board in C. One of the highlights of the ESP32 that makes it a great fit for the MCU is ESP-MESH, which is a mesh network API Espressif has developed. ESP-MESH is built on top of WiFi and seems pretty straight forward to work with.
For the first project, the circuit measures the resistivity of the soil with two electrodes placed on the bottom of the board. While this method works, the electrodes will become corroded after prolonged use and would require the whole board to be replaced, which would be costly. I have done some research and found that capacitive soil moisture meters are longer-lasting and potentially more accurate. Capacitive soil moisture sensors work by measuring how the soil’s dielectric permittivity affects the fringe field created by a capacitor traced out in the circuit board. Since the traces are insulated from the soil, the sensor won’t corrode or oxidize.
Back to the ESP32. One of the other highlights of the ESP32 is the capacitive touch pins. Basic testing I conducted showed that the capacitive touch pins can be used to measure the permittivity of soil. In the picture above you can see my test environment, which consisted of an ESP32 DevKitC, which I have been prototyping with, and a crude capacitive soil probe. The soil probe is two insulated copper plates placed on each side of a wooden steak, with one wired to ground and the other wired to a touch pin. There was a noticeable difference in the value of the pin as I placed it in wet soil vs dry soil. If the difference is enough to accurately measure moisture content is still a question, but it looks like I will definitely be able to calculate an approximate level.
This week I started developing the schematic and writing the code for the ESP32. I also created a page on Hackaday.io. I will be posting there more often with updates and will write another post for this website once the project is finished, or at least at the end of the semester. The circuit schematics will be posted on the hackaday project page and the code can be found on my GitHub account.