Sparometer - NZR SEM 16+ - Linux

af Hans Schou

ALPHA-software: Nogle gange sker det at der er fejl i kommunikationen og der bliver skrevet "error" til skærm. Det skyldes nok noget timing der er lidt for tæt på hvad Spar-o-meteret kan klare. Der arbejdes på at håndtere dette (2008-09-13).

Elsparefonden har valgt at kilde-koden (source code) til Spar-o-meter Windows programmet skal være under GPL licensen. Dermed har det været muligt at se hvad programmet gør og dernæst fremstille et program til Linux der kan kommunikere med sparometeret. Programmet til Linux virker på en lidt anden måde end Windows-programmet, da det er typisk for Linux-programmer at fungere ved kommandolinjen. Linux-programmet kan ca. sample 16 målinger pr. sekund.

Hardware

Nyttige kommandoer

Skriv og aflæs intern valgfri tekst:

$ sparometer --device=/dev/ttyS0 --set-text=abc123
$ sparometer --device=/dev/ttyS0 --get-text
abc123

Aflæs forbrug:

$ sparometer --get-sample-effect
0006.1W

Aflæs forbrug og se rådata:

$ sparometer --get-sample-effect --verbose
Open device: /dev/ttyS0
Command 'get-productid':
"/nzr4SEM16_S_v1.12" "\x0d" "\x0a" 
Command 'programming-mode9600':
Write: "\x06" "051" "\x0d" "\x0a" 
Read : "~" 
Command 'get-sample-effect':
Write: "\x01" "R1" "\x02" "1.7.1()" "\x03" 
Read : "\x02" "1.7.1(0006.1*W)" "\x03" 
Command 'programming-mode300':
Write: "\x06" "001" "\x0d" "\x0a" 
Read : "\x00"

Aflæs watt, ampere og volt løbende 10 gange med tidsangivelse hvert 0.2 sekund:

$ sparometer --get-sample-effect --get-sample-current --get-sample-voltage --loop=10 --time-stamp --delay=0.2
2008-09-13 15:33:47.392547 0006.0W 00.081A 224V
2008-09-13 15:33:47.562509 0006.0W 00.081A 224V
2008-09-13 15:33:47.762477 0006.0W 00.081A 224V
...

Sæt logningsinterval, dato og tid - samt aflæs de satte værdier.

$ sparometer --stop-log --set-interval=01*min --set-date=$(date +%y%m%d) --set-time=$(date +%H%M%S) --get-date --get-time --start-log

Sæt logningsinterval, dato og tid fra system-tid - samt aflæs de satte værdier.

$ sparometer --stop-log --set-interval=01*min --set-date --set-time --get-date --get-time --start-log

Slet alle gamle data.

$ sparometer --reset-log

Aflæs de opsamlede data. Tænd forbrugsenhed - vent et par minutter.

$ sparometer --get-logdata
1080913081238 00 01 3 1.5 W 11.5 A 12.5 V
0167.4 00.925 224
0166.7 00.922 224
0166.1 00.918 224
0164.1 00.909 224
0140.0 00.777 224
0140.1 00.777 224
0139.8 00.778 223
0140.9 00.782 224

Aflæs opsamlede data og konverter med TAB-adskiller.

$ sparometer --get-logdata | logdataformat.pl
DateTime	Watt	Amp	Volt
2008-09-13 08:12:38	0167.4	00.925	224
2008-09-13 08:13:38	0166.7	00.922	224
2008-09-13 08:14:38	0166.1	00.918	224
2008-09-13 08:15:38	0164.1	00.909	224
2008-09-13 08:16:38	0140.0	00.777	224
2008-09-13 08:17:38	0140.1	00.777	224
2008-09-13 08:18:38	0139.8	00.778	223
2008-09-13 08:19:38	0140.9	00.782	224

Aflæs hvor lang log har været aktiv.

$ sparometer --get-log-time
0000489sec 

Aflæs text gemt. Og aflæs hvor lang tid det tager.

