Hi all. (Sorry if this is too wordy!)
First ESPHome project and relatively new to HA ( it though) while I am confident enough with C to muddle my way through (although it is pretty casual project usage), I don’t know of the differences in C++ syntax etc.
I’ve tried applying the examples as much as possible but have always found I pick up things quickest (especially code) when working on my own problems (I know it sounds selfish).
I have embedded a capacitive moisture sensor in some bamboo and would like this sensor to report moisture levels. I would then monitor and eventually automate the Rachio irrigation controller to apply extra water as required.
Firstly, I am a little confused (from the examples) how to implement the piecewise equations provided with the sensor.
Second I would prefer to pass both the raw voltage from the sensor as well as the processed values into HA. This is mostly for my sanity and would allow me to check the voltage is matching what it should.
I haven’t seen of way of doing this?
Thank you in advance for any tips
esphome:
name: bamboo-moisture
platform: ESP32
board: esp32dev
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: ""
wifi:
ssid: ""
password: ""
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Bamboo-Moisture Fallback Hotspot"
password: ""
captive_portal:
sensor:
- platform: adc
pin: A0
name: "court_bamboo_voltage"
update_interval: 5min
attenuation: 6db
unit_of_measurement: 'V'
#return V, then return calculation?!?!?
filters:
lambda: |-
if (id(courtyard_bamboo_soil_voltage).state <= 1.1) {
lambda: return X * 10 - 1
}
else if {id(court_bamboo_voltage).state > 1.1 && id(court_bamboo_voltage.state) <= 1.3 {
lambda: return X * 25 - 17.5
}
else if (id(court_bamboo_voltage).state > 1.3 && id(court_bamboo_voltage.state) <= 1.82 {
lambda: return X * 48.08 - 47.5
}
else if (id)court_bamboo_voltage).state > 1.82 && id(court_bamboo_voltage).state <= 2.2 {
lambda: return X * 26.32 - 7.89
}
else if (id(court_bamboo_voltage).state > 2.2 && id(court_bamboo_voltage).state <= 3
lambda: return X * 62.5 - 87.5
}
else {
return ERROR
}
#most soils holding capacity tops out at 50%, 2.2v
unit_of_measurement: '%'