Smartmeter: vzlogger on Orange Pi Zero

Hi,

these are the steps to install vzlogger on an Orange Pi Zero by using a volkszaehler TTL device as interface to get the measures of the electricity meter. Connect the Output to the Pin 10/GPIO199/UART1_RX

First of all install Armbian .

Enable UART1. Open /boot/armbianEnv.txt and add the device tree overlay.

1
2
overlay_prefix=sun8i-h3
overlays=uart1

Reboot the PC. If the volkszaehler TTL interface is already connected you can check if data are received.
Install python serial and start python

1
2
root@debdev ~ # apt install python3-serial
root@debdev ~ # python3

Enter the following code

1
2
3
4
5
6
7
import serial
# Serielle Schnittstelle konfigurieren
ser = serial.Serial('/dev/ttyS1', 9600, timeout=1)
while True:
    data = ser.read(16# Read 16 Bytes
    if data:
        print(data.hex())  # print Bytes as Hex

This should be shown something like this:

1
2
3
4
5
6
7
8
9
10
11
12
77070100100700ff0101621b52005900
000000000000060177070100240700ff
0101621b520059000000000000000601
77070100380700ff0101621b52005900
0000000000000001770701004c0700ff
0101621b520059000000000000000001
77070100200700ff0101622352ff6900
000000000009490177070100340700ff
0101622352ff69000000000000094a01
77070100480700ff0101622352ff6900
0000000000094701770701001f0700ff
0101622152fe69000000000000000401

Download, build and install vzlogger

1
2
3
4
5
6
7
8
9
root@debdev ~ #apt-get install extrace git-core cmake libtool dh-autoreconf uuid-dev libmicrohttpd-dev \
    build-essential pkg-config libgnutls28-dev libssl-dev libmosquitto-dev libgcrypt20-dev libcurl3-dev \
    libunistring-dev libssl-dev libsasl2-dev libcurl4-openssl-dev uuid-dev libtool libltdl-dev
     
root@debdev ~ # mkdir ~/software
root@debdev ~ # cd  ~/software
root@debdev ~ # export CMAKE_INSTALL_PREFIX=/usr/local
root@debdev ~ # bash install.sh vzlogger libjson libsml mqtt

Create a user vzlogger and add it to the dialout group to get access to the serial device(s)

1
2
3
root@debdev ~ # useradd -r -s /sbin/nologin vzlogger
root@debdev ~ # usermod -a -G vzlogger vzlogger
root@debdev ~ # usermod -a -G dialout vzlogger

Edit /etc/systemd/system/vzlogger.service and adjust as seen below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
vi /etc/systemd/system/vzlogger.service
[Unit]
Description=vzlogger
After=syslog.target network.target
[Service]
User=vzlogger
Group=vzlogger
ExecStart=/usr/local/bin/vzlogger -c /etc/vzlogger.conf
ExecReload=
StandardOutput=null
ExecStartPre=-/usr/bin/mkdir -p /var/log/vzlogger
ExecStartPre=-/usr/bin/chown vzlogger:vzlogger/var/log/vzlogger
 
[Install]
WantedBy=multi-user.target

Add als the following lines to /etc/rc.local (before exit 0 :-))

1
2
/usr/bin/mkdir -p /var/log/vzlogger
/usr/bin/chown volkszaehler:volkszaehler /var/log/vzlogger

then you have to define your Smartmeter/electricity meter config. For me a EFR SGM-C8.

