Project

Algemeen

Profiel

Esphome » Geschiedenis » Versie 8

Micha Kersloot, 14-04-2023 20:11

1 1 Micha Kersloot
h1. Esphome
2
3 4 Micha Kersloot
{{>toc}}
4
5 1 Micha Kersloot
h2. TTGO T-Journal
6
7 2 Micha Kersloot
The T-journal is able to communicate the battery state over i2c. After bridging the pads as shown in the picter the IP5306 that is used is connected to pins 13 (scl) and 14 (sda). 
8 1 Micha Kersloot
9 2 Micha Kersloot
!clipboard-202303271732-dyvee.png!
10
11 3 Micha Kersloot
12
working configuration:
13
<pre>
14
substitutions:
15
  device_name: "cam01"
16
17
esphome:
18
  name: '${device_name}'
19
20
esp32:
21
 board: esp32dev
22
 framework:
23
   type: arduino
24
25
# Enable Home Assistant API
26
api:
27
  encryption:
28
    key: "xxxxxxxxxxxx"
29
30
ota:
31
  password: "xxxxxxxxxxxxx"
32
33
wifi:
34
  ssid: !secret wifi_ssid
35
  password: !secret wifi_password
36
37
  # Enable fallback hotspot (captive portal) in case wifi connection fails
38
  ap:
39
    ssid: "cam01 Fallback Hotspot"
40
    password: "xxxxxxx"
41
42
captive_portal:
43
44
external_components:
45
  - source:
46
      type: git
47
      url: https://github.com/MichaKersloot/esphome_custom_components
48
    components: [ ip5306, esp32_camera ]
49
50
i2c:
51
  - id: bus_a
52
    sda: 14
53
    scl: 13
54
    frequency: 400kHz
55
    scan: true    
56
57
ip5306:
58
  battery_level:   # sensor
59
    name: '${device_name} - Battery Level'
60
  charger_connected:  # binary_sensor
61
    id: connected
62
    on_press:
63
      then:
64
        - lambda: ESP_LOGD("TEST", "charging");
65
    on_release:
66
      then:
67
        - lambda: ESP_LOGD("TEST", "not charging");
68
  charge_full:  # binary_sensor
69
    id: full
70
    on_press:
71
      then:
72
        - lambda: ESP_LOGD("TEST", "fully charged");
73
    on_release:
74
      then:
75
        - lambda: ESP_LOGD("TEST", "still charging");
76
77
esp32_camera:
78
  name: '${device_name} - camera'
79
  external_clock:
80
    pin: GPIO27
81
    frequency: 20MHz
82
  i2c_pins:
83
    sda: GPIO25
84
    scl: GPIO23
85
  data_pins: [GPIO17, GPIO35, GPIO34, GPIO5, GPIO39, GPIO18, GPIO36, GPIO19]
86
  vsync_pin: GPIO22
87
  href_pin: GPIO26
88
  pixel_clock_pin: GPIO21
89
  agc_gain_ceiling: 8x
90
  # jpeg_quality: 16
91
  # max_framerate: 25Hz
92
  contrast: 0
93
  brightness: 1
94
  saturation: 0
95
  ae_level: 2
96
  # aec2: True
97
  horizontal_mirror: false
98
  vertical_flip: false
99
  resolution: 800x600
100
101
esp32_camera_web_server:
102
  - port: 8080
103
    mode: stream
104
  - port: 8081
105
    mode: snapshot
106
</pre>
107
108
109 2 Micha Kersloot
If you are unable to program:
110
111 1 Micha Kersloot
  python -m esptool --chip esp32 --port COM5 --baud 115200 --after hard_reset erase_flash
112
113 2 Micha Kersloot
and if even that doesn't solve it:
114 1 Micha Kersloot
115
  python -m esptool --port COM5 write_flash_status --non-volatile 0
