Skip to main content Microfireย 

Mod-pH for Home Assistant



๐Ÿ“’ Datasheet

Datasheet

PDF DOC HTML

In this write-up, we will install ESPHome to get pH measurements into Home Assistant.

  • We will be working in a terminal and using a few commands
  • You'll need a Home Assistant installation running
  • An ESP-device
  • A Mod-pH module and preferably a carrier board


These instructions are for the CLI version of ESPHome. You can also copy and paste the YAML into the ESPHome addon within Home Assistant and avoid the CLI completely.



1.

๐Ÿ“ฆ Install ESPHome

Follow the instructions on the ESPHome website.

2.

๐Ÿ Start a project

Type in the terminal. Make sure the path on the terminal is where you want the project to be. Follow the steps, and there should be a .yaml file in the directory you ran the command in. For this write-up, it will be mod-ph.yaml. If you type you should see the project compile.

3.

๐Ÿ”Œ Connections

  • Wiring for ESP32 and the sensor module
    Module
    Controller
    GND ground
    VCC 3.3 - 5 volt power supply
    SCL SCL
    SDA SDA
    PROBE_1 input probe wire
    PROBE_2 reference probe wire
  • Wiring for ESP32 and the carrier board
    Carrier Board
    Controller
    GND ground
    VIN 3.3 - 5 volt power supply
    SCL SCL
    SDA SDA
    1W optional 1-wire device signal line
    EN optional EN wire, drive HIGH to disable both power modules
    Carrier 1W Header
    1-Wire Sensor
    GND ground
    VCC 3.3 - 5 volt power supply
    SIG signal data line for 1-Wire sensor

    Probe connection is made with the SMA connector, using a SMA-BNC Bulkhead or similar.


4.

๐Ÿ”ข Code

We'll use an external sensor component to get the Mod-pH module working. This is done by adding some lines to the YAML.


The YAML file should be changed to the following:

1
substitutions:
2
  friendly_name: Microfire Mod-pH
3
  device_name: microfire-mod-ph
4
esphome:
5
  name: $device_name
6
esp32:
7
  board: esp32dev
8
  framework:
9
    type: arduino
10
logger:
11
api:
12
ota:
13
wifi:
14
  ssid: !secret wifi_ssid
15
  password: !secret wifi_password
16
  ap:
17
    ssid: $device_name
18
    password: !secret wifi_failover
19
captive_portal:
20

21
# import the mod-ph component
22
external_components:
23
  - source:
24
      type: git
25
      url: https://github.com/u-fire/ESPHomeComponents/
26

27
# https://esphome.io/components/i2c.html
28
i2c:
29
  sda: 21
30
  scl: 22
31

32
sensor:
33
  - platform: mod_ph
34
    id: ph
35
    name: pH
36
    update_interval: 15s
37

38
button:
39
  - platform: template
40
    id: ph_calibrate_low
41
    name: pH Calibrate Low 4.0
42
    icon: mdi:format-vertical-align-bottom
43
    on_press:
44
        lambda: |-
45
          id(ph).calibrateLow(4.0);
46
47
  - platform: template
48
    id: ph_calibrate_mid
49
    name: pH Calibrate Mid 7.0
50
    icon: mdi:format-vertical-align-center
51
    on_press:
52
        lambda: |-
53
          id(ph).calibrateMid(7.0);
54
55
  - platform: template
56
    id: ph_calibrate_high
57
    name: pH Calibrate High 10.0
58
    icon: mdi:format-vertical-align-top
59
    on_press:
60
        lambda: |-
61
          id(ph).calibrateHigh(10.0);
62
63
  - platform: template
64
    id: ph_calibrate_reset
65
    name: pH Calibrate Reset
66
    icon: mdi:restore
67
    on_press:
68
        lambda: |-
69
          id(ph).calibrateReset();
70
71
  - platform: factory_reset
72
    name: Restart with Factory Default Settings

Make sure you change the wifi section to your network and password if you aren't using a secrets.yaml. Check that the i2c section is using the correct pins.



5.

โžก๏ธ Upload

Type . It will compile the project and ask you which serial device to upload the code to. After that, you'll see the ESP debug output. If everything goes to plan, you should see a device has been discovered in Home Assistant.



6.

๐Ÿ  Home Assistant

From within Home Assistant, press Settings > Devices & Services and find the device in the ESPHome integration box. Click it and then click where it says 1 Device. You should see a screen with all the information, Mod-pH measurement, and some buttons to calibrate and reset the device. You can create dashboards, scripts, and anything else Home Assistant can do from here.

There is more documentation and examples for various combinations of sensors/modules on our ESPHomeComponents GitHub repo

.




Related items