Git Product home page Git Product logo

voltcraft-sem-6000's Introduction

voltcraft-sem-6000

"A full-featured shell script in order to manage Bluetooth switch, scheduler and smart energy meter Voltcraft SEM 6000 with Linux and Raspberry Pi"

The Voltcraft SEM-6000 is a remote 230V switch and smart energy meter. It was sold by Conrad Elektronik in Germany.

For details take a look at Conrad. The device is also known as Smart Power Plug EU by Revogi, see https://www.revogi.com/smart-power/power-plug-eu/#section0

In comparison to many remote switches which use the 433MHz band the SEM-6000 is based on Bluetooth v4.0. The advantage is that there is no need to have additional hardware, e.g. via GPIO connected sender/receiver.

Voltcraft SEM-6000 has the following features:

  • 12 schedulers which can run once or assigned to weekdays
  • Countdown mode in order to switch power on or off after a certain period
  • Configurable overload-mode in order to auto-turn-off or alarm in case of power overload
  • Energy meter in order to measure volt, ampere and watts in real-time
  • Energy meter recorder in order to measure power consumption over long period

Getting started

1. Check pre-conditions

Install expect:

$ sudo apt install expect

Check if gatttool is available:

$ gatttool
Usage:
  gatttool [OPTION...]
...

2. Discover the MAC address of the smart energy meter

$ sudo hcitool lescan
E Scan ...
FC:69:47:06:CB:C6 Voltcraft

The devices are called "Voltcraft" by default. Note that device appears with a different name if you have renamed if before.

3. Pair bluetooth

There is no need to pair device.

4. Aliases

For convenience reasons I recommend using aliases. Instead of entering the Bluetooth mac address each time you want to run the script, you can call the script by using meaningful names.

The script tries to read a file called .known_sem6 which must be located in your home folder. It is a text file with three columns:

  1. MAC address
  2. PIN
  3. Meaningful name

My .known_sem6 looks as follows:

$ cat ~/.known_sem6
FC:69:47:06:CB:C6 0000 fridge

This enables you to call the script like this

$ ./sem-6000.exp fridge --sync

instead of

$ ./sem-6000.exp FC:69:47:06:CB:C6 0000 --sync

Note: You don't even have to write the whole alias. This works as well:

$ ./sem-6000.exp f --sync

Getting help

To get an overview of the full feature set enter the following:

$ ./sem-6000.exp fr --help
Usage: <mac/alias> <pin> --<command1> <parameters...> --<command2>
                                   <mac>: bluetooth mac address of smart energy meter
                                   <alias>: you can use alias instead of mac address, see ~/.known_sem6
                                   <pin>: pin of smart energy meter if not stored in alias file
                                   <command>: For command and parameters

Basic commands:

 --on                               - turn on smart energy meter
 --off                              - turn off smart energy meter
 --toggle                           - toggle smart energy meter
 --standby <watts>                  - turn off device if consumption is less than given watts
                                      watts - low-water-mark, max. 3680, e.g. 2.654 for 2.654W


Scheduler commands:

 --scheduler <on|off> <hh:mm|+mm> [<smtwtfs>] [<YYYY-MM-DD>]
                                      on|off    - action of new scheduler
                                      hh:mm|+mm - start time or minutes from now
                                      smtwtfs   - (optional) weekdays, use capital letters to set, e.g. sMTWTFs
                                                  use the word "sameday" for same weekdays like today
                                                  if weekdays are missing then scheduler runs only once
                                      YYYY-MM-DD - (optional) Date from when it should run

 --scheduler <n> <set|unset|reset>  - activate, deactivate or reset given scheduler

 --scheduler reset                  - resets all schedulers, i.e. 1 - 12

 --scheduler                        - query status of all schedulers

Countdown commands:

 --countdown <on|off> <YYYY-MM-DD hh:mm:ss|hh:mm|+mm>
                                    - set countdown action and runtime
                                      on|off - action of countdown
                                      YYYY-MM-DD hh:mm:ss - given ETA
                                      hh:mm  - given ETA within next 24h
                                      +mm    - given runtime in minutes

 --countdown <reset>                - reset countdown

 --countdown                        - query status of countdown

Measurement commands:

 --status                           - get status incl. voltage, ampere, watts, power factor and frequency
 --measure header                   - print header line for measurements
 --measure [<s>]                    - take measurements, optional duration in seconds (use 0 for single), otherwise forever

 --data <day|month|year>            - request measured power consumption from enery meter
 --data reset                       - reset all data of measured power consumption
 --data header                      - print header line for measurements or data

