-->
Page 2 of 2

Re: Second NodeMCU ESP8266 powered up, NEITHER sends reading

PostPosted: Sat Jun 02, 2018 8:44 am
by gdsports
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.

Code: Select allif (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.

Re: Second NodeMCU ESP8266 powered up, NEITHER sends reading

PostPosted: Thu Jun 07, 2018 1:03 am
by fritserasmus
Solved:
When client.connect, each ESP8266 should have a unique ClientID.
I used the same sketch and not changing the ClientID for each

This topic can be closed

Re: Second NodeMCU ESP8266 powered up, NEITHER sends reading

PostPosted: Thu Jun 07, 2018 1:07 am
by fritserasmus
gdsports wrote: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.

Code: Select allif (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.



Thank you gdsports.
That was exactly what I needed.