Page 1 of 1

Using Ufire PH and EC probes in Esphome

Posted: Mon Oct 26, 2020 2:40 am
by Gromyjoe
Here is my Esphome Custom Components file.

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);
  }
};

And Here is my Esphome Node

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;
I havent yet tried to calibrate but it should work. window_size means it will take the 11 most recent measurements and send the average to home assistant. send_evey means it will send the 6th data point of the average. and send_first_at will send the 3rd measured reading and ignore the first 2. these will all be changed after I learn how all this works.
- 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.

Re: Using Ufire PH and EC probes in Esphome

Posted: Mon Oct 26, 2020 2:39 pm
by LEDG
Nice! Thank you for taking the time to share.

Re: Using Ufire PH and EC probes in Esphome

Posted: Thu Oct 29, 2020 3:26 am
by Calceus
Thanks for your sharing.

Re: Using Ufire PH and EC probes in Esphome

Posted: Tue Jan 12, 2021 4:54 pm
by jaysal
Hey Gromyjoe,
How are the uFire PH and EC probes performing? Looks like you implement a few months ago.

Re: Using Ufire PH and EC probes in Esphome

Posted: Tue Feb 23, 2021 9:45 am
by Elburro24
Would love to hear how they are working

Re: Using Ufire PH and EC probes in Esphome

Posted: Sun May 23, 2021 9:45 am
by azazel
i just recieve this ufire product.

Re: Using Ufire PH and EC probes in Esphome

Posted: Sat Jun 12, 2021 2:00 am
by Gromyjoe
sorry for the late repy, its been working pretty well so far. the probe isn't great quality so id like to finish making all the ufire features work.... someday, but for now flashing a new update every month is just fine. Havent really played around in home assistant much lately though, so nothings really changed besides my plants. They seem to enjoy the stable levels alot more!