Skip to content

Commit

Permalink
change MQTT message structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Techbeard committed Jul 3, 2024
1 parent 7d19ec2 commit 44cc056
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions software/src/janitza.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ JsonDocument Janitza::generateJson() {

if (regDef->phaseTag != P_NONE) {
const char *phaseStr = phaseTagStr[regDef->phaseTag];
doc["values"][regDef->nameStr][phaseStr] = val;
doc["Values"][regDef->nameStr][phaseStr] = val;
}
else {
doc["values"][regDef->nameStr] = val;
doc["Values"][regDef->nameStr] = val;
}
}

Expand Down
9 changes: 6 additions & 3 deletions software/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ void setup() {
DBG.begin(115200);
DBG.println("\nJanitza UMG96RM Power Analyzer to Influx\n");
MODUBS_SERIAL.begin(MODBUS_BAUD);

initEthernet();
connectEthernet();
mqttInit();

janitza.setDebugSerial(DBG);
janitza.useRS485(MODBUS_DE_PIN, MODBUS_RE_PIN, preTransmission, postTransmission);
#if USE_INFLUXDB
Expand All @@ -77,9 +82,6 @@ void setup() {

// janitza.read();

initEthernet();
connectEthernet();
mqttInit();
}

uint32_t lastUpdate = 0;
Expand All @@ -99,6 +101,7 @@ void loop () {
size_t len = serializeJson(doc, buf);
String topic = MQTT_BASE_TOPIC;
topic += String(janitza.getSerialNumber());
topic += "/json";
mqttPublish(topic.c_str(), buf, len);
}
#endif
Expand Down

0 comments on commit 44cc056

Please sign in to comment.