Project

Algemeen

Profiel

Esphome » Geschiedenis » Versie 12

Tom Albers, 19-08-2024 14:19

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 10 Micha Kersloot
more on: https://github.com/LilyGO/TTGO-T7-Demo
120
121 9 Micha Kersloot
I'm using a TTGO T7 v1.3 mini and a piece of a dutch phone cable with an RJ11 connector. I soldered the cable directly on the board.
122 4 Micha Kersloot
123
!clipboard-202304142146-wfydy.png!
124 5 Micha Kersloot
125
On RJ11, pin 1 and pin 6 are not connected / available
126
127
|_.RJ11 P1|_.ESP32 Pin|_.4w cable|_.comments|
128
|2 - CTS|GPIO19|black|Clear to Send, High = allow P1 Meter to send data|
129
|3 - Data GND|GND|red||
130
|4 - nc|-|green||
131
|5 - RXD (data)|GPIO16|yellow|1K external pull-up resistor needed|
132
133 6 Micha Kersloot
!clipboard-202304142208-kcypl.png!
134
135 8 Micha Kersloot
Working configuration:
136
<pre>
137
substitutions:
138
  name: p1meter
139
  friendly_name: p1meter
140
141
esphome:
142
  name: ${name}
143
  friendly_name: ${friendly_name}
144
145
esp32:
146
  board: ttgo-t7-v13-mini32
147
  framework:
148
    type: arduino
149
150
# Enable logging
151
logger:
152
  # Serial logging is disabled by setting the logger baud rate to 0.
153
  # Otherwise the logger will occupy the hardware UART, making it unavailable
154
  # for receiving smart meter data on pin D7 (GPIO13).
155
  baud_rate: 0
156
  
157
# Enable Home Assistant API
158
api:
159
  encryption:
160
    key: "xxxxxxxxxxxxxxxxxxxx"
161
162
ota:
163
  password: "xxxxxxxxxxxxxxxxxxxxx"
164
165
wifi:
166
  ssid: !secret wifi_ssid
167
  password: !secret wifi_password
168
169
  # Enable fallback hotspot (captive portal) in case wifi connection fails
170
  ap:
171
    ssid: "P1Meter Fallback Hotspot"
172
    password: "xxxxxxxxxxxxx"
173
174
captive_portal:
175
    
176
uart:
177
  id: uart_bus
178
  rx_pin:
179
    number: GPIO16
180
    inverted: true
181
  baud_rate: 115200
182
  rx_buffer_size: 1700
183
184
dsmr:
185
  request_pin: GPIO19
186
187
sensor:
188
  - platform: dsmr
189
    energy_delivered_tariff1:
190
      name: Energy Delivered Tariff 1
191
      state_class: total_increasing
192
    energy_delivered_tariff2:
193
      name: Energy Delivered Tariff 2
194
      state_class: total_increasing
195
    energy_returned_tariff1:
196
      name: Energy Returned Tariff 1
197
    energy_returned_tariff2:
198
      name: Energy Returned Tariff 2
199
    power_delivered:
200
      name: Power Consumed
201
    power_returned:
202
      name: Power Returned
203
    electricity_failures:
204
      name: Electricity Failures
205
    electricity_long_failures:
206
      name: Electricity Long Failures
207
    voltage_l1:
208
      name: Voltage L1
209
    voltage_l2:
210
      name: Voltage L2
211
    voltage_l3:
212
      name: Voltage L3
213
    current_l1:
214
      name: Current L1
215
    current_l2:
216
      name: Current L2
217
    current_l3:
218
      name: Current L3
219
    power_delivered_l1:
220
      name: Power Delivered L1
221
    power_delivered_l2:
222
      name: Power Delivered L2
223
    power_delivered_l3:
224
      name: Power Delivered L3
225
    power_returned_l1:
226
      name: Power Returned L1
227
    power_returned_l2:
228
      name: Power Returned L2
229
    power_returned_l3:
230
      name: Power Returned L3
231
    gas_delivered:
232
      name: Gas Delivered
233
        
234
text_sensor:
235
  - platform: dsmr
236
    identification:
237
      name: Identification
238
    p1_version:
239
      name: Version
240
</pre>
241
242 5 Micha Kersloot
!clipboard-202304142159-fj2tf.png!