Device commands:

 --device                           - read device meta information, i.e. name and serial no.
 --sync                             - synchronize time
 --name <name>                      - give smart meter a new name, max. 18 characters
 --pin <1234|reset>                 - change PIN or reset to default PIN, i.e. 0000

Device settings:

 --settings                         - request settings from device, i.e. overload, led, price
 --led <on|off>                     - turn led ring on / off
 --overload <watts>
                                    - set overload with high-water-mark and actions
                                      watts - high-water-mark, max. 3680, e.g. 3680 for 3680W

 --price <normal price> [<reduced price> <hh:mm> <hh:mm>]
                                    - set price and optionally a reduced price with start and end time
                                      Note: You can either use reduced price mode or statistics but not both
 --reset                            - factory reset

Statistics:

 --statistics reset                 - reset all captured data and set starting time to now
                                      Note: You can either use reduced price mode or statistics but not both
 --statistics set <mm-dd hh:mm>     - set starting time for statistics explicitly
 --statistics                       - capture and calculate statistics, i.e. average and projections consumption

Other commands:

 --print                            - print gathered information
 --json                             - print some gathered information in JSON format
 --dump                             - request all information from device
 --sleep <n>                        - pause processing for n seconds
 --verbose                          - print information about processing
 --debug                            - print actions in gatttool
 --help [<command>]                 - print general help or help for specific command

You get specific help for a command if you ask for it explicitly:

$ $ ./sem-6000.exp --help toggle
Usage: <mac/alias> <pin> --<command1> <parameters...> --<command2>
                                   <mac>: bluetooth mac address of smart energy meter
                                   <alias>: you can use alias instead of mac address, see ~/.known_sem6
                                   <pin>: pin of smart energy meter if not stored in alias file
                                   <command>: For command and parameters

 --toggle                           - toggle smart energy meter

PIN

The smart meter is protected by a 4-digit pin. The default pin is 0000.

You can change the pin by using the pin command:

./sem-6000.exp FC:69:47:06:CB:C6 0000 --pin 1234

or if you make use of the .known_sem6 file

./sem-6000.exp f --pin 0000

Note Don't forget to change PIN in .known_sem6 file since this has to be done manually!

if you have forgotten your PIN you can reset it by doing this:

./sem-6000.exp FC:69:47:06:CB:C6 2342 --pin reset

This resets the pin to factory default, i.e. 0000

Note You can use any pin after the bluetooth mac address!

Basic commands

Turn switch on and off

You can turn on the socket as follows:

$ ./sem-6000.exp fridge --on

Note that there isn't any feedback.

You can turn the device off by entering this:

$ ./sem-6000.exp fridge --off

If you want to toggle the switch you use the toggle command:

$ ./sem-6000.exp fridge --toggle

Queueing commands / sleep command

Since it takes some time to establish the Bluetooth connection each time you start the script, I have introduced command queuing. Each command starts with a dash. In this example I queue 7 commands. The sleep command pauses processing before the next command starts.

$ ./sem-6000.exp fridge --on --sleep 1 --toggle --sleep 1 --toggle --sleep 1 --off

Print gathered information

In most cases the script won't print anything. If you want to print some output, e.g. information that has been gathered by previous commands, you must tell the script to do so explicitly.

$ ./sem-6000.exp fridge --status --print
        Status:
          Power:             on
          Voltage:           236 VAC
          Ampere:            0.012 A
          Watts:             0.056 W
          Frequency:         50 Hz
          Power factor:      0.02
          Total consumption: 0.0 kWh

In this example we have already made use of the status command.

See power state of the socket

If you want to see if the socket is turned on and what the current power consumption is, you must ask for status first and print it afterwards:

$ ./sem-6000.exp fridge --status --print
        Status:
          Power:             on
          Voltage:           236 VAC
          Ampere:            0.012 A
          Watts:             0.056 W
          Frequency:         50 Hz
          Power factor:      0.02
          Total consumption: 0.0 kWh

Schedulers

The socket has 12 schedulers that can be programmed once or per weekday.

First let's look at the current state of schedulers:

$ ./sem-6000.exp fridge --scheduler --print
        Schedulers:          0

Note, that I have queued two commands again, i.e. "-scheduler" and "-print". The first command gathers the information but doesn't output anything. The second command prints the gathered information.