Create a file /etc/vzlogger.conf

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
{
"retry" : 0,                   /* how long to sleep between failed requests, in seconds */
"verbosity" : 15,               /* between 0 and 15 */
"log" : "/var/log/vzlogger/vzlogger.log",/* path to logfile, optional */
 
"local" : {
        "enabled" : true,      /* should we start the local HTTPd for serving live readings? */
        "port" : 8081,            /* the TCP port for the local HTTPd */
        "index" : true,         /* should we provide a index listing of available channels? */
        "timeout" : 30,         /* timeout for long polling comet requests, 0 disables comet, in seconds */
        "buffer" : 600,          /* how long to buffer readings for the local interface, in seconds */
         },
         // mqtt client support (if ENABLE_MQTT set at cmake generation)
         "mqtt": {
                 "enabled": true,  // enable mqtt client. needs host and port as well
                 "host": "10.10.254.100", // mqtt server addr
                 "port": 1883, // 1883 for unencrypted, 8883 enc, 8884 enc cert needed,
                 "cafile": "", // optional file with server CA
                 "capath": "", // optional path for server CAs. see mosquitto.conf. Specify only cafile or capath
                 "certfile": "", // optional file for your client certificate (e.g. client.crt)
                 "keyfile": "", // optional path for your client certficate private key (e.g. client.key)
                 "keypass": "", // optional password for your private key
                 "keepalive": 30, // optional keepalive in seconds.
                 "topic": "home/stromzaehler", // optional topic dont use $ at start and no / at end
                 "id": "", // optional static id, if not set "vzlogger_<pid>" will be used
                 "user": "user", // optional user name for the mqtt server
                 "pass": "mqttpw", // optional password for the mqtt server
                 "retain": false, // optional use retain message flag
                 "rawAndAgg": false, // optional publish raw values even if agg mode is used
                 "qos": 0, // optional quality of service, default is 0
                 "timestamp": false // optional whether to include a timestamp in the payload
         },
         "meters" : [
            {
                    // EFR SGM-C8
                    "enabled" : true,       /* disabled meters will be ignored */
                    "protocol" : "sml",     /* use 'vzlogger -h' for list of available protocols */
                    "device" : "/dev/ttyS1", // Serial device
                    "parity": "8N1",              
                    "baudrate": 9600,
                    "interval": 10,
                    "aggtime":30, // aggrate for 30sec and then send
                    "use_local_time": true,
                    "channels": [
                                                        {
                                                        "uuid": "034a512b-3958-4d74-a58b-caa297c6f28c", //Powershell  [system.guid]::NewGuid().Guid | Set-Clipboard
                                                        "identifier": "1-0:1.8.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "e0d53b6d-45d7-483e-b3f0-da6832c9843b",
                                                        "identifier": "1-0:2.8.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "c0398814-e358-405c-8ae7-1ea1ccf34882",
                                                        "identifier": "1-0:16.7.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "26d47a34-ca49-4941-8459-ba82a6427f40",
                                                        "identifier": "1-0:36.7.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                {
                                                        "uuid": "3460a86e-de8b-4168-b058-57933e8995ca",
                                                        "identifier": "1-0:56.7.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_co>
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "2bd577a9-5b61-445d-aaaf-47ad664e8a94",
                                                        "identifier": "1-0:76.7.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "9d6c3b8b-c4b8-469d-94d8-fb85c4e8caba",
                                                        "identifier": "1-0:32.7.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "3008ee57-06c6-4f47-a426-2996126e5fb9",
                                                        "identifier": "1-0:52.7.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "3d05b927-45a1-4dd8-bc29-b57d07fb6c11",
                                                        "identifier": "1-0:72.7.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "9bfc0a8b-7a4e-420a-a8fb-c8a125c1b4aa",
                                                        "identifier": "1-0:31.7.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "3739a365-96f7-4e4c-bfa5-c4e7c6766430",
                                                        "identifier": "1-0:51.7.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "3cae1182-b5ae-43b0-b924-52cf17a21853",
                                                        "identifier": "1-0:71.7.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                                                                        {
                                                        "uuid": "3e9463b5-7319-403e-a597-0b02b580f0c4",
                                                        "identifier": "1-0:81.7.1",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "c9520c8b-8341-437d-af88-c82a2325c9c2",
                                                        "identifier": "1-0:81.7.2",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "270d1a11-f458-4a43-8f1c-301578eed7dd",
                                                        "identifier": "1-0:81.7.4",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "ee2140ec-a9a7-423b-b565-26ddefe20303",
                                                        "identifier": "1-0:81.7.15",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "7a2c975a-af19-41c7-887e-6097d0590f70",
                                                        "identifier": "1-0:81.7.26",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        },
                                                        {
                                                        "uuid": "60aef602-d242-4bf2-af0d-86b7077ca917",
                                                        "identifier": "1-0:14.7.0",
                                                        "api": "null", // Nur MQTT https://wiki.volkszaehler.org/software/controller/vzlogger/vzlogger_conf_parameter#channels
                                                        "middleware": "http://localhost",
                                                        "aggmode": "max", // Possible avg, max, none
                                                        "duplicates": 60
                                                        }
                    ]
         
 
                }
        ]
}

