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