Skip to content

Commit

Permalink
feat: 🎨 send hydrometer id and password to MQTT
Browse files Browse the repository at this point in the history
  • Loading branch information
Vini7Dev committed Jul 6, 2023
1 parent b9548b3 commit 2e1f1e3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions hydrometer/hydrometer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const char* mqtt_username = "MQTT_USERNAME";
const char* mqtt_password = "MQTT_PASSWORD";
const int mqtt_port = 1883;

const int HYROMETER_ID = 1;
const char* HYDROMETER_PASSWORD = "example";

WiFiClient espClient;
PubSubClient client(espClient);

Expand Down Expand Up @@ -89,9 +92,9 @@ void sendDataToMQTT() {
}
client.loop();

char msg[10];
sprintf(msg, "%.2f", flowRate);
client.publish("createConsumptionMarking", msg);
String message = String(HYROMETER_ID) + "|" + HYDROMETER_PASSWORD + "|" + String(flowRate);
client.publish("createConsumptionMarking", message.c_str());

delay(5000);
}

Expand Down

0 comments on commit 2e1f1e3

Please sign in to comment.