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

PubSub example not working #39

Closed dsandi closed 7 years ago

dsandi commented 7 years ago

Hi,

I'm having the same issue described on other closed issues. When running this basic example I get:

AWS IoT SDK Version(dev) 2.2.0-
Setup failed!
-5

I added the line

Serial.println(rw_buf);

after this one and the output was:

AWS IoT SDK Version(dev) 2.2.0-

Setup failed!
-5

I also run cat /proc/cmdline on the board and the out put was:

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

I also confirmed having an internet connection by doing ping:

root@mydevice:~/AWS-IoT-Python-Runtime/lib# ping github.com
PING github.com (192.30.253.112): 56 data bytes
64 bytes from 192.30.253.112: seq=0 ttl=52 time=79.618 ms
64 bytes from 192.30.253.112: seq=1 ttl=52 time=68.120 ms
64 bytes from 192.30.253.112: seq=2 ttl=52 time=70.041 ms
64 bytes from 192.30.253.112: seq=3 ttl=52 time=70.931 ms
^C
--- github.com ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 68.120/72.177/79.618 ms

I'm using WiFi and I cannot use the Ethernet port to test.

liuszeng commented 7 years ago

Hi @dsandi ,

Thank you very much for providing the information.

Error code -5 (SERIAL1_COMMUNICATION_ERROR) means that the ATmega is not able to retrieve the expected response from embedded Linux on AAR9331. This might be caused either by an unsupported serial baud rate or a failure in serial1 communication. From the output of cat /proc/cmdline, we know that the baud rate configuration of your board is 250K, which is supported. You can try the following:

  1. Run "YunSerialTerminal" example provided along with the Arduino IDE and see if you can get it working correctly. With a proper baud rate configuration and a successful serial1 communication, you should be able to use the Serial monitor as a terminal on embedded Linux.

  2. Do a power cycle for the board and try to unload the sketch again. Note that the board will need 80-90 seconds to get ready for sketch upload.

Thanks, Liusu

dsandi commented 7 years ago

Hi,

I could run the YunSerialTerminal succesfully

Speed set to 57600
Speed set to 115200
Speed set to 250000
Speed set to 500000
Sending bridge's shutdown command
��

I also did the power cycle and re run the sketch and I got this output:


AWS IoT SDK Version(dev) 2.2.0-

root@gorillayun2:~/AWS-IoT-Python-Runtime/runtime# 
/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
/bin/ash: 1: not found
/bin/ash: /root: Permission denied
Linux
/

I T

G T

Connect failed!
-1

And this out put when removed the extra Serial.println we added here


AWS IoT SDK Version(dev) 2.2.0-

Connect failed!
-1
liuszeng commented 7 years ago

Hi @dsandi ,

Thank you very much for providing the information.

Now the sample fails in connect. Can you double check the credentials you are using to connect to AWS IoT?

  1. Are you using X.509 certificate, private key and root CA or IAM credentials?
  2. If you are using X.509 certificate, private key and root CA, can you confirm in your AWS IoT Console that your certificate is activated and attached with a proper AWS IoT Policy with permissions to connect, publish, subscribe and receive. For more information about policy permissions, please check out the following documentation: http://docs.aws.amazon.com/iot/latest/developerguide/pub-sub-policy.html

Thanks, Liusu

dsandi commented 7 years ago

I missed the policies!

So I guess it would be idea to run the YunSerialTerminal example successfully before running the sdk examples. Maybe we could add that to the read.me

liuszeng commented 7 years ago

Hi @dsandi ,

Glad that it works.

Normally, it should not require running the YunSerialTerminal example first to get the SDK samples working. YunSerialTerminal example just verifies the Serial1 connection between ATmega and AR9331 works fine. Yun board is a little bit fragile. A better practice here is to flush an empty sketch after you finished using it to avoid unpredictable things (blocking Serial1 connection, for example) next time the board powers up.

Thanks, Liusu