$ sparometer --get-text
elcykel
$ /usr/bin/time --format=%e sparometer --get-text
elcykel
3.78

Aflæs interval.

$ sparometer --get-interval
01min

Aflæs kWh forbrug.

$ sparometer --get-kwh
0000.045kWh 

Aflæs max Watt belastning.

$ sparometer --get-max-effect
0085.5W 

Aflæs min Watt belastning.

$ sparometer --get-min-effect
0000.8W 

Aflæs ejernummer.

$ sparometer --get-owner-nr
0000000000 

Aflæs dage.

$ sparometer --get-periode-effect
1Tage 

Aflæs prisperiode.

$ sparometer --get-price-periode
00000.010 

Aflæs pris per år.

$ sparometer --get-price-year
00141.307 

Aflæs ampere belastning.

$ sparometer --get-sample-current
00.377A 

Aflæs frekvens.

$ sparometer --get-sample-freq
50Hz 

Aflæs spænding.

$ sparometer --get-sample-voltage
228V 

Aflæs serienummer.

$ sparometer --get-serial
0000000000 

Aflæs software version.

$ sparometer --get-software-version
112 

Aflæs tarif.

$ sparometer --get-tarif
0.190 

Aflæs oppetid.

$ sparometer --get-up-time
0002759sec 

Aflæs ugedag.

$ sparometer --get-weekday ; date +%u\ %A
5 
4 Thursday

Aflæs mange værdier samtidigt.

$ echo sparometer --get-{date,time,text,kwh,interval,owner-nr,periode-effect,price-{periode,year},tarif,{log,up}-time,sample-{effect,freq,voltage}}
sparometer --get-date --get-time --get-text --get-kwh --get-interval --get-owner-nr --get-periode-effect --get-price-periode --get-price-year --get-tarif --get-log-time --get-up-time --get-sample-effect --get-sample-freq --get-sample-voltage

$ sparometer --get-{date,time,text,kwh,interval,owner-nr,periode-effect,price-{periode,year},tarif,{log,up}-time,sample-{effect,freq,voltage}}
1150604 
1204959 
elcykel 
0000.209kWh 
01min 
0000000000 
1Tage 
00000.039 
00066.409 
0.190 
0015565sec 
0015565sec 
0039.8W 
50Hz 
224V 

Hjælp

$ sparometer --verbose --help

