Received [ERR] command: setup code: -1 with Arduino Yun example: ThermostatSimulatorDevice
Closed this issue · 3 comments
I have setup my Arduino Yun as instructed in the Readme file in https://github.com/aws/aws-iot-device-sdk-arduino-yun.
Caveat:
- I updated OpenWrt to version Nov 14, 2014.
- I did not specify the AWSIoTPythonSDK version. So it must have installed the latest version. Would this be a problem?
I am using Win 7 64-bit. I could upload the blink example to the Yun for sanity check.
I could get Yun to commuicate with AWS IoT through the python examples. But it did not work with the Arduino code. The serial monitor returned a setup error -1. There are probably some steps or configurations that I have missed or incorrectly done but I could not find what they were.
AWS IoT SDK Version(dev) 2.2.0-
YunTestTwo
YunTestTwo
a*************8.iot.us-east-2.amazonaws.com (I intentionally covered the my endpoint on this post)
8883
/root/AWS-IoT-Python-Runtime/certs/root-CA.crt
/root/AWS-IoT-Python-Runtime/certs/YunTestTwo.private.key
/root/AWS-IoT-Python-Runtime/certs/YunTestTwo.cert.pem
[ERR] command: setup code: -1
My initial setup with AWS IoT was to follow the instructions in Connect from the IoT menu. My steps were
- Selected Linux and Python
- Downloaded and copied the certificate and key to Yun: /root/AWS-IoT-Python-Runtime/certs. The files are root-CA.crt, YunTestTwo.cert.pem, YunTestTwo.private.key.
- Downloaded and copied the SDK Python from https://github.com/aws/aws-iot-device-sdk-python to the certs directory. I did not use git clone because I did not install git in Yun.
- Installed the SDK using python setup.py install
- Ran the test script: basicPubSub.py from the certs directory.
- It worked.
- I opened MQTT client (under Test) and subscribed to topic: sdk/test/Python.
- I ran the test script again and it worked even though it complained "We cannot display the message as JSON, and are instead displaying it as UTF-8 String."
Next, in the Arduino code, I opened the ThermostatSimulatorDevice example and modified aws_iot_config.h.
#define AWS_IOT_MQTT_HOST "a***********8.iot.us-east-2.amazonaws.com" // your endpoint
#define AWS_IOT_MQTT_PORT 8883 // your port
#define AWS_IOT_CLIENT_ID "YunTestTwo" // your client ID
#define AWS_IOT_MY_THING_NAME "YunTestTwo" // your thing name
#define AWS_IOT_ROOT_CA_FILENAME "root-CA.crt" // your root-CA filename
#define AWS_IOT_CERTIFICATE_FILENAME "YunTestTwo.cert.pem" // your certificate filename
#define AWS_IOT_PRIVATE_KEY_FILENAME "YunTestTwo.private.key" // your private key filename
I even modified AWS_IOT_PATH_PREFIX from "../certs/" to "/root/AWS-IoT-Python-Runtime/certs/" but still got the same error.
Thank you in advance for reading my issue and helping me.
Hi @LabGrunt ,
Thank you very much for your interest in AWS IoT Arduino Yun SDK.
Yun SDK does depend on a specific version (v1.0.0) of the IoT Python SDK for its Python runtime that does the heavy lifting for MQTT communication. When you are installing the Python SDK on OpenWRT, you need to specify the version. More details can be found in the following documentation:
https://github.com/aws/aws-iot-device-sdk-arduino-yun#installation-on-windows
For setup error code -1, to get more debugging information, you can add an extra line to print out rw_buf to the serial monitor to check what error message is coming from OpenWRT. More details can be found in the following post:
#25
Can you try switch back to IoT Python SDK v1.0.0 on OpenWRT and attach the log output when experiencing the issue?
Thanks,
Liusu
I have installed Python SDK v1.0.0. and added the Serial.println.
The serial monitor output
AWS IoT SDK Version(dev) 2.2.0-
root@Arduino:/#
/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
root@Arduino:~/AWS-IoTme#
Traceback (most recent call last):
Setup failed!
-1
The log does not look informative to me.
I have decided to start over and afterwards, it worked.
My steps were
- Placed the latest openwrt in a microSD card and inserted it to Yun. (see this tutorial.)
- Opened the web browser which should detect the openwrt image and offer to reset.
- Clicked the reset and waited for several minutes as instructed.
- Placed the AWS IoT certificate and key files as instructed in this git.
- Installed the libraries (including distribute, python-openssl, pip and AWSIoTPythonSDK v1.0.0)
- Opened the example BasicPubSub to Arduino Yun
- Modified the AWS macros in aws_iot_config.h
- Note that I did not CHMOD run.py
- Opened the serial monitor to see that it started sending messages
- Opened the AWS IoT menu > Test
- Subscribed to topic "topic1"
- Observed the messages appearing on the MQTT client too.