|
@ -72,7 +72,7 @@ uint32_t lastTransmit = 0; |
|
|
//Variables for the mqtt packages and topics
|
|
|
//Variables for the mqtt packages and topics
|
|
|
String commandTopic; |
|
|
String commandTopic; |
|
|
String bme280Topic; |
|
|
String bme280Topic; |
|
|
String batteryTopic; |
|
|
String statusTopic; |
|
|
|
|
|
|
|
|
void setup() { |
|
|
void setup() { |
|
|
// gpio configuration
|
|
|
// gpio configuration
|
|
@ -90,7 +90,7 @@ void setup() { |
|
|
//Configure the MQTT topics
|
|
|
//Configure the MQTT topics
|
|
|
commandTopic = "esp32-node/cmd/" + iot.hostname + "/play"; |
|
|
commandTopic = "esp32-node/cmd/" + iot.hostname + "/play"; |
|
|
bme280Topic = "esp32-node/stat/" + iot.hostname + "/bme280"; |
|
|
bme280Topic = "esp32-node/stat/" + iot.hostname + "/bme280"; |
|
|
batteryTopic = "esp32-node/stat/" + iot.hostname + "/battery"; |
|
|
statusTopic = "esp32-node/stat/" + iot.hostname + "/status"; |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
//Use the web object to add elements to the interface
|
|
|
//Use the web object to add elements to the interface
|
|
@ -251,10 +251,15 @@ void transmitStatus() { |
|
|
uint16_t statusPacketIdSub; |
|
|
uint16_t statusPacketIdSub; |
|
|
statusPacketIdSub = iot.mqtt.publish(bme280Topic.c_str(), 0, false, sensorBuf); |
|
|
statusPacketIdSub = iot.mqtt.publish(bme280Topic.c_str(), 0, false, sensorBuf); |
|
|
// statusPacketIdSub = iot.mqtt.publish(bme280Topic.c_str(), 1, true, sensorBuf);
|
|
|
// statusPacketIdSub = iot.mqtt.publish(bme280Topic.c_str(), 1, true, sensorBuf);
|
|
|
int voltage = rom_phy_get_vdd33(); |
|
|
|
|
|
char batteryBuf[9]; |
|
|
StaticJsonBuffer<200> jsonBuffer2; |
|
|
sprintf(batteryBuf, "%d", voltage); |
|
|
JsonObject& root2 = jsonBuffer2.createObject(); |
|
|
statusPacketIdSub = iot.mqtt.publish(batteryTopic.c_str(), 0, false, batteryBuf); |
|
|
root2["voltage"] = rom_phy_get_vdd33(); |
|
|
|
|
|
root2["rssi"] = WiFi.RSSI(); |
|
|
|
|
|
root2["heap"] = ESP.getFreeHeap(); |
|
|
|
|
|
char statusBuf[root2.measureLength()+1]; |
|
|
|
|
|
root2.printTo(sensorBuf, sizeof(sensorBuf)); |
|
|
|
|
|
statusPacketIdSub = iot.mqtt.publish(statusTopic.c_str(), 0, false, statusBuf); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|