0

connecting two esp8266
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

connecting two esp8266

by kbasher on Mon Feb 26, 2018 10:23 am

Hi
I'm trying to connect two ESP8266 using just one key. if I connect one, the second one fails to connect to the broker. Trying to write code to control led of one board using push switch from another.
What am I doing wrong? I'm using free account.

kbasher
 
Posts: 1
Joined: Wed Feb 07, 2018 2:19 pm

Re: connecting two esp8266

by abhi_nath on Sat May 05, 2018 10:21 am

I am having the same problem. Only one ESP8266 connects, other one keeps on trying to connect. Is there any solution?

abhi_nath
 
Posts: 3
Joined: Sat Feb 17, 2018 12:54 pm

Re: connecting two esp8266

by abhi_nath on Mon May 07, 2018 3:12 pm

It would be of a great help if any experienced users can provide some clue.
Are they not connecting because Adafruit IO has any restriction on simultaneous connection with Free account ?

abhi_nath
 
Posts: 3
Joined: Sat Feb 17, 2018 12:54 pm

Re: connecting two esp8266

by abachman on Wed May 09, 2018 11:04 am

Hi all,


If you're using the same client ID in both sketches, the second would cause the first to disconnect. Our MQTT broker only allows one client connection per client ID, any subsequent connection with the same client ID will force the first to disconnect.

If you're using the Adafruit IO Arduino library, which is using the Adafruit MQTT library underneath, your client ID is randomized on each connection. If you're setting the client ID manually--for example, in order to track connection / disconnection per-device--you'll need to make sure each device or script has a different client ID.


- adam b.

abachman
 
Posts: 213
Joined: Mon Feb 01, 2010 12:48 pm

Re: connecting two esp8266

by abhi_nath on Wed May 09, 2018 1:10 pm

Thanks Adam for the reply. Really appreciate.

I could figure it out yesterday after looking at the Arduino code I was using, which is the sample code came in with the Library.

Changed the below line :
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_USERNAME, AIO_KEY);

To
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_CLIENT, AIO_USERNAME, AIO_KEY);

After defining the AIO_CLIENT name and voila, it started working.

abhi_nath
 
Posts: 3
Joined: Sat Feb 17, 2018 12:54 pm

Please be positive and constructive with your questions and comments.