Skip to content
SBF edited this page Jul 25, 2021 · 4 revisions

Quick reference for SBFspot MQTT

Install latest SBFspot version (V3.6.0 or higher will work)

Install MQTT broker (optional if you have already a broker running)

sudo apt-get -y install mosquitto

Install mosquitto_sub and mosquitto_pub clients (mandatory - dependency for SBFspot)

sudo apt-get -y install mosquitto-clients

Modify SBFspot.cfg (see example file in source folder)

#########################
###   MQTT Settings   ###
#########################

# Full path to mosquitto_pub executable
# Linux: sudo apt-get install mosquitto-clients
MQTT_Publisher=/usr/bin/mosquitto_pub

# Windows: Download and install mosquitto clients from https://mosquitto.org/download/
# Mosquitto 64-bit on Windows 64-bit
# MQTT_Publisher=%ProgramW6432%\\mosquitto\\mosquitto_pub.exe

# Mosquitto 32-bit on Windows 32-bit
# MQTT_Publisher=%ProgramFiles%\\mosquitto\\mosquitto_pub.exe

# IP address or DNS name of MQTT Broker
# Don't use test broker for production environments
MQTT_Host=test.mosquitto.org
# MQTT_Host=broker.hivemq.com

# Port (Optional)
#MQTT_Port=

# Topic Name
# When using public broker like test.mosquitto.org make sure to define a unique topic name
# by appending the serial number of the inverter to avoid you receive data of another SBFspot user. 
MQTT_Topic=sbfspot_{serial}

# Format of message items to be sent
# JSON: MQTT_ItemFormat="{key}": {value}
# TEXT: MQTT_ItemFormat={key}:{value}
# XML:  MQTT_ItemFormat=<item name="{key}" value="{value}" />
MQTT_ItemFormat="{key}": {value}

# MQTT_ItemDelimiter (none|blank|comma|semicolon default comma)
# JSON: MQTT_ItemDelimiter=comma
# TEXT: MQTT_ItemDelimiter=semicolon
# XML : MQTT_ItemDelimiter=none
MQTT_ItemDelimiter=comma

# Mandatory arguments for mosquitto_pub executable
# JSON: MQTT_PublisherArgs=-h {host} -t {topic} -m "{{message}}"
# TEXT: MQTT_PublisherArgs=-h {host} -t {topic} -m "{message}"
# XML : MQTT_PublisherArgs=-h {host} -t {topic} -m "<mqtt_message>{message}</mqtt_message>"
MQTT_PublisherArgs=-h {host} -t {topic} -m "{{message}}"

# Data to be published (comma delimited)
MQTT_Data=Timestamp,SunRise,SunSet,InvSerial,InvName,InvTime,InvStatus,InvTemperature,InvGridRelay,EToday,ETotal,PACTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2

Possible keywords are (if supported by your inverter):

SBFspot Alias Code Description
Timestamp Current date/time
InvTime Inverter date/time
SunRise Sunrise time
SunSet Sunset time
InvSerial Serial Number
InvName NameplateLocation Device name
InvClass NameplateMainModel Device class
InvType NameplateModel Device type
InvSwVer NameplatePkgRev Software package
InvStatus OperationHealth Condition
InvTemperature CoolsysTmpNom Operating condition temperatures
InvGridRelay OperationGriSwStt Grid relay/contactor
ETotal MeteringTotWhOut Total yield
EToday MeteringDyWhOut Day yield
PACTot GridMsTotW Power
PDC1/PDC2 DcMsWatt DC power input String 1/2
UDC1/UDC2 DcMsVol DC voltage input String 1/2
IDC1/IDC2 DcMsAmp DC current input String 1/2
OperTm MeteringTotOpTms Operating time
FeedTm MeteringTotFeedTms Feed-in time
PAC1 GridMsWphsA Power L1
PAC3 GridMsWphsC Power L3
UAC1 GridMsPhVphsA Grid voltage phase L1
UAC2 GridMsPhVphsB Grid voltage phase L2
PAC2 GridMsWphsB Power L2
UAC3 GridMsPhVphsC Grid voltage phase L3
IAC1 GridMsAphsA_1 Grid current phase L1
IAC2 GridMsAphsB_1 Grid current phase L2
IAC3 GridMsAphsC_1 Grid current phase L3
GridFreq GridMsHz Grid frequency
BatTmpVal BatTmpVal Battery temperature
BatVol BatVol Battery voltage
BatAmp BatAmp Battery current
BatChaStt BatChaStt Current battery charge status

Subscribe to 'sbfspot' topic

mosquitto_sub -d -h test.mosquitto.org -t sbfspot
Client mosqsub|24333-sbfspot sending CONNECT
Client mosqsub|24333-sbfspot received CONNACK (0)
Client mosqsub|24333-sbfspot sending SUBSCRIBE (Mid: 1, Topic: sbfspot, QoS: 0)
Client mosqsub|24333-sbfspot received SUBACK
Subscribed (mid: 1): 0

⭐️ 2019-AUG-01: For the moment I can't connect to test.mosquitto.org
Here's another one: broker.hivemq.com

❗️ Warning: In this example I use a public test broker. Don't use this in production. When using this public broker, use a unique topic (e.g. sbfspot_210027**** where 210027**** is your inverter serial number)

Run SBFspot

./SBFspot -v5 -mqtt

Enable MQTT on existing configuration

Add -mqtt switch to /usr/local/bin/sbfspot.3/daydata

/usr/local/bin/sbfspot.3/daydata -mqtt

Or edit daydata script

#!/bin/bash
#
log=/home/pi/smadata/logs/MyPlant_$(date '+%Y%m%d').log
/usr/local/bin/sbfspot.3/SBFspot -v -ad1 -am0 -ae0 -mqtt -cfg/usr/local/bin/sbfspot.3/SBFspot.cfg $1 $2 $3 $4 $5 &>>$log
Client mosqsub|24333-sbfspot received PUBLISH (d0, q0, r0, m0, 'sbfspot', ... (257 bytes))
Timestamp:29/07/2019 12:06:09;InvSerial:210027****;InvName:SB4000TL - 210027****;InvStatus:Ok;InvTemperature:46.730;InvGridRelay:Closed;EToday:3.134;ETotal:35584.849;PACTot:2153.000;UDC1:337.180;UDC2:164.320;IDC1:4.488;IDC2:4.431;PDC1:1513.000;PDC2:727.000;