NEWS
NODEmcu K-Type Temp-Fühler in IObroker !? [gelöst]
-
@qax1 Im Dokumente/arduino werden alle Dateien zum Arduino gespeichert:
-
Ah... Ok... gefunden...
Was davon jetzt wohin kopieren ?
Was meinst du mit "Mein Projekt" ?Sorry bin halt absoluter Anfänger...
-
-
Ich hab das MQTT ersetzten jetzt so verstanden......
-
@qax1
Punkt hinter dem "h" ist falsch.
Ansonsten nimm meine MQTT.h -
Du musst das Semikolon hier entfernen nach dem define:
-
Jetzt kommt der Fehler :
Arduino: 1.8.13 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, WIFI, Only Sketch, 115200"
MQTT-TEST-1:25:1: error: 'MQTTClient' does not name a type
MQTTClient client;
^
C:\Users\Stefan\Documents\Arduino\MQTT-TEST-1\MQTT-TEST-1.ino: In function 'void connect()':
MQTT-TEST-1:34:12: error: 'client' was not declared in this scope
while (!client.connect(client_name,"MQTTUser","MQTTPassword")) { ^
MQTT-TEST-1:40:4: error: 'client' was not declared in this scope
client.subscribe(client_name + "/+"); ^
MQTT-TEST-1:40:35: error: invalid operands of types 'const char [10]' and 'const char [3]' to binary 'operator+'
client.subscribe(client_name + "/+"); ^
MQTT-TEST-1:41:33: error: invalid operands of types 'const char [10]' and 'const char [7]' to binary 'operator+'
client.publish(client_name + "/alive","true"); ^
C:\Users\Stefan\Documents\Arduino\MQTT-TEST-1\MQTT-TEST-1.ino: In function 'void setup()':
MQTT-TEST-1:59:2: error: 'client' was not declared in this scope
client.begin("http://192.168.178.30",1883,net); //192.168.178.45
^
C:\Users\Stefan\Documents\Arduino\MQTT-TEST-1\MQTT-TEST-1.ino: In function 'void loop()':
MQTT-TEST-1:75:5: error: 'client' was not declared in this scope
client.publish(client_name + "/InternalTemp",String(c)); ^
MQTT-TEST-1:75:34: error: invalid operands of types 'const char [10]' and 'const char [14]' to binary 'operator+'
client.publish(client_name + "/InternalTemp",String(c)); ^
MQTT-TEST-1:77:3: error: 'client' was not declared in this scope
client.loop();
^
MQTT-TEST-1:81:6: error: 'werteCount' was not declared in this scope
werteCount = 0; ^
MQTT-TEST-1:86:35: error: invalid operands of types 'const char [10]' and 'const char [16]' to binary 'operator+'
client.publish(client_name + "/connectProblem","Verbindungsproblem gehabt"); ^
exit status 1
'MQTTClient' does not name a type
Dieser Bericht wäre detaillierter, wenn die Option
"Ausführliche Ausgabe während der Kompilierung"
in Datei -> Voreinstellungen aktiviert wäre. -
@qax1 Hast du jetzt meine MQTT genutzt? Und hast du das Semikolon entfernt?
Hier darf nur die IP stehen:
Also http:// weg -
Ich habe den PUNKT hinter dem h
und den Semikolon weg gemacht. -
@qax1 Dann entpack jetzt die Datei MQTT.7z und schieb den Ordner MQTT dann in Dokumente/Arduino.
Und danach oben wieder auf MQTT.h ändern. -
@mcu
Ok... erledigt... jetzt kommt :Arduino: 1.8.13 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, WIFI, Only Sketch, 115200"
C:\Users\Stefan\Documents\Arduino\MQTT-TEST-1\MQTT-TEST-1.ino: In function 'void connect()':
MQTT-TEST-1:40:35: error: invalid operands of types 'const char [10]' and 'const char [3]' to binary 'operator+'
client.subscribe(client_name + "/+"); ^
MQTT-TEST-1:41:33: error: invalid operands of types 'const char [10]' and 'const char [7]' to binary 'operator+'
client.publish(client_name + "/alive","true"); ^
C:\Users\Stefan\Documents\Arduino\MQTT-TEST-1\MQTT-TEST-1.ino: In function 'void loop()':
MQTT-TEST-1:75:34: error: invalid operands of types 'const char [10]' and 'const char [14]' to binary 'operator+'
client.publish(client_name + "/InternalTemp",String(c)); ^
MQTT-TEST-1:81:6: error: 'werteCount' was not declared in this scope
werteCount = 0; ^
MQTT-TEST-1:86:35: error: invalid operands of types 'const char [10]' and 'const char [16]' to binary 'operator+'
client.publish(client_name + "/connectProblem","Verbindungsproblem gehabt"); ^
exit status 1
invalid operands of types 'const char [10]' and 'const char [3]' to binary 'operator+'
Dieser Bericht wäre detaillierter, wenn die Option
"Ausführliche Ausgabe während der Kompilierung"
in Datei -> Voreinstellungen aktiviert wäre. -
Ich weiß nicht ob s was zu sagen hat,
aber ich habe in IObroker im MQTT-Adapter
keinen Namen / Passwort vergeben. -
@mcu Eins nachdem anderen:
- String MCUName = "SensorMax"; einfügen nach #define client_name
- werteCount = 0; Zeile komplett löschen
- bei client.subscribe(client_name : client_name durch MCUName ersetzen
- und bei allen client.publish(client_name : client_name durch MCUName ersetzen
- beim client.connect"MQTTUser","MQTTPassword" -> "",""
-
Komplieren läuft jetzt komplett durch... -
@qax1 Dann schick mir mal das komplette Script.
-
@mcu ```
#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[] = "xxxxxxxxxxxxxxxxx";
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("http://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 !?:
Serial.print("\nconnecting...");
while (!client.connect(client_name,"MQTTUser","MQTTPassword")) {Serial.print("\nconnecting..."); while (!client.connect(client_name,"MQTTUser","MQTTPassword")) {
noch ändern -> "",""
Code-tags - erste Zeile frei lassen , sonst versteht er das nicht.
client.begin("http://192.168.178.30",1883,net); ->client.begin("192.168.178.30",1883,net);
das http:// entfernen -
@mcu
Ok... erledigt -
@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); }