Code: Select all
#include <esphome.h>
#include <uFire_EC.h>
#include <uFire_pH.h>
class uFire_probe : public PollingComponent, public Sensor {
public:
uFire_EC ec;
uFire_pH ph;
Sensor *Ufire_pH = new Sensor();
Sensor *Ufire_EC = new Sensor();
Sensor *Ufire_TempC = new Sensor();
// constructor
uFire_probe() : PollingComponent(15000) {}
void setup() override {
ec.begin();
ph.begin();
ec.reset();
ph.reset();
}
void update() override {
float pH = ph.measurepH(ec.measureTemp());
Ufire_pH->publish_state(pH);
float s = ec.measureEC(ec.measureTemp());
Ufire_EC->publish_state(s);
float tempC = ec.measureTemp();
Ufire_TempC->publish_state(tempC);
}
};
Code: Select all
esphome:
name: water_nutrient_doser
platform: ESP32
board: nodemcu-32s
includes:
- uFire_probe.h
libraries:
- "Isolated EC Probe Interface"
- "Isolated ISE Probe Interface"
wifi:
ssid: "PUTYOURSSIDHERE"
password: "***************"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Water Nutrient Doser"
password: "ndWGx0DLzA10"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
i2c:
sda: 22
scl: 21
sensor:
- platform: custom
lambda: |-
auto my_sensor = new uFire_probe();
App.register_component(my_sensor);
return {my_sensor->Ufire_EC, my_sensor->Ufire_TempC, my_sensor->Ufire_pH};
sensors:
- name: "Ufire_EC"
unit_of_measurement: ec
accuracy_decimals: 3
filters:
- median:
window_size: 11
send_every: 6
send_first_at: 3
- calibrate_linear:
- 0.540 -> 0.700
- 2.320 -> 2.000
- 12.540 -> 12.880
- name: "Ufire_TempC"
unit_of_measurement: Celsius
accuracy_decimals: 2
- name: "Ufire_pH"
unit_of_measurement: PH
accuracy_decimals: 2
filters:
- median:
window_size: 11
send_every: 6
send_first_at: 3
- calibrate_linear:
- 4.47 -> 4.01
- 7.57 -> 7.00
- 9.21 -> 9.00
- platform: pulse_counter
pin: GPIO17
unit_of_measurement: 'L/Hr'
name: 'Reverse Osmosis Water'
update_interval: 10s
# filters:
# - lambda: return (x / 27.0) * 60.0;
- calibrate_linear: is basically taking the measured value (the first number) and setting the offset of what it should be. So for example you put the probe in ph solution 4.01 and you get a reading of the averaged value 4.47 ph, you enter 4.47->4.01 . Then repeat for mid and high range... This is just what im understanding so dont quote me on this and it hasnt been tested yet besides them sending values.
Hope someone finds this useful!!! And im pretty sure this would work for any brand of sensors as long as the library is available in platformio.