Soil moisture sensor for house plants



  • Hello community,
    I want to present my project of a soil moisture sensor for potted flowers.
    Two years ago I experimented with building a soil moisture sensor, at that time I created a concept based on @mfalkvidd's solution from this thread:

    https://forum.mysensors.org/topic/2147/office-plant-monitoring

    The sensor has been working continuously for 2 years (and counting). Recently I returned to the project, taking into account all the pros and cons that I have noticed over the past 2 years.

    Assumptions of the old project:

    1. The lowest possible price of production, while maintaining functionality.
    2. Long operating time on one battery.
    3. Maintenance-free
    4. Sensor enclosed in a small housing
    5. Notification on the phone about the need to water the plant
    6. Notification on the phone about the lack of contact with the sensor (failure, dead battery).

    This is how the sensor powered by a CR2032 battery was created. The sensor reported the moisture content of the soil in the pot. And the battery level in %. The soil moisture measurement was based on a pullup resistor built into the microprocessor and a fork sensor without an intermediary circuit.

    However, this approach did not quite suit me – due to the low sensitivity of the system, as well as the pullup built into the processor, the measurement tended to "float" without any clear reason. I was also not satisfied with the sensor's measurement range and the characteristics of this range. Therefore, returning to the topic, I added new requirements:

    Assumptions of the new project:

    1. The lowest possible price of production, while maintaining functionality.
    2. Operation time of several years on one battery.
    3. Maintenance-free
    4. Sensor enclosed in a small housing
    5. Notification by phone about the need to water the plant
    6. Notification by phone about the lack of contact with the sensor (failure, dead battery).
    7. Measurement through a voltage divider, calibrated to the highest sensitivity when the soil requires watering
    8. Voltage divider ensuring a wide measurement range
    9. In the case of developing the project, changing (updating) the software will not require calibrating the battery voltage measurement separately for each sensor - one software, updating the sensors without changing the code for each sensor.
    10. Sensor adapted to different heights of pots

    This is how it was created:
    The sensor fits in a Kinder Surpirse egg ball (sorry USA) - you don't have to buy a special housing. The probes are made of stainless steel wire (here you can still see the test ones made of ordinary steel, from bicycle spokes, the target ones have already been ordered).

    The voltage measurement correction is saved in the eeprom - so when updating the software, it does not have to be entered for each sensor separately.
    I used a 4k7 resistor as a voltage divider and of course the soil in the pot. Only the following are transferred to the host (Home Assistant): Battery level in % and the result read from the Arduino ADC.
    The 4k7 resistor is powered from pin 5, to which the supply voltage is applied only for about 1 second before the measurement.
    The system takes less than 10uA during standby, wakes up every 15 minutes to check the soil moisture, if it detects a change of a large value, then it sends an update - this is in case of watering.
    Every hour it checks if there has been a smaller change in humidity and if so, sends an update. Additionally, if there has been no update for the last 2 hours - it is sent.

    The ADC reading is changed to % humidity already in the Home Assistant scripts. The time from contact with the sensor is also counted there and messages are sent.

    A two-step initial calibration is required:

    1. During sensor programming, a voltage correction is entered into the eeprom
    2. Calibration of 100% and 0% humidity readings is done in Home Assistant, without the need for physical access to the sensor or changing its software.

    The sensor is based on Arduino Pro Mini 328p 3.3V (it also fits on 168, but debugging must be disabled) from Aliexpress. It was necessary to remove the voltage regulator, power LED and rectifier diode on the RAW input. Then solder the jumpers so that the VCC voltage is available on the RAW pin. The following are also installed: 2 pieces of 47uF capacitors, Radio NRF24L01+, connectors and wires. I am currently collecting data for the second calibration - to set the % humidity and messages about the need to water.

    My English is not perfect, so I used Google Translate

    https://drive.google.com/file/d/19YzKoPAPLfLj49oFyMzQ9IYZ5GfdNKjK/view?usp=sharing



  • I forgot to add that I set the internal ATMEGA 328p clock to 1MHz, changed the bootloader and set "Brown-out detection disabled".

    Photos:
    Foto1
    Foto2
    Foto3



  • I did a soil moisture sensor for outdoors. It is powered from an 18650 battery charged from a small solar panel (1W).

    My device uses 6mA in standby. Can you provide a reference on achieving 10µA? Removing the power LED certainly will reduce power usage, though one loses the visual of power on when debugging.

    The sensor I use is capacitive, as opposed the resistive your using. I read somewhere that resistive probes corrode faster, but then, I've had problems with the devices I'm using because the electronics got wet (I think I've fixed that in this version).

    I have 4 units deployed. One solar panel is much less than 1W and doesn't provide enough power during a cloudy day. It comes and goes. Another has stopped communicating. and I have yet to determine its problem. (They're remote and I'm a lot of kilometers away from them.)

    I'd suggest you create a github page and fully document what you've done. My hope is that my documentation is adequate to the point that someone can build it with no help from me, even though I'd be glad to help.

    Good job!

    -OSD



  • I saw your project. Removing the LED and voltage regulator reduced the consumption from mA to uA (in standby). I think that the charging module for 18650 + step-down converter can draw a lot of power. Have you thought about giving up the 18650, solar panel and all the electronics for them, and using two batteries? Batteries with simple optimization of the code and hardware will give you a long operating time. Even with AA batteries the operating time will be significant, and if you use LR14 or LR20, I think you can count the operating time in years. With such batteries, it is also easy to take care of waterproofness (if appearance and size are not a priority) - you place the whole thing in a sewage pipe connector + two caps - tightness guaranteed.
    As for corrosion, in my opinion it is not a problem with sensors powered by batteries. The sensor is powered for a very short time, and corrosion is caused by the current flow. I don't bother with reversing the polarity in the sensor, but reversing the power supply can eliminate rusting altogether. It so happens that today I was taking the last old-type sensors out of the pots, so I took pictures. What is visible on it is the stuck soil (before taking the picture I only rinsed them under the tap and wiped them with a paper towel). The sensors worked in the ground for 2 years and a few months. In the current version I have sensors built based on a stainless steel rod.

    Photo 1
    Photo 2



  • I think the comments you make are good. I do have a question about the removing the regulator. I assume you mean the 5V to 3.3V regulator.

    I connect to the 5V and I see lot of variation in moisture readings due to the variation in the output of the power supply (solar panel/stepdown). I have a calibration routine for that. The voltage can go as high as 4.2V, which I believe may be bad if I connect the power supply to 3.3V.

    Of course, this is not a concern if using two 1.5V batteries. With batteries, the moisture reading would be more consistent over a day. Lot of advantages there. I just don't like changing batteries and I really hate it when they leak. I have every reason to believe that my power supply will last 10 years and I am fortunate to live in a place with consistent sunshine 🙂 . Someone replicating my project will have to take this into consideration. My design easily accommodates a different power supply.

    And my power supply could be used in other projects.

    Resistive vs Capacitive sensor. I'm glad you report good results. This gives people options.

    Water moisture: I've had good experience with "spraying" the Arduino with clear electronic coating and sealing the enclosure with liquid tape.

    -OSD



Suggested Topics

36
Online

11.5k
Users

11.1k
Topics

112.9k
Posts