116 4 Micha Kersloot
117
h2. p1 dsmr power meter with TTGO T7 v1.3 mini
118
119 7 Micha Kersloot
I'm using a TTGO T7 v1.3 mini with and end of a phone cable with an RJ11 connector. I soldered the cable direct to the board.
120 4 Micha Kersloot
121
!clipboard-202304142146-wfydy.png!
122 5 Micha Kersloot
123
On RJ11, pin 1 and pin 6 are not connected / available
124
125
|_.RJ11 P1|_.ESP32 Pin|_.4w cable|_.comments|
126
|2 - CTS|GPIO19|black|Clear to Send, High = allow P1 Meter to send data|
127
|3 - Data GND|GND|red||
128
|4 - nc|-|green||
129
|5 - RXD (data)|GPIO16|yellow|1K external pull-up resistor needed|
130
131 6 Micha Kersloot
!clipboard-202304142208-kcypl.png!
132
133 8 Micha Kersloot
Working configuration:
134
<pre>
135
substitutions:
136
  name: p1meter
137
  friendly_name: p1meter
138
139
esphome:
140
  name: ${name}
141
  friendly_name: ${friendly_name}
142
143
esp32:
144
  board: ttgo-t7-v13-mini32
145
  framework:
146
    type: arduino
147
148
# Enable logging
149
logger:
150
  # Serial logging is disabled by setting the logger baud rate to 0.
151
  # Otherwise the logger will occupy the hardware UART, making it unavailable
152
  # for receiving smart meter data on pin D7 (GPIO13).
153
  baud_rate: 0
154
  
155
# Enable Home Assistant API
156
api:
157
  encryption:
158
    key: "xxxxxxxxxxxxxxxxxxxx"
159
160
ota:
161
  password: "xxxxxxxxxxxxxxxxxxxxx"
162
163
wifi:
164
  ssid: !secret wifi_ssid
165
  password: !secret wifi_password
166
167
  # Enable fallback hotspot (captive portal) in case wifi connection fails
168
  ap:
169
    ssid: "P1Meter Fallback Hotspot"
170
    password: "xxxxxxxxxxxxx"
171
172
captive_portal:
173
    
174
uart:
175
  id: uart_bus
176
  rx_pin:
177
    number: GPIO16
178
    inverted: true
179
  baud_rate: 115200
180
  rx_buffer_size: 1700
181
182
dsmr:
183
  request_pin: GPIO19
184
185
sensor:
186
  - platform: dsmr
187
    energy_delivered_tariff1:
188
      name: Energy Delivered Tariff 1
189
      state_class: total_increasing
190
    energy_delivered_tariff2:
191
      name: Energy Delivered Tariff 2
192
      state_class: total_increasing
193
    energy_returned_tariff1:
194
      name: Energy Returned Tariff 1
195
    energy_returned_tariff2:
196
      name: Energy Returned Tariff 2
197
    power_delivered:
198
      name: Power Consumed
199
    power_returned:
200
      name: Power Returned
201
    electricity_failures:
202
      name: Electricity Failures
203
    electricity_long_failures:
204
      name: Electricity Long Failures
205
    voltage_l1:
206
      name: Voltage L1
207
    voltage_l2:
208
      name: Voltage L2
209
    voltage_l3:
210
      name: Voltage L3
211
    current_l1:
212
      name: Current L1
213
    current_l2:
214
      name: Current L2
215
    current_l3:
216
      name: Current L3
217
    power_delivered_l1:
218
      name: Power Delivered L1
219
    power_delivered_l2:
220
      name: Power Delivered L2
221
    power_delivered_l3:
222
      name: Power Delivered L3
223
    power_returned_l1:
224
      name: Power Returned L1
225
    power_returned_l2:
226
      name: Power Returned L2
227
    power_returned_l3:
228
      name: Power Returned L3
229
    gas_delivered:
230
      name: Gas Delivered
231
        
232
text_sensor:
233
  - platform: dsmr
234
    identification:
235
      name: Identification
236
    p1_version:
237
      name: Version
238
</pre>
239
240 5 Micha Kersloot
!clipboard-202304142159-fj2tf.png!