There are no schedulers set yet.

Let's set the first scheduler for weekdays from Monday to Friday. The scheduler should turn my device on at 7:00 a.m.

$ ./sem-6000.exp fridge --scheduler on 07:00 _MTWTF_

Now, I want to add a scheduler that is going to run once at a specific date and turn the device off

$ ./sem-6000.exp fridge --scheduler off 21:30 2019-09-03

Let's take a look at the settings of all schedulers:

$ ./sem-6000.exp fridge --scheduler --print
        Schedulers:          2

        Scheduler 1:
          Slot:              11
          Active:            yes
          Action:            turn off
          Date:              2019-09-03
          Time:              21:30
          Weekdays:          _______

        Scheduler 2:
          Slot:              12
          Active:            yes
          Action:            turn on
          Date:              2019-07-20
          Time:              07:00
          Weekdays:          _MTWTF_

In order to reset a specific scheduler or all schedulers run:

$ ./sem-6000.exp fridge --scheduler 1 reset
$ ./sem-6000.exp fridge --scheduler reset

Countdown

The socket has a timer. You can set it with an ease like this:

$ ./sem-6000.exp fridge --countdown off +10

This activates a countdown timer which runs for 10 minutes and then turns the socket off. You can also specify a date of arrival (ETA) like this:

$ ./sem-6000.exp fridge --countdown off 2019-08-30 07:45:30

Let's ask for information about the countdown that we have started before:

$ ./sem-6000.exp fridge --countdown --print
        Countdown:            on
          Action:             off
          Started at:         2019-07-20 13:47:19
          ETA:                2019-08-30 07:45:30
          Runtime:            40 days, 17:58:11
          Remaining:          40 days, 17:57:49

Enter the following in order to stop the running countdown:

$ ./sem-6000.exp fridge --countdown reset

Power commands

The smart energy meter monitors power consumption continuously. It can automatically power off in case that power consumption exceeds a certain limit.

Measurements

Note: It is required to execute the sync command before you can start any measurements:

$ ./sem-6000.exp fridge --sync

Snapshot

If you want to take and print a single measurement, just call the status command:

$ ./sem-6000.exp fridge --status --print
        Status:
          Power:             on
          Voltage:           236 VAC
          Ampere:            0.012 A
          Watts:             0.013 W
          Frequency:         50 Hz
          Power factor:      0.00
          Total consumption: 0.0 kWh

Real-time monitoring

The measure command captures power data. This monitors the power consumption for 5 seconds:

$ ./sem-6000.exp fridge --measure header --measure 5
Timestamp       Power   Volt (V)        Ampere (A)      Watt (W)        Frequency (Hz)  Power factor
2019-07-20 15:56:27     1       236     0.012   0.045   50      0.02
2019-07-20 15:56:29     1       236     0.012   0.045   50      0.02
2019-07-20 15:56:29     1       236     0.012   0.0     50      0.00
2019-07-20 15:56:30     1       236     0.012   0.041   50      0.01
2019-07-20 15:56:31     1       236     0.012   0.041   50      0.01
2019-07-20 15:56:31     1       236     0.012   0.0     50      0.00

Note that the measure command directly prints a csv record. If you have left out the period, here "5" for 5 seconds, it runs forever. You can stop it by pressing CTRL-C

Request recorded data

Recorded data

The smart energy meter records power consumption. Data is recorded in three scopes: a. Hourly for the last 24 hours b. Daily for the last 30 days c. Monthly for the last 12 month

To request recorded data, use the data command.

The following command requests recorded data for last 24 hours and prints it with header line.

$ ./sem-6000.exp fridge --data header --data day --print
Timestamp       Watt (Wh)
2019-07-19 15:00        8
2019-07-19 16:00        11
...
2019-07-20 12:00        17
2019-07-20 13:00        19
2019-07-20 14:00        13

Reset recorded data

If you want to reset all recorded data enter the following:

$ ./sem-6000.exp fridge --data reset

Statistics

The smart meter measures consumption permanently. Based on the power-on time the script calculates average and projected consumption.

Unfortunately the device doesn't store the power-on time by itself (in comparison to the Voltcraft SEM-3600BT). That's why I store the starting time for statistics in one of the fields meant for reduced price. Therefore, you can't activate reduced price mode and statistics in parallel. Statistics only work if reduced price mode is deactivated and vice versa.

Start statistics

In order to activate statistics, do the following:

