From 386ae346a0f8acf1fd1084ea6be7889092e189bc Mon Sep 17 00:00:00 2001 From: simonox Date: Mon, 20 Feb 2023 16:29:53 +0100 Subject: [PATCH] refactoring --- .../02-energy-monitor-mqtt/02-energy-monitor-mqtt.ino | 6 +++--- software/firmware/energy-montior/README.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/software/firmware/energy-montior/02-energy-monitor-mqtt/02-energy-monitor-mqtt.ino b/software/firmware/energy-montior/02-energy-monitor-mqtt/02-energy-monitor-mqtt.ino index cf5d087..6510f5c 100644 --- a/software/firmware/energy-montior/02-energy-monitor-mqtt/02-energy-monitor-mqtt.ino +++ b/software/firmware/energy-montior/02-energy-monitor-mqtt/02-energy-monitor-mqtt.ino @@ -33,8 +33,7 @@ void setup() { Serial.setTimeout(500); setup_energy_sensor(); setup_wifi(); - client.setServer(mqttServer, mqttPort); - reconnect(); + setup_mqtt(); } void setup_energy_sensor() { @@ -59,7 +58,8 @@ void setup_wifi() { Serial.println(WiFi.localIP()); } -void reconnect() { +void setup_mqtt() { + client.setServer(mqttServer, mqttPort); // Loop until we're reconnected while (!client.connected()) { Serial.print("Attempting MQTT connection..."); diff --git a/software/firmware/energy-montior/README.md b/software/firmware/energy-montior/README.md index a280486..af2dc1c 100644 --- a/software/firmware/energy-montior/README.md +++ b/software/firmware/energy-montior/README.md @@ -100,7 +100,7 @@ docker-compose --file software/container/docker-compose.yml up ##### Credentials -To connect to your wifi and access your MQTT server you have to add this to an `environment` [header file](./02-energy-monitor-mqtt/environment.h): +To connect to your Wifi and access your MQTT server you have to add this to an `environment` [header file](./02-energy-monitor-mqtt/environment.h): ```C // Replace with your network credentials @@ -134,7 +134,7 @@ Posting to MQTT is quite simple. After setting up Wifi and connection to the MQT client.publish(concat(mqttPrefix, "/ampere"), irmsArray); ``` -Have a look at the complete [exampe](./02-energy-monitor-mqtt/). +Have a look at the complete [example](./02-energy-monitor-mqtt/). ## Links