From b479790cda3252d5a12597d12eb6a9fc17dbdeab Mon Sep 17 00:00:00 2001 From: Joachim Hummel Date: Sun, 11 Oct 2020 11:53:08 +0000 Subject: [PATCH] Added INO-File --- MQTT-Remote-BME680.ino | 255 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 MQTT-Remote-BME680.ino 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