Re: Second NodeMCU ESP8266 powered up, NEITHER sends reading
Posted: Sat Jun 02, 2018 8:44 am
Each ESP must use a unique MQTT client name. mosquitto disconnects clients with duplicate names. In the current code, "ESP8266Client" is used for all clients.
See the latest pubsubclient ESP example which generates a random client name for every connection.
If the problem persists, turn on verbose debug on the MQTT server to see if and why it is disconnecting clients. Wireshark captures might be helpful.
Code: Select all
if (client.connect("ESP8266Client", mqtt_username, mqtt_password)) {
See the latest pubsubclient ESP example which generates a random client name for every connection.
Code: Select all
Serial.print("Attempting MQTT connection...");
// Create a random client ID
String clientId = "ESP8266Client-";
clientId += String(random(0xffff), HEX);
// Attempt to connect
if (client.connect(clientId.c_str())) {
If the problem persists, turn on verbose debug on the MQTT server to see if and why it is disconnecting clients. Wireshark captures might be helpful.