// Publish our message void publishMessage() { if (mqtt->getConnectionState() != eTCS_Connected) startMqttClient(); // Auto reconnect mqtt->publish(mqtt_client + "/Status", "Online"); // or publishWithQoS }
void publishBMP() { if (mqtt.getConnectionState() != eTCS_Connected) startMqttClient(); // Auto reconnect Serial.print("*********************************************"); Serial.println("Start reading BMP180 sensor"); if (!barometer.EnsureConnected()) { Serial.println("Could not connect to BMP180"); } else { // Retrive the current pressure in Pascals long currentPressure = barometer.GetPressure(); // convert pressure to mmHg float BMPPress = currentPressure / 133.322; // Print out the Pressure Serial.print("Pressure: "); Serial.print(BMPPress); Serial.println(" mmHg"); mqtt.publish(BMP_P, String(BMPPress)); // Retrive the current temperature in degrees celcius float BMPTemp = barometer.GetTemperature(); // Print out the Temperature Serial.print("Temperature: "); Serial.print(BMPTemp); Serial.println(" *C"); mqtt.publish(BMP_T, String(BMPTemp)); Serial.println("BMP180 sensor read and transmitted to server"); Serial.println("*********************************************"); } }
// MQTT : Publish our message void publishMessage() { if (mqtt.getConnectionState() != eTCS_Connected) { startMqttClient(); // Auto reconnect return; } // Read DHT22 TempAndHumidity th; if(!dht.readTempAndHumidity(th)) { return; } // Make JSON data String message = "{\"temp\":"; message += th.temp; message += ", \"humi\":"; message += th.humid; message += "}"; // publish message Serial.println("Let's publish message now!"); mqtt.publish("home/thirdroom/temp_humi", message, true); // retained message displayTemp(message); }
// Publish our message void publishMessage() { if (mqtt.getConnectionState() != eTCS_Connected) startMqttClient(); // Auto reconnect Serial.println("Let's publish message now!"); mqtt.publish("main/frameworks/sming", "Hello friends, from Internet of things :)"); // or publishWithQoS }
// Will be called when WiFi station was connected to AP void connectOk() { Serial.println("I'm CONNECTED"); // Run MQTT client startMqttClient(); // Start publishing loop procTimer.initializeMs(20 * 1000, publishMessage).start(); // every 20 seconds }
// Publish our message void publishMessage() { if (mqtt->getConnectionState() != eTCS_Connected) startMqttClient(); // Auto reconnect Serial.println("Let's publish message now!"); mqtt->publish("main/frameworks/sming", "Hello friends, from Internet of things :)"); mqtt->publishWithQoS("important/frameworks/sming", "Request Return Delivery", 1, false, onMessageDelivered); // or publishWithQoS }
// Will be called when WiFi station was connected to AP void connectOk() { Serial.println("I'm CONNECTED"); // ntpDemo = new ntpClientDemo(); // Run MQTT client startMqttClient(); WifiAccessPoint.enable(false); // Start publishing loop procTimer.initializeMs(20 * 1000, publishMessage).start(); // every 20 seconds }
// Will be called when WiFi station was connected to AP void connectOk() { Serial.println("I'm CONNECTED"); displayText("I'm CONNECTED to AP"); // Run MQTT client startMqttClient(); // Start publishing loop procTimer.initializeMs(60*1000, publishMessage).start(); }
/** * WiFi station connected to AP */ void connectOk() { // Waiting for smart-config state LINK_OVER if (smartConfigActive) return; debugf("I'm CONNECTED"); Serial.println(WifiStation.getIP().toString()); blinkStop(); // run MQTT client startMqttClient(); mqttPublish("CONNECTED"); blinkGreenStart(500, -1); }