aws / aws-iot-device-sdk-arduino-yun

SDK for connecting to AWS IoT from an Arduino Yún.
Apache License 2.0
163 stars 77 forks source link

Setup Failed! -5 PubSub example #33

Closed mtahamir closed 7 years ago

mtahamir commented 7 years ago

I recently was able to get my Raspberry Pi to connect to AWS, but I'm new and having trouble connecting my Arduino YUN. I've made sure to follow the instructions for the SDK and that WiFi works but, whenever I run the example PubSub code my serial monitor shows the following output:

AWS IoT SDK Version(dev) 2.2.0-

Setup failed!
-5

I'm unsure as how to fix this issue. My closest understanding is that this is related to SERIAL1_COMMUNICATION_ERROR. I've run the YunSerialTerminal sketch a few times to confirm that the Arduino Serial Monitor can see data from the OpenWRT side.

liuszeng commented 7 years ago

Hi @tahamir ,

Thank you very much for using AWS IoT Arduino Yun SDK.

The issue you are seeing here is caused by ATmega32u4 not able to receive expected response from AR9331 via Serial1 communication. To help us investigate into the issue, can you provide the following information?

a. Do a ssh into the Linux side of your Yun board and try the following command to get the baud rate configuration:

cat /proc/cmdline

You should be able to see similar output like this (I am testing on my Yun with Linino installed, which has a baud rate configuration of 115.2k):

board=linino-one console=ttyATH0,115200 ...

Yun SDK supports baud rate 250K and 115.2K. You can check out the baud rate on your Linux.

b. Add the following line after this line:

Serial.println(rw_buf);

Check the serial monitor output when you are experiencing the issue.

Thanks, Liusu

mtahamir commented 7 years ago

Hi @liuszeng

I sshed into my Yun and applied the command. I got the following output:

root@arduino:~# cat /proc/cmdline
 board=linino-yun console=ttyATH0,250000 mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),14656k(rootfs),1280k(kernel),64k(nvram),64k(art),15936k@0x50000(firmware) rootfstype=squashfs,jffs2 noinitrd mem=64M rootfstype=squashfs,jffs2 noinitrd
root@arduino:~#

So I can confirm the Yun should be running at the right baud rate for AWS.

I also added the Serial.println(rw_buf); line and on my Serial Monitor I got the following output:

AWS IoT SDK Version(dev) 2.2.0-


t@arduino:~/AWS-IoT-Python-Runtime/runtime# 1
/bin/ash: /root: Permission denied
/bin/ash: 1: not found
/bin/ash: /root: Permission denied
/bin/ash: 1: not found
/bin/ash: /root: Permission denied
/bin/ash: 1: not found
/bin/ash: /root: Permission denied
Linux
/

I T

G T

C T

S T

P T

Z T

Y F: No messages.
loop 0 done

P T

Z T

Y 0 0 new message 0
CALLBACK:
new message 0

Y F: No messages.
loop 1 done

The looping at the end repeats itself like this for quite a bit afterwards.

liuszeng commented 7 years ago

Hi @tahamir ,

From the baud rate we can see that your board is configured to have a baud rate of 250K for (console) serial1 communication, which is supported by the SDK. From the provided logs, it seems that you are getting the SDK PubSub sample working, as it is printing out the message published by itself:

...
CALLBACK:
new message 0
...

Did you see any other issues or error code printed out in your IDE serial monitor?

Thanks, Liusu

mtahamir commented 7 years ago

Hi @liuszeng

I took another look at my setup and noticed that the time it worked I was running the code while connected to the internet through ethernet. But the time it didn't work I was connecting through the YUN's onboard WiFi. I reran the code while including the Serial.println(rw_buf); command. I get the following output on my Serial Monitor:

AWS IoT SDK Version(dev) 2.2.0-

Setup failed!
-5

It looks like before any data is put in rw_buf the code fails to run.

liuszeng commented 7 years ago

Hi @tahamir ,

Thank you very much for providing the information.

Can you try the following things?

  1. Verify that your board has outbound internet connectivity when it is on WiFi. You can do this by ssh into the Linux and do a ping.
  2. Reconfigure the WiFi connection and restart (power cycle).

One thing you would need to make sure is to wait until the board it fully set up to run the sample after you reconfigured WiFi and restart the board. It usually takes no more than 90 seconds. During set up, Yun board will spit some boot-up info to stdout (Serial1) that could break the SDK protocol.

Thanks, Liusu

liuszeng commented 7 years ago

Hi @tahamir ,

We have not heard from you for a while. We are closing the issue for now. Please feel free to reopen it or start another thread if you have any more questions.

Thanks, Liusu

matthewcarroll commented 7 years ago

Hi @liuszeng ,

I am consistently getting the Setup failed! -5 error.

Here is the output of cat /proc/cmdline on my board:

 board=linino-yun console=ttyATH0,250000 mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),14656k(rootfs),1280k(kernel),64k(nvram),64k(art),15936k@0x50000(firmware) rootfstype=squashfs,jffs2 noinitrd mem=64M rootfstype=squashfs,jffs2 noinitrd

The first 3 lines of my program are:

  Bridge.begin();
  Serial.begin(9600);
  while (!Serial);

I uncommented the line above but get only blank output.

Any help would be much appreciated.

Thanks! Matthew