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

MQTT won't connect to AWS IoT without serial connection. #62

Open
weimiao86 opened this issue Jan 25, 2022 · 7 comments
Open

MQTT won't connect to AWS IoT without serial connection. #62

weimiao86 opened this issue Jan 25, 2022 · 7 comments
Labels
type: imperfection Perceived defect in any part of project

Comments

@weimiao86
Copy link

weimiao86 commented Jan 25, 2022

Hi,

I am using the Arduino MKR NB1500 to connect to the AWS IoT.
My current issue is the MQTT won't connect to AWS if the USB serial port is not recognized by my computer.
Scenarios as below.

  1. Power the Arduino from computer USB and the serial port shows up (COM6). MQTT works fine, it can connect to the cellular network and AWS.
  2. Power the Arduino from computer USB with charging only USB cable, which means there is no serial port showing up in computer device manager. the cellular network connection is fine, but the MQTT won't connect.
  3. Power the Arduino from a power bank with a data-supported USB (the one used to download code to Arduino). The cellular network connection is fine, but the MQTT won't connect.
  4. I tried to power the Arduino from the VIN pin, got the same result, it can connect to the cellular network, but won't connect to AWS.

My final goal is to power the Arduino from the power bank or VIN pin, but none of them work.

Please help, thank you! here is the log.

124

@per1234
Copy link
Contributor

per1234 commented Jan 25, 2022

Hi @weimiao86. Do you have something like this in your sketch?

  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

This code will cause the sketch to wait there until the serial port is opened. That is useful because, without it, you would not be able to see important information printed to Serial between the time the program started and when you got Serial Monitor open.

However, you must not have this code in a sketch that is intended to run without a serial connection because that would mean the program hangs at that line forever.

@per1234 per1234 added status: waiting for information More information must be provided before work can proceed type: imperfection Perceived defect in any part of project labels Jan 25, 2022
@weimiao86
Copy link
Author

@per1234 No, I don't have while (!Serial) in my code. The code will run and it stops when establishing the MQTT connection.

@per1234 per1234 removed the status: waiting for information More information must be provided before work can proceed label Jan 25, 2022
@robauto
Copy link

robauto commented Jan 25, 2022

A question related: So this could could be our AWS endpoint refusing (we can't ping the device either) - assuming this is not the serial loop (this has been addressed) what is the recommendation for learning what is causing the connection to fail? We have used AT tests, viewed log files.

@weimiao86
Copy link
Author

The Pubsubclient works with a battery. I don't understand why this library requires the serial connection to work.

@weimiao86 weimiao86 changed the title MQTT won't connect to AWS IoT when the USB serial port is not recognized. MQTT won't connect to AWS IoT without serial connection. Jan 31, 2022
@hcorn82
Copy link

hcorn82 commented Dec 11, 2022

I am having the same issue with MK1000 and ArduinoMqttClient. Keeping the board plugged into a computer isn't really feasible for my application. And for Pubsubclient I can't seem to get it to work with MK1000 and wifi101 library. Anyone have success with alternatives to ArduinoMqttClient and wifi101 or something that works on MK1000?

@weimiao86
Copy link
Author

@hcorn82 From my test, I found it may also be related to the computer or the driver. Try downloading the code to Arduino on a different computer, or try the Arduino online IDE https://create.arduino.cc/editor, it works for me.

@hcorn82
Copy link

hcorn82 commented Dec 12, 2022

@weimiao86 I've been using the Arduino web editor. But with my limited knowledge I am unable to get Wifi101 working without while (!Serial).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

4 participants