The tool shows the measured values of the SMA Energymeter (or Sunny Home Manager), who transmits the values to the local network via multicast. Additionally you can export the data to a MQTT Broker or mySQL database.
I tested the tool with an Ubuntu 22.04 VM under Proxmox 7. Maybe you need some more steps to get it to work on other systems like RaspberryPi.
Comments and questions are welcome: smaemtool [at] planethell [dot] de.
Keep in mind I am not a software developer :)
Example output:
andreas@ds-logger:~$ ./smaemtool --break --mqtt --sql Version 1.0 Timestamp: 24.02.2023 16:19:22 Unix timestamp: 1677251962 Break set, running only once. MQTT set, export to MQTT enabled. SQL set, export to SQL enabled. Listening for multicast packets on 239.12.255.254:9522... Received 600 bytes from 192.168.0.124: Power Import: 492 W Power Export: 0 W Phase 1 Import: 88 W Phase 2 Import: 346 W Phase 3 Import: 57 W Phase 1 Export: 0 W Phase 2 Export: 0 W Phase 3 Export: 0 W Message sent to MQTT broker 192.168.0.60 on topic smaemtool. Starting SQL export to server 192.168.0.50, Database PV. Data successfully inserted into table smaemtool.
The output is the summary of the import/export power and the import/export power on each of the 3 phases.
As you can see, there are 3 command line parameters available:
Parameters for MQTT and SQL are stored in a config file (smaemtool.conf):
########################### ## MQTT ########################### mqtt-address=192.168.0.60 mqtt-clientid=smaemtool mqtt-topic=smaemtool ########################### ## mySQL ########################### sqlserver=192.168.0.50 sqldb=PV sqltable=smaemtool sqluser=sqluser sqlpw=sqlpassword
For the SQL part, you have to create a table to store the data:
-- CREATE TABLE `smaemtool` ( `id` int NOT NULL, `timestamp` int DEFAULT NULL, `imp` int DEFAULT NULL, `exp` int DEFAULT NULL, `L1imp` int DEFAULT NULL, `L2imp` int DEFAULT NULL, `L3imp` int DEFAULT NULL, `L1exp` int DEFAULT NULL, `L2exp` int DEFAULT NULL, `L3exp` int DEFAULT NULL, `date` datetime DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci; -- ALTER TABLE `smaemtool` ADD PRIMARY KEY (`id`); -- ALTER TABLE `smaemtool` MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
Install the packages and compile the source code:
sudo apt-get update sudo apt-get install build-essential libssl-dev libpaho-mqtt-dev sudo apt install libmysqlclient-dev gcc -o smaemtool smaemtool.c -lpaho-mqtt3c -lmysqlclientDownload the Sourcecode, Config file and binary as archive.
Binary was compiled for AMD64 on Ubuntu 22.04.1 LTS.