sparometer version 0.0.5.
Copyright © 2015 by Hans Schou <chlor@schou.dk>
Build date: 2015-06-05

  --data-readout
	Spar-o-meter internal command: "\x06" "030" "\x0d" "\x0a" 
	Mode: data-readout 300 baud
	data_readout

  --get-date
	Spar-o-meter internal command: "\x01" "R1" "\x02" "0.9.2()" "\x03" 
	Mode: programming 300 baud
	get_date

  --get-interval
	Spar-o-meter internal command: "\x01" "R1" "\x02" "0.8.4()" "\x03" 
	Mode: programming 300 baud
	get_interval

  --get-kwh
	Spar-o-meter internal command: "\x01" "R1" "\x02" "1.8.1()" "\x03" 
	Mode: programming 300 baud
	get_kwh

  --get-log-time
	Spar-o-meter internal command: "\x01" "R1" "\x02" "130.130()" "\x03" 
	Mode: programming 300 baud
	get_log_time

  --get-logdata
	Spar-o-meter internal command: "\x01" "R5" "\x02" "P.01(;)" "\x03" 
	Mode: programming 9600 baud
	get_logdata

  --get-max-effect
	Spar-o-meter internal command: "\x01" "R1" "\x02" "1.6.1()" "\x03" 
	Mode: programming 300 baud
	get_max_effect

  --get-min-effect
	Spar-o-meter internal command: "\x01" "R1" "\x02" "1.3.1()" "\x03" 
	Mode: programming 300 baud
	get_min_effect

  --get-owner-nr
	Spar-o-meter internal command: "\x01" "R1" "\x02" "0.0.0()" "\x03" 
	Mode: programming 300 baud
	get_owner_nr

  --get-periode-effect
	Spar-o-meter internal command: "\x01" "R1" "\x02" "130.128()" "\x03" 
	Mode: programming 300 baud
	get_periode_effect

  --get-price-periode
	Spar-o-meter internal command: "\x01" "R1" "\x02" "129.130()" "\x03" 
	Mode: programming 300 baud
	get_price_periode

  --get-price-year
	Spar-o-meter internal command: "\x01" "R1" "\x02" "129.129()" "\x03" 
	Mode: programming 300 baud
	get_price_year

  --get-productid
	Spar-o-meter internal command: "/?!" "\x0d" "\x0a" 
	Mode: programming 300 baud
	get_productID '/nzr4SEM16_S_v1.12'

  --get-sample-current
	Spar-o-meter internal command: "\x01" "R1" "\x02" "11.7()" "\x03" 
	Mode: programming 9600 baud
	get_sample_current

  --get-sample-effect
	Spar-o-meter internal command: "\x01" "R1" "\x02" "1.7.1()" "\x03" 
	Mode: programming 9600 baud
	get_sample_effect --get-sample-effect --loop=3 --delay=1

  --get-sample-freq
	Spar-o-meter internal command: "\x01" "R1" "\x02" "14.7()" "\x03" 
	Mode: programming 9600 baud
	get_sample_freq

  --get-sample-voltage
	Spar-o-meter internal command: "\x01" "R1" "\x02" "12.7()" "\x03" 
	Mode: programming 9600 baud
	get_sample_voltage

  --get-serial
	Spar-o-meter internal command: "\x01" "R1" "\x02" "96.1.0()" "\x03" 
	Mode: programming 300 baud
	get_serial

  --get-software-version
	Spar-o-meter internal command: "\x01" "R1" "\x02" "0.2.0()" "\x03" 
	Mode: programming 300 baud
	get_software_version

  --get-tarif
	Spar-o-meter internal command: "\x01" "R1" "\x02" "129.128()" "\x03" 
	Mode: programming 300 baud
	get_tarif

  --get-text
	Spar-o-meter internal command: "\x01" "R1" "\x02" "128.128()" "\x03" 
	Mode: programming 300 baud
	get_text

  --get-time
	Spar-o-meter internal command: "\x01" "R1" "\x02" "0.9.1()" "\x03" 
	Mode: programming 300 baud
	get_time

  --get-up-time
	Spar-o-meter internal command: "\x01" "R1" "\x02" "130.131()" "\x03" 
	Mode: programming 300 baud
	get_up_time

  --get-weekday
	Spar-o-meter internal command: "\x01" "R1" "\x02" "0.9.5()" "\x03" 
	Mode: programming 300 baud
	get_weekday

  --init-end
	Spar-o-meter internal command: "\x01" "B0" "\x03" 
	Mode: programming 300 baud
	init_end

  --manufacturer-mode
	Spar-o-meter internal command: "\x06" "056" "\x0d" "\x0a" 
	Mode: manufactor 9600 baud
	manufacturer_mode

  --periode-log
	Spar-o-meter internal command: "\x01" "W1" "\x02" "130.128(0*Tage)" "\x03" 
	Mode: programming 9600 baud
	periode_log

  --programming-mode2400
	Spar-o-meter internal command: "\x06" "031" "\x0d" "\x0a" 
	Mode: programming 300 baud
	programming_mode2400

  --programming-mode300
	Spar-o-meter internal command: "\x06" "001" "\x0d" "\x0a" 
	Mode: programming 300 baud
	programming_mode300

  --programming-mode4800
	Spar-o-meter internal command: "\x06" "041" "\x0d" "\x0a" 
	Mode: programming 300 baud
	programming_mode4800

  --programming-mode9600
	Spar-o-meter internal command: "\x06" "051" "\x0d" "\x0a" 
	Mode: programming 300 baud
	programming_mode9600

  --reset-log
	Spar-o-meter internal command: "\x01" "E1" "\x02" "131.132(zero)" "\x03" 
	Mode: manufactor 9600 baud
	Clear all logging data stored internal.

  --set-date[=<150606>]
	Spar-o-meter internal command: "\x01" "W1" "\x02" "0.9.2(150606)" "\x03" 
	Mode: programming 300 baud
	Set date in YYMMDD format. If no date given current system day will be used. Syntax: --set-date[=<YYMMDD>]. --set-date=$(date +%y%m%d)

  --set-interval=<01*min>
	Spar-o-meter internal command: "\x01" "W1" "\x02" "0.8.4(01*min)" "\x03" 
	Mode: programming 300 baud
	set_interval

  --set-owner-nr=<99>
	Spar-o-meter internal command: "\x01" "W1" "\x02" "96.1.0(99)" "\x03" 
	Mode: programming 300 baud
	set_owner_nr

  --set-periode-effect=<1>
	Spar-o-meter internal command: "\x01" "W1" "\x02" "130.128()" "\x03" 
	Mode: programming 300 baud
	set_periode_effect

  --set-tarif=<1.550>
	Spar-o-meter internal command: "\x01" "W1" "\x02" "129.128(1.550)" "\x03" 
	Mode: programming 300 baud
	set_tarif

  --set-text=<SPAROMETER>
	Spar-o-meter internal command: "\x01" "W1" "\x02" "128.128(SPAROMETER)" "\x03" 
	Mode: programming 300 baud
	set_text max 30 ASCII characters except '()'. --set-text=$(hostname -f)

  --set-time[=<134852>]
	Spar-o-meter internal command: "\x01" "W1" "\x02" "0.9.1(134852)" "\x03" 
	Mode: programming 300 baud
	Set time in HHMMSS format. If no time given current system time will be used. Syntax: --set-time[=<HHMMSS>]. Example: --set-time=$(date +%H%M%S)

  --start-log
	Spar-o-meter internal command: "\x01" "E1" "\x02" "131.130(start)" "\x03" 
	Mode: manufactor 9600 baud
	start_log

  --stop-log
	Spar-o-meter internal command: "\x01" "E1" "\x02" "131.131(stop)" "\x03" 
	Mode: manufactor 9600 baud
	stop_log

  --delay=<0.0>
	Delay in seconds between executing commands. Example: --delay=1.234567. If no delay is given together with the 'loop' command, there will be no delay. Due to slow communication and A/D conversion the minimum delay is about 0.125 seconds at 9600 baud.

  --device=</dev/ttyUSB0>
	List of serial port devices to try to open. --device=<serial>[:<serial>]. Example: --device=/dev/ttyS0:/dev/ttyS1:/dev/ttyUSB0:/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0

  --debug[=<0>]
	Turn on debug.

  --help
	This help. Use '--verbose' for more details.

  --loop[=<1>]
	Loop commands given. 'loop=0' equals loop for ever.

  --time-stamp
	Prefix each line with a time stamp. 0=false, 1=true.

  --verbose[=<1>]
	Turn on verbose.

ENVIRONMENT
Set environment variable by 'export sparometer=/dev/ttyUSB0' for default serial port instead of the one specified during './configure --enable-serial-device=/dev/ttyUSB0'.

Send bug reports to: <chlor@schou.dk>

Sparometer kan gemme 16000 målinger. Med kommandoen --set-interval=01*min kan intervallet mellem hver måling sættes til fx 1 minut. Elsparefonden foreslår 15 min.

Log-interval
Log
min
Længde
dage
111
222
333
444
555
666
10110
15165
30330
60660

Producent NZR.de Se Elektronische Zähler, SEM-LOG 16+ Artikel-Nr.: 08030301 Standby-Energy-Monitor SEM-LOG 16+

SEM-LOG 16+

Standby-Energy-Monitor SEM-LOG 16+ - NZRSEM16 USB


Horst Schirmeier reported 2012-08-31 that the NZR SEM 16+ USB energy monitor is working with "sparometer" https://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.0.44 .


Powered by: Linux, Apache, Hans Schou

ISO/IEC 15445