Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wifiecho example error -2 on uno r4 #108

Open
maxvaneck opened this issue Jul 12, 2024 · 4 comments
Open

wifiecho example error -2 on uno r4 #108

maxvaneck opened this issue Jul 12, 2024 · 4 comments
Labels
status: waiting for information More information must be provided before work can proceed type: imperfection Perceived defect in any part of project

Comments

@maxvaneck
Copy link

as in the title. it connects just fine with the wifi but i get an error code -2 whenn running the wifiecho example on an arduino uno r4. it happens both on test.mosquitto.org and a local mosquitto broker acceptiong anonymous connections. mqtt explorer works just fine on both so i don't know what's going on . thx for the help. i'm unable to test on any other boards atm but the most likely culprit is the uno r4 since it's so new and i've had trouble with other libraries
Max

@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Jul 12, 2024
@pennam
Copy link
Contributor

pennam commented Jul 17, 2024

Hi @maxvaneck I'm not able to reproduce your issue with my UNO R4, seems everything is working fine. Would you check which wifi firmware version is running on your board?

@pennam pennam added the status: waiting for information More information must be provided before work can proceed label Jul 17, 2024
@maxvaneck
Copy link
Author

I was running an older firmware version. i've just updated and i still run in the same problem on the example

@willham93
Copy link

I am also having this issue with an Uno r4 running firmware 0.4.1

@maxvaneck
Copy link
Author

maxvaneck commented Nov 19, 2024

i did find a fix eventually . i vaguely remember something about adding a sort of delay during connection . below is some code you could try of which i am reasonably sure it works

  Serial.print("Attempting to connect to the MQTT broker: ");
  Serial.println(broker);

  if (!mqttClient.connect(broker, port)) {
    Serial.print("MQTT connection failed! Error code = ");
    Serial.println(mqttClient.connectError());

 Serial.print("Attempting to connect to the MQTT broker: ");
    Serial.println(broker);

    while (!mqttClient.connect(broker, port))
    {
        Serial.print(".");
        delay(100);
    }

    Serial.println("\nYou're connected to the MQTT broker!");
    Serial.println();

  Serial.println("You're connected to the MQTT broker!");
  Serial.println();

  Serial.print("Subscribing to topic: ");
  Serial.println(topic);
  Serial.println();


  // subscribe to a topic
  mqttClient.subscribe(topic);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for information More information must be provided before work can proceed type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

4 participants