Hello,
I have started recently in getting in the fantastic world of ESPHome devices. My first project is to use a Moisture sensor (more precisely Capacitive Soil Moisture Sensor v1.2) to keep track of when I should water plants.
I started earlier this week (below I’m going to include the source code) and I was getting some consistent results. Then from yesterday evening I started getting quite random results.
Here below the chart of the sensor where is visible when the ESP started returning quite random results (25 Aug evening). From that moment I tried to:
- Re-upload the sketch
- Change the sensor (with an equal)
And nothing still getting very weird results. Do you have any idea of why this is happening? The code is the same, no changes were made by my self.
Let me know your thoughts, thanks in advance
Ciao
esphome:
name: esphome-soil_moisture
friendly_name: ESPHome Soil Moisture
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
platform: esphome
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "esphome-soil_moisture"
password: !secret ap_password
captive_portal:
#Soil moisture sensor
sensor:
- platform: adc
pin: GPIO35
name: "Soil Moisture"
id: soil_moisture
accuracy_decimals: 1
update_interval: 5s
icon: mdi:flower
unit_of_measurement: '%'
attenuation: 11db
filters:
- lambda: |-
if (x > 2) { // if over 2 volts, we are dry
return 0;
} else if (x < 1.0) { // if under 1 volts, we are fully saturated
return 100;
} else {
return (2-x) / (2-1.0) * 100.0; // use a linear fit for any values in between
}
- median:
window_size: 7
send_every: 4
send_first_at: 1
- platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
name: "WiFi Signal dB"
id: wifi_signal_db
update_interval: 5s
filters:
- median:
window_size: 7
send_every: 4
send_first_at: 1