Massively increasing electricity prices mean that people want to know more precisely how much electricity they actually use and where there is potential for savings. Nowadays, thanks to modern smart electricity meters, it is easy to read your current electricity consumption precisely.

There are some suitable sensors on the open market for this purpose. A good variant is a sensor that can be connected directly to the network via Wi-Fi, provided the power box where the smart electricity meter is installed, is not made entirely of metal and has at least one plastic rear wall or some plastic opening covers at the bottom or top.

Choosing a device

You can choose between 3 main variants of IR Sensors.

The USB based sensors can be used with Raspberry Pis or other devices which provide a USB port.

If you want to use a specific microcontroller or development board, you have to choose the TTL based version.

If you are good with an ESP-01S microcontroller, and you are sure that the sensor can connect through the power box to an access-point, I would choose the Wi-Fi version.

Build Tasmota with Smart Meter Interface support

The first place to visit is the Smart Meter Interface documentation page of Tasmota: https://tasmota.github.io/docs/Smart-Meter-Interface/. There you can find all the necessary information to let Tasmota support a large variety of smart meters.

To use the script provided below, you also need to define USE_SML_SCRIPT_CMD to allow access to SML variables in other parts of the script.

#ifndef USE_SCRIPT
#define USE_SCRIPT
#endif
#ifndef USE_SML_M
#define USE_SML_M
#define USE_SML_SCRIPT_CMD
#endif
#ifdef USE_RULES
#undef USE_RULES
#endif

 Add more features to your Tasmota code as you like.

Create a Tasmota script for Smart Meter Interface

After compiling the code and flashing the binary on your device, you need to find a pre-created script for your meter at https://tasmota.github.io/docs/Smart-Meter-Interface/#smart-meter-descriptors.

You need to change the >M block in the provided script to the >M block you find in the pre-created script for your meter. Furthermore, the script uses the sml[1] variable for the total power consumption and sml[2] for the actual power consumption. The indices i_ti and i_cc of the sml-array can be different for your meter. The order you put the descriptors in the >M block determine which index they have in the sml-array.

>D
; c=consumption (kWh)
; cc=current consumption (W)
; p=price (Euro)
; h=hour d=day m=month y=year
; td=today ld=last day tw=this week lw=last week
; mt=mqtt timer
; use command "websensor53 0"
ppkwh=0.28

i_ti=1
i_cc=2

t:mt=0

e_p_h=0
e_p_d=0
e_p_m=0
e_p_y=0

run_once=0

; actual total in, ...
a_ti=0
a_cc=0

p:d_ti_mid=0
d_ti_last=0
d_c_td=0
d_p_td=0
p:d_c_ld=0
p:d_p_ld=0

p:days=0
p:w_ti_mid=0
w_ti_last=0
w_c_tw=0
w_p_tw=0
p:w_c_lw=0
p:w_p_lw=0

>S

a_ti=sml[i_ti]
a_cc=sml[i_cc]

d_c_td=a_ti-d_ti_mid
d_p_td=d_c_td*ppkwh

w_c_tw=a_ti-w_ti_mid
w_p_tw=w_c_tw*ppkwh

e_p_h=a_cc*ppkwh/1000
e_p_d=e_p_h*24
e_p_m=e_p_d*30
e_p_y=e_p_d*365

if upsecs>=1
and
upsecs<2
then
=#resetval
endif

if time==0
and
upsecs>=10
and
run_once==0
then
run_once=1
d_ti_last=d_ti_mid
d_ti_mid=sml[i_ti]
d_c_ld=d_ti_mid-d_ti_last
d_p_ld=d_c_ld*ppkwh
if days>=6
then
w_ti_last=w_ti_mid
w_ti_mid=sml[i_ti]
w_c_lw=w_ti_mid-w_ti_last
w_p_lw=w_c_lw*ppkwh
days=0
else
days=days+1
endif
svars
endif

if time==1
and
run_once==1
then
run_once=0
endif

; mqtt
;if (mqtts>0 and mt<=0)
;then
;=>publish stat/%topic%/RESULT {"price_h":"%e_p_h%","price_d":"%e_p_d%","price_m":"%e_p_m%","price_y":"%e_p_y%","watt":"%a_cc%","kwh":"%a_ti%"}
;=>publish stat/%topic%/CONSUM {"c_today":"%3d_c_td%","price_today":"%d_p_td%","c_week":"%3w_c_tw%","price_week":"%w_p_tw%"}
;mt=5
;endif

>B
=>sensor53 r
=>websensor53 0

#resetval
print NS
if d_ti_mid==0
then
d_ti_mid=sml[i_ti]
endif
if w_ti_mid==0
then
w_ti_mid=sml[i_ti]
print w_ti_mid:%w_ti_mid%
endif

>M 1
+1,3,s,0,9600,MT681
1,77070100010800ff@1000,Total Consumed,KWh,Total_in,3
1,77070100100700ff@1,Current Consumption,W,Power_cur,0

>W
<style>table tbody tr th{color:#fff;}table tbody tr td{color:#fff;}h2{color:#fff;}h4{color:#485ccf;}#ptd{color:#ff37d6;padding:0px;}</style>
<style>body{background-image:URL("https://is.gd/v6lsX6");background-size:60%%;}table{background:#0000007a;border-radius:8px;}button{background:#353535;}.bred{background:#b32997;}</style>

MT681 Total Consumed{m} %3a_ti% KWh
MT681 Current Consumption{m} <div id="ptd">%0a_cc% W</div>
<h4>Real - Days</h4>
Consumption Today{m} %3d_c_td% kWh
Price Today{m} <div id="ptd">%d_p_td% Euro</div>
Consumption Yesterday{m} %3d_c_ld% kWh
Price Yesterday{m} %d_p_ld% Euro
<h4>Real - Weeks</h4>
Consumption Week{m} %3w_c_tw% kWh
Price Week{m} <div id="ptd">%w_p_tw% Euro</div>
Consumption Last Week{m} %3w_c_lw% kWh
Price Last Week{m} %w_p_lw% Euro
<h4>Estimated Price</h4>
Hour{m} %e_p_h% Euro
Day{m} %e_p_d% Euro
Month{m} %e_p_m% Euro
Year{m} %e_p_y% Euro
#

Additional Information

You can find some more information about how to style your Tasmota WebUI here: Tasmota Custom WebUI and CSS Style

If you want to do a more precise analyses of the data provided from your smart meter, have a look at this SML parser: https://tasmota-sml-parser.dicp.net/.

If you want to use an old ESP-01 and not a new ESP-01S module, you have to solder a 12k resistor from VCC to GPIO0 and another 12k resistor from VCC to CH_PD. On the following page, some of the differences of the two versions are explained: https://www.forward.com.au/pfod/ESP8266/GPIOpins/ESP8266_01_pin_magic.html

https://ottelo.jimdofree.com/stromz%C3%A4hler-auslesen/

https://homeitems.de/smartmeter-mit-tasmota-auslesen/#

 

 

Comments powered by CComment