diff --git a/MQTT-Remote-BME680.ino b/MQTT-Remote-BME680.ino new file mode 100644 index 0000000..c6923bf --- /dev/null +++ b/MQTT-Remote-BME680.ino @@ -0,0 +1,255 @@ +* 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 +#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