Hallo,
Ich bin neu hier und es tut mir leid wenn ich euch nicht ausreichend Informationen gebe um mir zu helfen, ich gebe mein bestes.
Ich benutze:
ESP32-WROOM-32, von AZ-Delivery
Arduino IDE 1.8.15
Mit meinem Code möchte ich nur eine LED über MQTT ansteuern, dies funktionert auch, jedoch gibt der Serial Monitor nicht den Status, sondern folgende Fehlermeldung an:
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:10944
load:0x40080400,len:6388
entry 0x400806b4
Diese, oder eine ähnliche Nachricht wirft er mir dauerhaft raus. Für den jetztigen Stand des Projekts ist das nicht weiter störend, aber später habe ich so Probleme beim Fehler Finden und Beheben.
Danke schon mal im Voraus
Mein Code ist wie folgt:
#include <WiFi.h>
#include <PubSubClient.h>
#include <Wire.h>
const char* ssid = "MySSID";
const char* password = "MyPassword";
// My MQTT Broker
const char* mqtt_server = "bla.bla.bla.bla";
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;
// LED Pin
const int ledPin = 12;
void setup() {
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
pinMode(ledPin, OUTPUT);
}
void setup_wifi() {
delay(10);
// Connecting to WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void callback(char* topic, byte* message, unsigned int length) {
Serial.print("Message arrived on topic: ");
Serial.print(topic);
Serial.print(". Message: ");
String messageTemp;
for (int i = 0; i < length; i++) {
Serial.print((char)message[i]);
messageTemp += (char)message[i];
}
Serial.println();
// If a message is received on the topic esp32/output, you check if the message is either "on" or "off".
// Changes the output state according to the message
if (String(topic) == "esp32/output") { // esp32/output
Serial.print("Changing output to ");
if(messageTemp == "1"){
Serial.println("on");
digitalWrite(ledPin, HIGH);
}
else if(messageTemp == "0"){
Serial.println("off");
digitalWrite(ledPin, LOW);
}
}
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("ESP8266Client")) {
Serial.println("connected");
// Subscribe
client.subscribe("esp32/output");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
}
Zusammenfassung
Dieser Text wird ausgeblendet