NEWS
MQTT-Adapter (Server/Client/…)
-
Okay das klappt glaube ich soweit.
Wie komme ich jetzt an die Daten?
void loop() { if (!client.connected()) { reconnect(); } client.loop(); long now = millis(); long duration, distance; // Distanzmessung if (now - lastMsg > 10000) { lastMsg = now; digitalWrite(TRIGGER, LOW); delayMicroseconds(2); digitalWrite(TRIGGER, HIGH); delayMicroseconds(10); digitalWrite(TRIGGER, LOW); duration = pulseIn(ECHO, HIGH); distance = (duration/2) / 29.1; String msg=""; char MsgEntfernung[25]; msg= distance; msg.toCharArray(MsgEntfernung,25); client.publish("Entfernung", MsgEntfernung); Serial.print(distance); Serial.println(" Centimeter aktuell:"); data = distance; delay(1000); server.handleClient(); } }
Die sehe ich im ioBroker unter Instanzen nämlich nicht.
mttq.0 –> info --> connections (mehr ist da nicht)?!
Danke
P-S- (der Log)
host.raspberrypi 2018-06-04 21:00:23.837 info Restart adapter system.adapter.mqtt.0 because enabled host.raspberrypi 2018-06-04 21:00:23.837 error instance system.adapter.mqtt.0 terminated with code 0 (OK) Caught 2018-06-04 21:00:23.837 error by controller[0]: port: 1883 } Caught 2018-06-04 21:00:23.836 error by controller[0]: address: '0.0.0.0', Caught 2018-06-04 21:00:23.836 error by controller[0]: syscall: 'listen', Caught 2018-06-04 21:00:23.836 error by controller[0]: errno: 'EADDRINUSE', Caught 2018-06-04 21:00:23.835 error by controller[0]: code: 'EADDRINUSE', Caught 2018-06-04 21:00:23.835 error by controller[0]: at process._tickCallback (internal/process/next_tick.js:104:9) Caught 2018-06-04 21:00:23.835 error by controller[0]: at _combinedTickCallback (internal/process/next_tick.js:83:11) Caught 2018-06-04 21:00:23.835 error by controller[0]: at net.js:1417:9 Caught 2018-06-04 21:00:23.834 error by controller[0]: at listen (net.js:1307:10) Caught 2018-06-04 21:00:23.834 error by controller[0]: at Server._listen2 (net.js:1271:14) Caught 2018-06-04 21:00:23.834 error by controller[0]: at exports._exceptionWithHostPort (util.js:1043:20) Caught 2018-06-04 21:00:23.833 error by controller[0]: at Object.exports._errnoException (util.js:1020:11) Caught 2018-06-04 21:00:23.832 error by controller[0]: { Error: listen EADDRINUSE 0.0.0.0:1883 mqtt.0 2018-06-04 21:00:23.791 info terminating mqtt.0 2018-06-04 21:00:23.269 error at process._tickCallback (internal/process/next_tick.js:104:9) mqtt.0 2018-06-04 21:00:23.269 error at _combinedTickCallback (internal/process/next_tick.js:83:11) mqtt.0 2018-06-04 21:00:23.269 error at net.js:1417:9 mqtt.0 2018-06-04 21:00:23.269 error at listen (net.js:1307:10) mqtt.0 2018-06-04 21:00:23.269 error at Server._listen2 (net.js:1271:14) mqtt.0 2018-06-04 21:00:23.269 error at exports._exceptionWithHostPort (util.js:1043:20) mqtt.0 2018-06-04 21:00:23.269 error at Object.exports._errnoException (util.js:1020:11) mqtt.0 2018-06-04 21:00:23.269 error Error: listen EADDRINUSE 0.0.0.0:1883 mqtt.0 2018-06-04 21:00:23.266 error uncaught exception: listen EADDRINUSE 0.0.0.0:1883 mqtt.0 2018-06-04 21:00:22.324 info starting. Version 1.5.0 in /opt/iobroker/node_modules/iobroker.mqtt, node: v6.14.2 host.raspberrypi 2018-06-04 21:00:20.827 info instance system.adapter.mqtt.0 started with pid 23821 host.raspberrypi 2018-06-04 21:00:08.568 info instance system.adapter.daswetter.0 terminated with code 0 (OK)
-
Hast du noch etwas auf dem port 1883 laufen?
Gruß Rainer
-
Nein
Nicht dass ich wüsste.
-
{ Error: listen EADDRINUSE 0.0.0.0:1883 `
Hast du ggf. den sonoff Adapter laufen, der baut auch auf mqtt auf und nutzt dessen port.Gruß
Rainer
-
Hi
ja Sonos läuft … hab jetzt den MQTT Server auf 1888 gesetzt und bekomme Connection failed mit rc=-2
-
-
ich meinte Sonoff ^^
der läuft … Port vom MQTT habe ich auf 1893 gesetzt und auch im Code geändert aber da tut sich nichts Keine Connection mit dem "Error" rc= -2
ioBroker:
mqtt.0 2018-06-05 13:30:49.442 info Starting MQTT server on port 1893 mqtt.0 2018-06-05 13:30:48.765 info starting. Version 1.5.0 in /opt/iobroker/node_modules/iobroker.mqtt, node: v6.14.2 host.raspberrypi 2018-06-05 13:30:47.327 info instance system.adapter.mqtt.0 started with pid 30301 host.raspberrypi 2018-06-05 13:30:45.334 info instance system.adapter.mqtt.0 terminated with code 0 (OK) mqtt.0 2018-06-05 13:30:45.312 info terminating host.raspberrypi 2018-06-05 13:30:44.793 info stopInstance system.adapter.mqtt.0 killing pid 30257 host.raspberrypi 2018-06-05 13:30:44.793 info stopInstance system.adapter.mqtt.0 host.raspberrypi 2018-06-05 13:30:44.792 info object change system.adapter.mqtt.0 host.raspberrypi 2018-06-05 13:30:08.652 info instance system.adapter.daswetter.0 terminated with code 0 (OK)
-
-
Im Device zeigt es mir das im Seriallog / Konsole
Serial.print("failed, rc="); Serial.print(client.state());
Was könnte noch eine Problemursache sein?
Hier die Passage aus dem Code:
Serial.print("Attempting MQTT connection..."); // Create a random client ID String clientId = "ESP8266ClientDistanzmessung"; //clientId += String(random(0xffff), HEX); // Attempt to connect if (client.connect(clientId.c_str(),userName,passWord)) //if (client.connect(clientId.c_str())) { Serial.println("connected"); //once connected to MQTT broker, subscribe command if any client.subscribe("OsoyooCommand"); } else { Serial.print("failed, rc="); Serial.print(client.state()); Serial.println(" try again in 5 seconds"); // Wait 6 seconds before retrying delay(6000); }
-
Das stand doch vorhin noch nicht alles da!
Serial.print("failed, rc="); Serial.print(client.state());
was bitte ist der state -2?
Gruß
Rainer
-
Das weiß ich nicht … hatte gehofft da kann mir jemand helfen.
Das ist was die NodeMCU ausspuckt wenn sie sich versucht mit dem ioBroker-mqtt Server Adapter zu verbinden