-
Notifications
You must be signed in to change notification settings - Fork 14
/
phsensor.yaml
74 lines (65 loc) · 1.57 KB
/
phsensor.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
esphome:
name: phsensor
platform: ESP8266
board: d1_mini
wifi:
ssid: "xxx"
password: "xxx"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "xxx"
password: "xxx"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
sensor:
# https://esphome.io/components/sensor/adc.html
- platform: adc
pin: A0
id: ph
name: "pH Sensor"
update_interval: 1s
unit_of_measurement: pH
# https://esphome.io/components/sensor/index.html#sensor-filters
filters:
- median:
window_size: 7
send_every: 4
send_first_at: 3
# Measured voltage -> Actual pH (buffer solution)
- calibrate_linear:
- 0.59 -> 7.0
- 0.71 -> 4.0
i2c:
sda: D2
scl: D1
scan: true
display:
- platform: lcd_pcf8574
dimensions: 16x2
lambda: |-
it.printf(0, 0, "pH: %.2f", id(ph).state);
if (id(ph).state < 4) {
it.print(0, 1, "Very acidic");
}
else if (id(ph).state >= 4 && id(ph).state < 5) {
it.print(0, 1, "Acidic");
}
else if (id(ph).state >= 5 && id(ph).state < 7) {
it.print(0, 1, "Acidic-ish");
}
else if (id(ph).state >= 7 && id(ph).state < 8) {
it.print(0, 1, "Neutral");
}
else if (id(ph).state >= 8 && id(ph).state < 10) {
it.print(0, 1, "Alkaline-ish");
}
else if (id(ph).state >= 10 && id(ph).state < 11) {
it.print(0, 1, "Alkaline");
}
else if (id(ph).state >= 11) {
it.print(0, 1, "Very alkaline");
}