$ sem-6000 fridge --statistics

Note that this also resets all measured data. If you remember when you have started measuring, you can just set the starting time like this. Here time and date are set to Octobre, 31st.

$ sem-6000 fridge --statistics set 10-31 20:15

Note that if date is in future the script assumes that last year is meant.

Request statistics

After statistics was set and ran for at least one minute you can request statistics as follows:

$ sem-6000 fridge --statistics --print
Settings:
  LED ring:             off
  Overload limit:       1300 W

  Price:                0.31 $ per kWh

  Reduced mode:         off

Status:
  Power:                on
  Voltage:              236 VAC
  Ampere:               0.195 A
  Watts:                25.568 W
  Frequency:            50 Hz
  Power factor:         0.56
  Total consumption:    0.0 kWh
  Total last 12 months: 14.239 kWh

Statistics:
  Log statistics since:  2021-10-03 11:17
  Current consumption:   14.239 kWh
  Avg. consumption:      42.62 Wh
  Projected consumption: 373.351 kWh per year
  Projected price:       115.74 $ per year

2020-11 0
2020-12 0
2021-01 0
2021-02 0
2021-03 0
2021-04 0
2021-05 0
2021-06 0
2021-07 0
2021-08 0
2021-09 0
2021-10 14239

Settings

Synchronize time

If you just want to synchronize the time from your PC with the smart meter call:

$ ./sem-6000.exp fridge --sync

LED ring

Normally the LED ring indicates that the switch is turned on. You can turn off the LED ring so that it is always off even if the switch is turned on.

$ ./sem-6000.exp fridge --led off

Overload limit

You can configure that the smart energy meter turn off in case that it exceeds a limit in terms of power consumption. In this example the socket turns off immediately in case that power consumption gets higher that 1000 Watts:

$ ./sem-6000.exp fridge --overload 1000

The default value is 3680W

$ ./sem-6000.exp fridge --overload 3680

Prices

The switch can store two different prices, i.e. the normal price and a reduced price. Actually, the switch doesn't seem to calculate internally, so that this setting makes only sense if you use the official app.

It goes like this:

$ ./sem-6000.exp fridge --price 0.32 0.20 23:00 07:00

Request settings

Run the settings command in order to request current settings:

$ ./sem-6000.exp fridge --settings --print
        LED ring:            off
        Overload limit:      3680 W

        Price:               0.32

        Reduced mode:        on
        Reduced price:       0.20
        Reduced start:       23:00
        Reduced end:         07:00

More commands

Device information

In order to get general device information, you can request it by using the device command:

$ ./sem-6000.exp fridge --device --print
        Mac:                 FC:69:47:06:CB:C6
        Device PIN:          0000
        Name:                Voltcraft
        Serial:              ML01D10012000000
        Alias:               fridge

Set name

You can set a name for the device

Verbose

If you want to get some information what's going on while the script is running, add the verbose command.

$ ./sem-6000.exp fridge --verbose --on --status
INFO:   Try to connect to FC:69:47:06:CB:C6
INFO:   Connected to FC:69:47:06:CB:C6
INFO:   Auth SEM
INFO:   >>>     char-write-req 2b 0f0c170000000000000000000018ffff
INFO:   OK
INFO:   <<<     Notification handle = 0x2b value: 0f 06 17 00 00 00 00 18 ff ff
INFO:   Response completed in terms of announced length and end sequence
INFO:   SEM authorized successfully with PIN
INFO:   Switch SEM
INFO:   >>>     char-write-req 2b 0f06030001000005ffff
INFO:   OK
INFO:   <<<     Notification handle = 0x2b value: 0f 04 03 00 00 04 ff ff
INFO:   Response completed in terms of announced length and end sequence
INFO:   SEM successfully switched
INFO:   Request measurement
INFO:   >>>     char-write-req 2b 0f050400000005ffff
INFO:   OK
INFO:   <<<     Notification handle = 0x2b value: 0f 11 04 00 01 00 bd a1 eb 00 e1 32 00 00 00 00 00 00 62
INFO:   Response already completed in current notification in terms of announced length. No need to wait for another notification

INFO:   Measurement successfully requested
INFO:   Disconnect from FC:69:47:06:CB:C6

Debug

The script uses gatttool from the bluez bluetooth stack. You can also see the commands sent to gatttool by using the debug command:

$ ./sem-6000.exp fridge --debug --on --status
[                 ][LE]> connect FC:69:47:06:CB:C6
Attempting to connect to FC:69:47:06:CB:C6
Connection successful
[FC:69:47:06:CB:C6][LE]> char-write-req 2b 0f0c170000000000000000000018ffff
Characteristic value was written successfully
Notification handle = 0x002e value: 0f 06 17 00 00 00 00 18 ff ff
[FC:69:47:06:CB:C6][LE]> char-write-req 2b 0f06030001000005ffff
Characteristic value was written successfully
Notification handle = 0x002e value: 0f 04 03 00 00 04 ff ff
[FC:69:47:06:CB:C6][LE]> char-write-req 2b 0f050400000005ffff
Characteristic value was written successfully
Notification handle = 0x002e value: 0f 11 04 00 01 00 be 6f eb 00 e2 32 00 00 00 00 00 00 32
[FC:69:47:06:CB:C6][LE]>

Dump

The dump command tries to gather all information from the device.

$ ./sem-6000.exp fridge --dump --print
        Mac:                 FC:69:47:06:CB:C6
        Device PIN:          0000
        Name:                Fridge
        Serial:              ML01D10012000000
        Alias:               fridge

        Status:
          Power:             on
          Voltage:           235 VAC
          Ampere:            0.225 A
          Watts:             48.448 W
          Frequency:         50 Hz
          Power factor:      0.92
          Total consumption: 0.0 kWh

        LED ring:            off
        Overload limit:      3680 W

        Price:               0.32

        Reduced mode:        on
        Reduced price:       0.20
        Reduced start:       23:00
        Reduced end:         07:00

        Schedulers:          0

        Countdown:           off
        Randommode:          off

voltcraft-sem-6000's People

Contributors

heckie75 avatar moormaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voltcraft-sem-6000's Issues

Total Power always zero

Hoi, I like the work done on the script t decode the data.
Who I compare the information in the Mobile app with the Status command in the script, I see that the total energy is always 0. ( Also in the examples you show)
I have decoded the hex stringiest and see that the location where you read the Total is also 0.

I think we need to look at a different place for the total power used.

connect error: Function not implemented (38)

Since this week I am getting this error when executing the script.
Is something similar happening to anyone?

connect error: Function not implemented (38)
while executing
"exec gatttool -b $sem(mac) --characteristics > $hndfile"
(procedure "setup_characteristics" line 6)
invoked from within
"setup_characteristics"
(procedure "init_handles" line 11)
invoked from within
"init_handles"
(procedure "init" line 9)
invoked from within
"init $INIT(auth)"
("^sync$" arm line 3)
invoked from within
"switch -regexp $command {

