refactoring
This commit is contained in:
parent
e8938b3ae1
commit
386ae346a0
|
@ -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...");
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue