/* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ #include #include #include #include #include String matrixausgabe_text = " "; // Ausgabetext als globale Variable volatile int matrixausgabe_index = 0;// aktuelle Position in Matrix IPAddress myOwnIP; // ownIP for mDNS //-------------- definition mqtt-object ueber WiFi WiFiClient espClient; PubSubClient mqttclient(espClient); //--------- list of mqtt callback functions #define MAX_MQTT_SUB 10 // maximal 10 subscriptions erlaubt typedef void (*mqtthandle) (byte*,unsigned int); typedef struct { // Typdeklaration Callback String topic; // mqtt-topic mqtthandle fun; // callback function } subscribe_type; subscribe_type mqtt_sub[MAX_MQTT_SUB]; int mqtt_sub_count=0; String MQTT_Rx_Payload = "" ; //--------- mqtt callback function void mqttcallback(char* to, byte* pay, unsigned int len) { String topic = String(to); String payload = String((char*)pay); MQTT_Rx_Payload=payload.substring(0,len); Serial.println("\ncallback topic:" + topic + ", payload:" + MQTT_Rx_Payload); for (int i=0;i ( 700 ) )) { pixels.setPixelColor(0,30,30,0,0); pixels.show(); if (( ( co2 ) > ( 1000 ) )) { pixels.setPixelColor(0,40,0,0,0); pixels.show(); } } else { } } delay( 1000 ); mqttreconnect(); { String pay=String(String(co2)); mqttclient.publish("sensor/CO2",pay.c_str()); Serial.print("\nmqtt publish: "); Serial.print(pay); }; mqttreconnect(); { String pay=String(String(temp)); mqttclient.publish("sensor/temp",pay.c_str()); Serial.print("\nmqtt publish: "); Serial.print(pay); }; mqttreconnect(); { String pay=String(String(hum)); mqttclient.publish("sensor/hum",pay.c_str()); Serial.print("\nmqtt publish: "); Serial.print(pay); }; delay( 6000 ); }