|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Issue with more than one Arduino in MQTT network |
« View previous topic :: View next topic » |
Author |
Message
|
kolomir0 |
Posted: Tue Sep 04, 2018 11:33 am Post subject: Issue with more than one Arduino in MQTT network |
|
|
Newbie
Joined: 04 Sep 2018 Posts: 1
|
Hello
I am working on a project in which the main idea is to connect a lot of arduino in the network. I thought that MQTT would be perfect.
The central unit is the computer on which the Mosquito server is running. In addition, is runing a program to serve everyone Arduino working in the network.
Of course, this is a very early phase of the project. During the first tests I connected with only one Arduino and everything worked satisfactorily. Arduino have to receive commands from a computer and send reports.
I used Arduino WeMos D1 mini (ESP8266) and I think the most popular library "PubSubClient" to write a program for Arduino.
The problem is when I connect two (or more) arduino .... In the network, of course, they received their own IP. They should subscribe to the same Topic ... because they work together. Unfortunately, they have a problem with the connection ...
Below part of the sample program from library:
Code: |
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");
// Once connected, publish an announcement...
client.publish("xxx", "hello world");
// ... and resubscribe
client.subscribe("xxx");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
} |
In Serial port monitor I have only "Attempting MQTT connection..." from both Arduino.
When I switches off one of them, the other starts to work correctly.
Maybe someone knows what I'm doing wrong ...?
Thank you for every help. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Sep 05, 2018 11:46 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
you might want to look at your code. Sounds like both Arduinos are competing for the same socket...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|