|
@@ -0,0 +1,77 @@
|
|
1
|
+title: Smart Meter Bridge
|
|
2
|
+description: Reading SML power meter data transmitted via LoRa
|
|
3
|
+parent: smarthome
|
|
4
|
+position: 150
|
|
5
|
+git: https://git.xythobuz.de/thomas/esp-env
|
|
6
|
+github: https://github.com/xythobuz/esp-env
|
|
7
|
+date: 2024-07-06
|
|
8
|
+comments: true
|
|
9
|
+---
|
|
10
|
+
|
|
11
|
+<!--% backToParent() %-->
|
|
12
|
+
|
|
13
|
+A while ago my power net company installed new smart power meters, specifically the [Iskra MT681](https://wiki.volkszaehler.org/hardware/channels/meters/power/edl-ehz/iskraemeco_mt681).
|
|
14
|
+It has a standardized infrared interface to get some data from it.
|
|
15
|
+There are different [designs](https://wiki.volkszaehler.org/hardware/controllers/ir-schreib-lesekopf-ttl-ausgang) available to attach a microcontroller, both open-source and commercial.
|
|
16
|
+I've gone the lazy route and bought one [from eBay](https://www.ebay.de/itm/353940190755).
|
|
17
|
+
|
|
18
|
+<!--%
|
|
19
|
+lightgallery([
|
|
20
|
+ [ "img/lora_sml_1.jpg", "IR TTL Reader with magnetic base" ],
|
|
21
|
+])
|
|
22
|
+%-->
|
|
23
|
+
|
|
24
|
+Unfortunately the meter is mounted in the basemet of my apartment building, too far for any WiFi signals.
|
|
25
|
+So I decided to try out [LoRa](https://en.wikipedia.org/wiki/LoRa) to transmit the data, using two [Heltec LoRa32](https://heltec.org/project/wifi-lora-32-v3/) dev boards.
|
|
26
|
+
|
|
27
|
+<!--%
|
|
28
|
+lightgallery([
|
|
29
|
+ [ "img/lora_sml_2.jpg", "LoRa SML transmitter, outside" ],
|
|
30
|
+ [ "img/lora_sml_3.jpg", "LoRa SML transmitter, inside" ],
|
|
31
|
+])
|
|
32
|
+%-->
|
|
33
|
+
|
|
34
|
+The interface to the meter is an infrared UART with 9600 8N1.
|
|
35
|
+Over this port it sends messages in a format called [SML](https://de.wikipedia.org/wiki/Smart_Message_Language).
|
|
36
|
+To decode these I'm using [sml_parser](https://github.com/olliiiver/sml_parser).
|
|
37
|
+
|
|
38
|
+<!--%
|
|
39
|
+lightgallery([
|
|
40
|
+ [ "img/lora_sml_4.jpg", "LoRa SML receiver" ],
|
|
41
|
+])
|
|
42
|
+%-->
|
|
43
|
+
|
|
44
|
+To get useful data from the meter you have to unlock it with a PIN from the net provider.
|
|
45
|
+Without this PIN you only get the current energy count in `kWh`, the same number you can see on the display.
|
|
46
|
+After unlocking all data, you get the energy count in `1/10th Wh`, so much finer resolution.
|
|
47
|
+And you also get the current power in `W`.
|
|
48
|
+
|
|
49
|
+<!--%
|
|
50
|
+lightgallery([
|
|
51
|
+ [ "img/lora_sml_5.jpg", "Testing the transmitter" ],
|
|
52
|
+ [ "img/lora_sml_6.jpg", "Readout of SML messages" ],
|
|
53
|
+])
|
|
54
|
+%-->
|
|
55
|
+
|
|
56
|
+For the LoRa PHY I'm using [RadioLib](https://github.com/jgromes/RadioLib/), which already comes integrated into the [unofficial Heltec LoRa 32 library](https://github.com/ropg/heltec_esp32_lora_v3/).
|
|
57
|
+
|
|
58
|
+I'm doing lots of deep sleep on the transmitter side, to safe as much battery capacity as possible.
|
|
59
|
+And I had to use the watchdog in the ESP32 and also do an auto-reset when no messages have been received after a while.
|
|
60
|
+So somewhere the code hangs, sometimes.
|
|
61
|
+But with these hacks in place it seems to work well.
|
|
62
|
+
|
|
63
|
+The code is integrated into my [ESP-Env project](espenv.html) and [repo](https://git.xythobuz.de/thomas/esp-env).
|
|
64
|
+
|
|
65
|
+<!--%
|
|
66
|
+lightgallery([
|
|
67
|
+ [ "img/lora_sml_power.png", "Example of my power usage" ],
|
|
68
|
+ [ "img/lora_sml_battery.png", "Battery usage of the LoRa transmitter" ],
|
|
69
|
+])
|
|
70
|
+%-->
|
|
71
|
+
|
|
72
|
+Here you can see a normal weekend for me, going to bed at 4:30 in the morning, and waking up at around 13:00.
|
|
73
|
+The spike with 1.3kW is heating water for coffee.
|
|
74
|
+The other power readings come from tasmota sockets or my NAS UPS.
|
|
75
|
+
|
|
76
|
+Also the battery usage of the LoRa transmitter is very low.
|
|
77
|
+I will update when I have to recharge them for the first time.
|