Tasmota: Build firmware for Smart Meter Interfaces

Hi,

SML feature is not included in default builds. You have to compile it by yourself.


Create a python virtual environment

1
michael@debdev ~ # sudo apt install python3 python3-venv
1
2
3
4
5
6
7
michael@debdev ~ # python3 -m venv tasmota-build-sml
michael@debdev ~ # source tasmota-build-sml/bin/activate
(tasmota-build-sml) michael@debdev ~ # pip install --upgrade pip
(tasmota-build-sml) michael@debdev ~ # pip install -U platformio
(tasmota-build-sml) michael@debdev ~ # git clone https://github.com/arendst/Tasmota.git Tasmota
(tasmota-build-sml) michael@debdev ~ # cd ~/Tasmota
(tasmota-build-sml) michael@debdev ~/Tasmota #

Create a file tasmota/user_config_override.h

with content

1
2
3
4
5
6
7
8
9
#ifndef USE_SCRIPT
#define USE_SCRIPT
#endif
#ifndef USE_SML_M
#define USE_SML_M
#endif
#ifdef USE_RULES
#undef USE_RULES
#endif

Start build

1
(tasmota-build-sml) michael@debdev ~/Tasmota # pio run

Flashing the device. create a new virtual env

1
2
3
michael@debdev ~ # python3 -m venv ~/esptool
michael@debdev ~ # source ~/esptool/bin/activate
[esptool] michael@debdev ~ # python3 -m pip install setuptools wheel esptool

and flash the device

1
michael@debdev ~ # esptool.py  --baud 115200 write_flash -fs 1MB -fm dout 0x0  ~/Tasmota/build_output/firmware/tasmota.bin

Set the tasmota module to “generic”: Tasmota -> configuration -> module -> generic
and set the IO Pins to none: Tasmota -> configuration -> Template -> All ports to none

Physically I connected the volkszaehler out to the D7/IO 13.

Then looking for your device in the smartmeter descriptors

In my case a EFR SGM-C8. I used EFR SGM-C2/C4/D4. Open the tasmota, navigate to tools then script, enable the script checkbox and copy the sml descriptor into the script textbox:

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
>D
>B
->sensor53 r
>M 1
+1,13,s,16,9600,EFR
1,77070100010800ff@1000,Comsumption,kWh,Total,4
;for meters measuring feed-in SGM-Cx-xxx2xx
;1,77070100020800ff@1000,Supply,kWh,Supply,4
;next 4 lines for double-tariff meters SGM-Cx-xxxxTx
1,77070100010801ff@1000,Comsumption_t1,kWh,Total_t1,4
1,77070100010802ff@1000,Comsumption_t2,kWh,Total_t2,4
1,77070100020801ff@1000,Supply_t1,kWh,Supply_t1,4
1,77070100020802ff@1000,Supply_t2,kWh,Supply_t2,4
;all commented lines from here on for 3-phase meter SGM-C4
1,77070100100700ff@1,Actual Power,W,Power,0
1,77070100200700ff@1,Voltage L1,V,Voltage,1
1,77070100340700ff@1,Voltage L2,V,Voltage_L2,1
1,77070100480700ff@1,Voltage L3,V,Voltage_L3,1
1,770701001f0700ff@1,Current L1,A,Current,2
1,77070100330700ff@1,Current L2,A,Current_L2,2
1,77070100470700ff@1,Current L3,A,Current_L3,2
1,77070100510701ff@1,Phaseangle L2-L1,deg,phase_angle_L2_L1,0
1,77070100510702ff@1,Phaseangle L3-L1,deg,phase_angle_L3_L1,0
1,77070100510704ff@1,Phaseangle I/U L1,deg,phase_angle_L1,1
1,7707010051070fff@1,Phaseangle I/U L2,deg,phase_angle_L2,1 
1,7707010051071aff@1,Phaseangle I/U L3,deg,phase_angle_L3,1
1,770701000e0700ff@1,Frequency,Hz,Freq,1
;all commented lines from here on just for completeness
;1,7707010000020000@1,Firmware Version,,FwVer,0
;1,77070100605a0201@1,Firmware Checksum,,FwCheck,0
;1,7707010061610000@1,Error Register,,ErrorReg,0
;1,7707010060320101@1,Hardware Version,,HwVer,0
;1,7707010060320104@1,Parameter Version,,ParamVer,0
;1,77070100600100ff@#,Server-ID,,ID,0
;You can find your server-id printed on your meter. If you want you can also convert it to your Identifikationsnummer with some ASCII, DEC and HEX encoding. 0A-01-45-46-52-ST-UV-WX-YZ = 1EFR + string(S) + string(T) + hexToDec(UVWXYZ)
#

I have to adjust the first config line:

1
+1,13,s,16,9600,EFR

Explaintation:

1
2
3
4
5
6
+1   is the first smartmeter
13   is the IO Pin (also Working with 14, 12)
s    is means a SML-SmartMeter
16   build a Medianvalue over the measures
9600 BAUD Rate
EFR  Define your  own name

You can also dump out what is received over the serial wire. open Tasmota console => Tools/console and start the dump for smartmeter 1

1
sensor53 d1

The out can be copied to https://tasmota-sml-parser.dicp.net/decode and check what could be decoded.

Some cases (port or SML descriptor) may need a power off/on cycle.

Michael