^sync$ {

  init $INIT(auth)
  req_sync

}
^status$ {

  init $INIT(auth)
  capture_measurement..."
(procedure "do_command" line 12)
invoked from within

"do_command $param"
("while" body line 13)
invoked from within
"while { 1 } {

set param [ lindex $argv 0 ]
set argv [ lrange $argv 1 end ]

if { [string range $param 0 1 ] == "--" } {
set param [string r..."
(file "./sem-6000.exp" line 3580)

Consumption trigger problem

The consumption statistics can be read, start time can be set and it can be reset to 0. But in my case it does not start counting the consumption. The current consumption is read out correctly, but the consumption for the last hour, day, etc. stays 0. I read out via bluetooth with an raspberry pi and the LED ring keeps blinking blue.
But if the voltcraft App once started then the LED ring turns automatically green and I can stop the app again. Now the consumption per hour, day, etc. starts growing. Is there a way to trigger the "voltcraft sem" like the APP to not manually have to activate it (which signal is send to the "voltcraft sem" from the APP)?

Power factor not in --status --json output

The --status --print human readable output also shows the calculated the power factor (source) but the --status --json output does not include it (source). I see that the power factor can be calculated from the other values in the JSON output but maybe it would be easier to include it directly? Or is there a downside in doing that?

Also wanted to say: cool project and reverse engineering, thanks!

Only working with firmware 1.16?

Hi,
first of all: thanks for this great project.
I've used this to get remote access to my power plugs for a long time. For some reason I installed the app and when I connected the plugs, the app told me that there is a firmware update. I did the update, my plugs firmware is now on version 1.22 and I cannot connect with this project :(
Is there any hope for me to get it working again, either by downgrading the firmware (is it possible? if yes, how?) or by an adopted version of this project?
Kind Regards, Mike

Time is 1h ahead

After sync, measurement time is +1h:
[date
Sun 20 Nov 19:02:18 CET 2022
jan@raspberrypi:~ $ ./sem-6000.exp p --sync
jan@raspberrypi:~ $ ./sem-6000.exp p --measure header --measure 10
Timestamp Power Volt (V) Ampere (A) Watt (W) Frequency (Hz) Power factor
2022-11-20 20:02:44 1 231 0.0 0.0 49 1
2022-11-20 20:02:45 1 231 0.0 0.0 49 1
2022-11-20 20:02:46 1 231 0.0 0.0 49 1
2022-11-20 20:02:46 1 231 0.0 0.0 49 1
2022-11-20 20:02:47 1 231 0.0 0.0 49 1
2022-11-20 20:02:48 1 230 0.0 0.0 49 1
2022-11-20 20:02:48 1 228 0.0 0.0 49 1
2022-11-20 20:02:49 1 228 0.0 0.0 49 1
2022-11-20 20:02:50 1 230 0.0 0.0 49 1
2022-11-20 20:02:50 1 230 0.0 0.0 49 1
2022-11-20 20:02:51 1 230 0.0 0.0 49 1
2022-11-20 20:02:52 1 230 0.0 0.0 49 1
2022-11-20 20:02:52 1 230 0.0 0.0 49 1
jan@raspberrypi:~ $

Get Wh for shorter period

If I understand README correctly no measurement command measures power consumption (Wh) but just current (W or A). Just recorded data can show power consumption but by hours and days.

Is it possible to get power consumption for shorter periods like 5s or minute?

Integration into lm_sensors

Hello,
any chance to integrate the --measure command into lm_sensors? If the values like voltage, ampere and power became familiar to sensors, one could easily make nice looking realtime plots with KSysGuard for example.

adding ssh for remote overwatch

Hi!

It works perfectly with my voltcraft.
But i had an idea, would it be to difficult to add an ssh function?
For example:
./sem-6000.exp Voltcraft -r 192.168.0.1 --status --print

Why?
Example; A freebsd server, that has no bluetooth capabilities but still wants to serve energy consumption data to a webpage.
Thanks for great code!

Unable to Authenticate

I am using a Raspberry PI 3B

I Changed the PIN with the smartphone app to 1235

SEM6000 Firmware: 1.17

I used hcitool lescan to discover the mac address of the device

pi@raspberrypi:~ $ sudo hcitool lescan
LE Scan ...
FB:CB:A5:59:9F:40 LHB-EB49174B
FB:CB:A5:59:9F:40 (unknown)
8C:EA:48:FA:38:11 (unknown)
8C:EA:48:FA:38:11 [AV] Samsung Soundbar Q800A
1C:52:16:51:36:7D (unknown)
EB:21:9B:59:43:E1 LHB-415EF7F9
EB:21:9B:59:43:E1 (unknown)
41:F9:9E:FF:62:87 (unknown)
ED:29:F8:84:60:93 (unknown)
A3:00:00:00:1D:80 Voltcraft
A3:00:00:00:1D:80 Voltcraft

I setup the .known_sem6 file

pi@raspberrypi:~ $ cat .known_sem6
A3:00:00:00:1D:80 1235 test

I tried --sync but got the following result

pi@raspberrypi:~ $ ./sem-6000.exp test --verbose --sync
INFO:   Try to connect to A3:00:00:00:1D:80
INFO:   Connected to A3:00:00:00:1D:80
INFO:   Synchronize SEM
INFO:   >>>     char-write-req 2b 0f0c0100083a110e0c07e500005bffff
WARN:   Timeout. Notification not received
ERROR:  Notification invalid!
ERROR:  Checksum of notification invalid!
ERROR:  Synchronization of SEM failed
INFO:   Disconnect from A3:00:00:00:1D:80

I tried to retrieve the status

pi@raspberrypi:~ $ ./sem-6000.exp test --verbose --status
INFO:   Try to connect to A3:00:00:00:1D:80
INFO:   Connected to A3:00:00:00:1D:80
INFO:   Auth SEM
INFO:   >>>     char-write-req 2b 0f0c170000010203050000000023ffff
WARN:   Timeout. Notification not received
ERROR:  Notification invalid!
ERROR:  Checksum of notification invalid!
ERROR:  Authorization failed. Check PIN!
ERROR:  Authorization failed. Check PIN!

I looked through issue #9 and compared the gatt characteristics but they seem to differ

pi@raspberrypi:~ $ gatttool -b A3:00:00:00:1D:80 -I
[A3:00:00:00:1D:80][LE]> connect
Attempting to connect to A3:00:00:00:1D:80
Connection successful
[A3:00:00:00:1D:80][LE]> characteristics
handle: 0x0002, char properties: 0x0a, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, char properties: 0x0a, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0006, char properties: 0x02, char value handle: 0x0007, uuid: 00002a02-0000-1000-8000-00805f9b34fb
handle: 0x0008, char properties: 0x02, char value handle: 0x0009, uuid: 00002a04-0000-1000-8000-00805f9b34fb
handle: 0x000b, char properties: 0x22, char value handle: 0x000c, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x000f, char properties: 0x06, char value handle: 0x0010, uuid: 0000fff1-0000-1000-8000-00805f9b34fb
handle: 0x0011, char properties: 0x04, char value handle: 0x0012, uuid: 0000fff3-0000-1000-8000-00805f9b34fb
handle: 0x0013, char properties: 0x10, char value handle: 0x0014, uuid: 0000fff4-0000-1000-8000-00805f9b34fb
[A3:00:00:00:1D:80][LE]>

Is it possible that firmware 1.17 is incompatible with the script?
I can get data / control the device using the app without any problems.

Auth failed

Using the correct pin (set by smartphone) I still get:

root@pi01:~# ./sem-6000.exp vc1 --verbose --sync
INFO:   Try to connect to 50:51:A9:76:5E:89
INFO:   Connected to 50:51:A9:76:5E:89
INFO:   Synchronize SEM
INFO:   >>>     char-write-req 2b 0f0c01001e370e060707e400005dffff
INFO:   OK
INFO:   <<<     Notification handle = 0x2b value: 0f 04 01 00 00 02 ff ff 
INFO:   Response completed in terms of announced length and end sequence
INFO:   SEM successfully synchronized
INFO:   Disconnect from 50:51:A9:76:5E:89
root@pi01:~# ./sem-6000.exp vc1 --verbose --status
INFO:   Try to connect to 50:51:A9:76:5E:89
INFO:   Connected to 50:51:A9:76:5E:89
INFO:   Auth SEM
INFO:   >>>     char-write-req 2b 0f0c170000010203040000000022ffff
WARN:   Timeout. Notification not received
ERROR:  Notification invalid!
ERROR:  Checksum of notification invalid!
ERROR:  Authorization failed. Check PIN!
ERROR:  Authorization failed. Check PIN!

Any idea what could be wrong? The phone was not connected at the time anymore. Otherwise I would get "Connection failed".

Sending PIN is not needed for capturing measurement

By accident I found out that after opening the BLE connection to the Voltcraft you can directly transmit a Capture Measurement command and you will recieve a valid BLE notification containing actual values.

I tried and for other requests like setting the power switch/LED ring on/off you will receive a "Authorization invalid/missing PIN" BLE notification but for capture measurement it is just Capture measurement response 0x0400 BLE notification.

Edit: is there an easy way to account for this in the script?

Trying to understand the checksum calculation

Hi, I hope it's ok to ask this question via an 'issue', not sure where else I could ask :)

I'm trying to understand how the checksum calculation works.

I did find the section in your code where i believe it is being calculated. But I can't replicate the checksums given in your api documentation, which must be correct because the commands work.

from your code:

  # add payload and calculate checksum
  set sum 1
  foreach b $bytes {
    lappend full_req $b
    set sum [ expr $sum + [ scan $b %d ] ]
  }
  set sum [ expr $sum & 255 ]
  lappend full_req $sum

Given this example from your documentation
char-write-cmd 0x2b 0f0c170001010203040000000018ffff

My understanding is I have to take the part 0c1700010102030400000000 into account for the checksum calculation

I then loop over the individual bytes and add them to chksm and at the end I have to & 0xFF them, which should net me 0x18, however I'm getting 0x2F, with the following python example

data = bytearray.fromhex('0c1700010102030400000000')
chksm = 1
for d in data:
    chksm += d
print( hex(chksm & 0xff) )

Would be great if you could shine some light on this. I've looked at multiple repos and I can't figure it out :/

edit: After some more attempts: I haven't actually encountered a command that doesn't work when I calculate the checksum excl. the length byte, aside from some examples in your api documentation (e.g. the one above). My guess atm. is that in those cases the checksum is simply not correct in the documentation :?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.