diff options
author | Joe Robinson <joe@lc8n.com> | 2019-02-19 23:25:51 +0000 |
---|---|---|
committer | Joe Robinson <joe@lc8n.com> | 2019-02-19 23:25:51 +0000 |
commit | 8a6cbc16c200faa926671a6c69df2775983410ee (patch) | |
tree | c7e98e71b0f26e382ea45ef907bbbe9e02805ab2 | |
parent | c4b62abe473716dc004a19bbb48b382bac80d601 (diff) |
Build topic from ID
-rw-r--r-- | cricket.ino | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/cricket.ino b/cricket.ino index 0166db5..a78091d 100644 --- a/cricket.ino +++ b/cricket.ino @@ -87,9 +87,15 @@ void loop() { connectMqtt(); } dtostrf(t, 1, 2, t_msg); - mqttClient.publish("cricket1/temperature", t_msg); dtostrf(h, 1, 2, h_msg); - mqttClient.publish("cricket1/humidity", h_msg); dtostrf(m, 1, 2, m_msg); - mqttClient.publish("cricket1/moisture", m_msg); + char temp_topic[20]; + char humidity_topic[20]; + char moisture_topic[20]; + sprintf(temp_topic, "%s/temperature", MQTT_ID); + sprintf(humidity_topic, "%s/humidity", MQTT_ID); + sprintf(moisture_topic, "%s/moisture", MQTT_ID); + mqttClient.publish(temp_topic, t_msg); + mqttClient.publish(humidity_topic, h_msg); + mqttClient.publish(moisture_topic, m_msg); } |