![]() |
rasProject_01 / weSweetHome
R. 146 2026-09-26
process control / RasPi software by weinert-automation
|
MQTT related definitions for an experimental smart home (lab) project. More...
#include <mosquitto.h>Macros | |
| #define | SUBTOP_I |
| Length of base topic including trailing /. | |
Functions | |
| void | mqttClean () |
| End as MQTT client. | |
| int | mqttInit () |
| Initialise as MQTT client. | |
| void | mqttPlg01Set (uint8_t const on) |
| Switch the plug Plug01. | |
| void | mqttPlg02Set (uint8_t const on) |
| Switch the plug PLG2. | |
| void | mqttPlg03Set (uint8_t const on) |
| Switch the plug PLG3. | |
| void | mqttPlg04Set (uint8_t const on) |
| Switch the plug PLG4. | |
Variables | |
| char | clientId [38] |
| MQTT client ID. | |
| char | messCmdOffPlg [4] |
| Message to turn a S20 plug off. | |
| char | messCmdOnPlg [4] |
| Message to turn a S20 plug on. | |
| char | messSttOffPlg [6] |
| State message: a S20 plug is now off. | |
| char | messSttOnPlg [6] |
| State message: a S20 plug is now on. | |
| struct mosquitto * | mosq |
| MQTT interface state. | |
| int | mosqLoopError |
| Return value of mosquitto_loop. | |
| char | mqttHost [68] |
| MQTT broker address or name. | |
| int | mqttPort |
| MQTT broker port. | |
| char const | subTopBatU [10] |
| Relative topic to subscribe Ubat (bat/volt). | |
| char const | subTopEco3 [14] |
| Relative topic for topic for EcoWorthy BT readings. | |
| char const | subTopGrow [14] |
| Relative topic for Growatt readings. | |
| char | subTopStPlg01 [14] |
| State sub topic of S20 plug Number 01 to 09. | |
| char const | topicSubs [20] |
| The MQTT topic to subscribe to. | |
MQTT related definitions for an experimental smart home (lab) project.
MQTT is used to control relay devices like Sonoff S20 switchable plugs with Tasmota and to communicate battery and inverter values got by Bluetooth respectively Modbus by dedicated controllers.
Revision history
| #define SUBTOP_I |
| void mqttPlg01Set | ( | uint8_t const | on | ) |
Switch the plug Plug01.
This function publishes the switch command via MQTT to the relay device Plug01, usually a Sonoff S20 with Tasmota.
| on | switch on when true, else off |
| void mqttPlg02Set | ( | uint8_t const | on | ) |
Switch the plug PLG2.
See mqttPlg01Set
| void mqttPlg03Set | ( | uint8_t const | on | ) |
Switch the plug PLG3.
See mqttPlg01Set
| void mqttPlg04Set | ( | uint8_t const | on | ) |
Switch the plug PLG4.
See mqttPlg01Set
| int mqttInit | ( | ) |
Initialise as MQTT client.
On success only: subscribe, loop and publish.
| void mqttClean | ( | ) |
|
extern |
|
extern |
|
extern |
|
extern |
Relative topic to subscribe Ubat (bat/volt).
Hardware setup: (old) ESP with ADU. The EcoWorthy Bluetooth (BT) value subTopEco3 gets precedence when available.
|
extern |
Relative topic for Growatt readings.
|
extern |
Relative topic for topic for EcoWorthy BT readings.
Hardware setup 2026: M5Stamp S3; software platformIO
|
extern |
Message to turn a S20 plug on.
|
extern |
Message to turn a S20 plug off.
|
extern |
State sub topic of S20 plug Number 01 to 09.
It's preset as plug01/POWER for 01, but the digit at index [5] will be set before each use accordingly.
|
extern |
State message: a S20 plug is now on.
|
extern |
State message: a S20 plug is now off.
|
extern |
MQTT interface state.
Defined in <mosquitto.h> without description. MQTT interface (state)
|
extern |
MQTT client ID.
default value: sweetHomeControl; length: 15; max. length: 36
May be changed before mqttInit().