Using Ufire PH and EC probes in Esphome

Home Assistant automation projects, questions, etc. go here.
Post Reply
Gromyjoe
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 48
Joined: Fri Jul 03, 2020 2:28 pm

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.
User avatar
LEDG
Site Admin
Reactions:
Posts: 1599
Joined: Sun Jun 04, 2017 8:15 pm

Nice! Thank you for taking the time to share.
Want to Support the Site?

Use this Amazon referral link and any purchase you make within 24 hrs will earn LEDgardener a commission at no cost to you!
User avatar
Calceus
LED-Curious
LED-Curious
Reactions:
Posts: 1
Joined: Mon Sep 21, 2020 7:00 am

Thanks for your sharing.
jaysal
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 75
Joined: Sat May 30, 2020 7:49 am

Hey Gromyjoe,
How are the uFire PH and EC probes performing? Looks like you implement a few months ago.
Elburro24
LED-Curious
LED-Curious
Reactions:
Posts: 17
Joined: Tue Feb 23, 2021 9:43 am

Would love to hear how they are working
azazel
LED-Curious
LED-Curious
Reactions:
Posts: 1
Joined: Thu May 13, 2021 4:12 pm

i just recieve this ufire product.
Attachments
694270.jpg
Gromyjoe
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 48
Joined: Fri Jul 03, 2020 2:28 pm

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!
Post Reply