Error trying to connect Arduino MKR NB 1500 to AWS IoT “the device does not recognize the command”

I have a project using MKR NB 1500 and Adafruit stemma soil sensor connecting to AWS to upload the sensor data. I had this working before just fine. I am developing in VS Code and PlatformIO. Yesterday I got a notification that there was an update available to VS Code, so I updated it. Then I made an inconsequential update to the code (minor change to one line of text to output to the serial monitor) and now when I run the sketch on the board I get the following error when trying to connect to AWS.


I can only assume that the update somehow caused this issue, but I’m a pretty novice programmer and don’t know where to start with this error. Any help is appreciated!

And that change was? Whatever it was it killed the serial connection it seems o_O

I literally changed
Serial.print("Attempting to MQTT broker: ");
Serial.print("Attempting to connect to MQTT broker: ");.

But just to be sure, I reverted back to the last know working version of the code from a few weeks ago and I still get the same error. After reverting I am sure that the only thing that’s changed is the update to VS Code.

The other thing that confuses me is that while the error seems to point to an issue with the serial connection, as you can see in the screenshot, it successfully writes several lines to the serial monitor before the error is thrown.

This may just indicate that the error appears at runtime.

in fact in conjunction with the informatio “Attempting to connect” and “cellular connection” it seems to me that the connection attempt activates the modem which causes an extreme current draw (and voltage drop) that knocks out the microcontroller, which hosts the USB-serial. Cellular connections are known to be power-hungry.

Do you get the same “serial connection is kill” behavior when just doing a normal loop with nothing else?

#include <Arduino.h>

void setup() { Serial.begin(115200); }
void loop() { Serial.prinltn("Looping"); delay(1000); }


Does it make a different if you chose a different USB port or cable to connect the board, so that it may get a better power source?

Is the antenna connected on the board’s u.FL connector? The voltage drop may be because of no antenna and all the RF energy gets reflected right back into the chip when it does a transmission and it does bzz.


that was exactly the problem. The antenna was disconnected. I actually realized it just before I saw your last post when I was making sure the batter was properly connected to handle the power draw. Now I feel kinda dumb, but greatly relieved it was something so simple! I’m surprised it was connecting to the cellular provider without an antenna.

Thanks for your help!

1 Like

well, it seems I declared victory too soon. After connecting the antenna and battery it’s still happening, just taking a while. After seeing the error again I tried the Adafruit soil sensor test sketch, which just reads to soil sensor data and publishes the reading to the serial monitor. After a while even on that sketch I get the same error. Any other ideas?

I’ll try a test with just the looping code provided above and see if I get the same error.
UPDATE: No issue with plain looping code.

ok so I realized that the version of the soil sensor example code I tested with included some additional JSON code that I was using to test putting the sensor readings into JSON for sending to AWS. I’m wondering if how I’m doing the JSON is causing a memory leak. I’m going to make some modifications to the JSON in the soil sensor to ensure I’m properly allocating memory.
In the meantime I’m also running the soil sensor example with the JSON commented out to see if that runs error free. If it does I’m guessing that’s my problem.