Help with setting up lambdas (for Atlas Scientific EZO sensor calibration)

Hello All,

Basically, I want to be able to use #3561 but can’t figure out how to set it up. I don’t want to use mqtt and would prefer to have buttons that can set calibration according to a number I assign instead of having multiple buttons for individual calibration points, or firing events from developer tools.

If I used HA Service calls or esphome automations, would I have to edit my config.yaml file or would all the code be in the individual devices config file in esphome?

It would be great to have the same button be able to calibrate different devices (as I’m looking to calibrate 7 different sensors), but I’m not sure that’s possible.

I’m not a coder or a programmer so I don’t know much, just a new-age farmer looking to be able to manage and maintain all the components from esphome and home assistant without having to hassle with installing tasmota on each device every time I want to calibrate a sensor.

Any and all help would be greatly appreciated, thank you so much!

Hey. Trying to calibrate my EZO pH sensor using labmda calls, but i’m not sure how.
Did you succeed in the end?

Hi!

Yes, I did. They pushed through the pull requests for the EZO sensors (and another one for the Atlas Scientific Pumps), so all you have to do is create buttons for what action you’d like to perform.

https://esphome.io/components/sensor/ezo.html?highlight=ezo was pretty confusing to me because I don’t know much about lambda calls or c++, but @ssieb was nice enough to help me out further with this reply.

One thing to watch out for: In order to verify the buttons were in fact working I ran the ESPHome log on my computer while pressing the buttons from my phone to see if there were any changes to the log. I was unable to get get_calibration(): to respond with info, but all the rest I tried seem to work fine. I had no issues with send_command(): and believe this could be the “easier” way.

Here’s two examples that achieve the same results:

First make sure you have

logger:
  level: verbose

Now you can use the already setup Lambda Calls that @gvdhoven championed.

button:
  - platform: template
    name: "Get Device Info for pH Sensor"
    on_press:
      then:
        - lambda: |-
            id(paste_id_here).get_device_information();

or with the included send_custom(): command.

button:
  - platform: template
    name: "Get Device Info for pH Sensor (custom)"
    on_press:
      then:
        - lambda: |-
            id(paste_id_here).send_custom("i");

Specifically for the calibration commands:
id(paste_id_here).send_custom("Cal,clear"); (not necessary, but if you want)
id(paste_id_here).send_custom("Cal,mid,7.00"); (do mid calibration first so it doesn’t clear the previous info)
id(paste_id_here).send_custom("Cal,low,4.00");
id(paste_id_here).send_custom("Cal,high,10.00");
and to verify id(paste_id_here).send_custom("Cal,?");

The full list of commands you can send to the sensors can be found on Atlas Scientific’s site. Here’s the pH sensor datasheet. (as a side note I found id(paste_id_here).send_custom("Slope,?"); to be very interesting.)

I’m sure there’s a way to create a logbook that shows the results of the button presses in HA so you don’t have to use two devices or have verbose logs… but I haven’t gotten that far.

Hope this helps!

Hi! thanks so much for the clarification! how about the ezo conductivity sensor calibration? can i use the same type of lambda changing the commands? in the esphome site is not clear (at least to me). Thanks!! :slight_smile:

Yup!

It’s the same format for all the EZO circuits. The commands vary depending on what you’re calibrating.