Better Plant Sensor

capacitive_sensor

Capacitive Soil Moisture Sensor

Just as the heading suggests, this is about a capacitive soil moisture sensor. Initially, I was pretty happy with the result of the Plant soil moisture sensor that I recently posted. However, I quickly ran into an issue. The sensor module corroded within a week rendering it utterly useless. Luckily, the sensors came in a multi-pack so I was back up and running again quickly but obviously this would not suffice for long term use. Short version, I need a better plant sensor.

After a little research on the sensor & probe kit, I found that they are all plagued with this issue. There are some discussions around two possible options to increase life. 1) limiting the frequency of applying voltage (that causes the oxidation) or 2) switching to AC as opposed to DC. In my search, I came across the capacitive soil moisture sensor which seems devoid of this issue.

Materials

Wiring (Sensor to Wemos D1)

  • VCC -> VCC(5v)
  • GND –> GND
  • Sensor –> A0

Code

I rarely add any electronics or devices that do not integrate with Home Assistant, so why should this be any different? For this I used the ESPHome integration as it enables the use of YAML to (fairly easily) code.

esphome:
   name: name_of_device
   platform: ESP8266
   board: d1_mini
wifi:
   ssid: "wifi_name"
   password: "wifi_password"
   fast_connect: on
   domain: .local.lan #or your domain (defaults to .local)
web_server: port: 80
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
sensor:
   - platform: adc
     unit_of_measurement: "%"
     icon: "mdi:flower-outline"
     accuracy_decimals: 0
     pin: A0
     filters:
       - lambda: |-
           if (x > 0.7) {
             return 0;
           } else if (x < 0.38) {
             return 100;
           } else {
             return (0.7-x) / (0.7-0.38) * 100.0;
           }
     name: "name_of_sensor"
     update_interval: 300s

HomeAssistant

Once you have the above uploaded and powered, you can add it to your integrations and create a card. Here is what mine looks like, and yes that says “Love Plant”:

plant_sensor
plant_sensor

Automation/Alert

This is where things get fun in my opinion. I set up an automation that will text/email us when the soil gets below a defined threshold.

- id: '1572199874719'
  alias: Plant Monitor
  description: Notify when plants need water
  trigger:
  - below: '40'
    entity_id: sensor.soil_moisture_level
    for: 'minutes: 10'
    platform: numeric_state
  condition: []
  action:
  - data:
      message: This is your Love Plant… Why don't you love me? Please give me water!
  service: notify.gmail 
Please follow and like us:

Leave a Reply