NEWS
NODEmcu K-Type Temp-Fühler in IObroker !? [gelöst]
-
@qax1 Dann zeig nochmal, aber erste Zeile frei lassen-> Return und dann erst Code-Tag (</>).
-
#include <Wire.h> #include <SPI.h> #include "Adafruit_MAX31855.h" #include <ESP8266WiFi.h> #include <MQTT.h> #define CLK 14 //connect CLK to GPIO14 #define CS 5 //connect CS to GPIO5 #define DO 12 //connect DO to GPIO12 #define client_name "SensorMAX" String MCUName = "SensorMax"; const char ssid[] = "xyz"; const char pass[] = "xxxxxxxxxxxxxxxxxxx"; String Nachricht_MQTT = ""; String Topic_MQTT = ""; Adafruit_MAX31855 thermocouple(CLK,CS,DO); WiFiClient net; MQTTClient client; void connect() { Serial.print("\nchecking wifi..."); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(1000); } Serial.print("\nconnecting..."); while (!client.connect(client_name,"MQTTUser","MQTTPassword")) { Serial.print("."); delay(1000); } Serial.print("\nconnected!"); client.subscribe(MCUName + "/+"); client.publish(MCUName + "/alive","true"); } void messageReceived(String &topic, String &payload) { Serial.println("MQTT incoming: " + topic + " - " + payload); Topic_MQTT = topic; Nachricht_MQTT = payload; topic = ""; payload = ""; } void setup() { Serial.begin(9600); Serial.println("MAX31855 testing"); delay(500); WiFi.begin(ssid, pass); client.begin("192.168.178.30",1883,net); //192.168.178.45 connect(); //alive wird gesendet client.onMessage(messageReceived); } void loop() { Serial.print("Internal Temp = "); Serial.println(thermocouple.readInternal()); delay(100); double c = thermocouple.readCelsius(); if (isnan(c)) { Serial.println("Something wrong with thermocouple!"); } else { Serial.print("C = "); Serial.println(c); client.publish(MCUName + "/InternalTemp",String(c)); } client.loop(); if (!client.connected()) { Serial.println("Neustart!"); delay(200); WiFi.begin(ssid, pass); client.begin("192.168.178.30",1883,net); connect(); //alive wird gesendet client.onMessage(messageReceived); client.publish(MCUName + "/connectProblem","Verbindungsproblem gehabt"); } delay(1000); }
-
@qax1 sagte in NODEmcu K-Type Temp-Fühler in IObroker !?:
while (!client.connect(client_name,"MQTTUser","MQTTPassword"))
Immer noch nicht geändert:
while (!client.connect(client_name,"MQTTUser","MQTTPassword")) -> while (!client.connect(client_name,"","")) -
@mcu sagte in NODEmcu K-Type Temp-Fühler in IObroker !?:
while (!client.connect(client_name,"",""))
Serial.print("\nconnecting..."); while (!client.connect(MCUName,"","")) { Serial.print("."); delay(1000);
so ?
-
@qax1
while (!client.connect(MCUName,"","")) {
dort nicht den client_name ersetzen!while (!client.connect(client_name,"",""))
-
Serial.print("\nconnecting..."); while (!client.connect(client_name,"","")) { Serial.print("."); delay(1000);
ok
-
@qax1 Dann lass mal laufen. Kommt im ioBroker MQTT was an?
Sonst zeige die Einstellungen zum MQTT-Adapter.
Meine sind:
-
Sau Geil es läuft....
Ich kann dir gar nicht genug Danken....
Das hätte ich alleine wohl nie hinbekommen -
Und dann bitte im ersten Post die Überschrift anpassen [gelöst] NODEmcu....
-