Enable and start vzlooger

1
2
root@debdev ~ # systemctl enable vzlogger
root@debdev ~ # systemctl start vzlogger

Tasmota: Build firmware for Smart Meter Interfaces

Hi,

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

Continue reading Tasmota: Build firmware for Smart Meter Interfaces

Windows: sysprep fails with “Failure occurred while executing ‘Sysprep_Clean_Opk’ “

Hi,

after an Upgrade from Windows 10 to Windows 11 on a customer PC sysprep is no longer working. Unfortunataly the error messages in C:\Windows\System32\sysprep\Panther\setuperr.log does not really help to find the root cause:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Error                        pGetUninstallInterfaceCommon: Failed loading the setupplatform, hr = 0x80070666
Error                 SYSPRP RemoveUninstall:Failed to instantiate uninstall interface; hr = 0x80070666
Error                 SYSPRP Sysprep_Clean_Opk:Failed to remove Uninstall; dwRet = 0x666
Error                 SYSPRP ActionPlatform::LaunchModule: Failure occurred while executing 'Sysprep_Clean_Opk' from C:\Windows\System32\spopk.dll; dwRet = 0x666
Error                 SYSPRP SysprepSession::ExecuteAction: Failed during sysprepModule operation; dwRet = 0x666
Error                 SYSPRP SysprepSession::ExecuteInternal: Error in executing action for Microsoft-Windows-Sysprep-SpOpk; dwRet = 0x666
Error                 SYSPRP SysprepSession::Execute: Error in executing actions from C:\Windows\System32\Sysprep\ActionFiles\Cleanup.xml; dwRet = 0x666
Error                 SYSPRP RunPlatformActions:Failed while executing Sysprep session actions; dwRet = 0x666
Error      [0x0f0070] SYSPRP RunDlls:An error occurred while running registry sysprep DLLs, halting sysprep execution. dwRet = 0x666
Error      [0x0f00a8] SYSPRP WinMain:Hit failure while processing sysprep cleanup providers; hr = 0x80070666
Error      [0x0f0060] SYSPRP ParseCommands:Found unsupported command line option '/?'
Error      [0x0f00a4] SYSPRP WinMain: Unable to parse command-line arguments to sysprep; GLE = 0x0
Error      [0x0f0060] SYSPRP ParseCommands:Found unsupported command line option '/?'
Error      [0x0f00a4] SYSPRP WinMain: Unable to parse command-line arguments to sysprep; GLE = 0x0

Continue reading Windows: sysprep fails with “Failure occurred while executing ‘Sysprep_Clean_Opk’ “

Windows Powershell: CTRL-Space is no longer working

Hi,

the powershell has a “slimmed down intellisense” to complete commandlet names, functions, .NET types etc.
Continue reading Windows Powershell: CTRL-Space is no longer working

Windows: Convert an ETL (Event tracing file) into a human readable format

Hi,

event tracing files, for example produced by wusa.exe log parameter, are binary files. The powershell command let Get-WinEvent couldn’t open it but Windows Eventviewer is able to read those files.
There is also an option to convert ETL files.
Continue reading Windows: Convert an ETL (Event tracing file) into a human readable format

My Knowledgebase for things about Linux, Windows, VMware, Electronic and so on…