This project was built with the following requirements in mind:
- RaspberryPi 3
- Espressif ESP32 DevKitC
- AWS account with access to AWS IoT
- Windows or OSX based machine
- Python 2.7
- Wifi connection (egress to AWS available)
These instructions assume that you have already downloaded and installed Rasbpian on your RaspberryPi.
SSH into your RaspberryPi and execute the following commands:
sudo su -
adduser --system ggc_user
addgroup --system ggc_group
apt-get install rpi-update
rpi-update b81a11258fc911170b40a0b09bbd63c84bc5ad59
echo 'fs.protected_hardlinks = 1' >> /etc/sysctl.d/98-rpi.conf
echo 'fs.protected_symlinks = 1' >> /etc/sysctl.d/98-rpi.conf
reboot
cd /home/pi/Downloads
git clone https://github.com/aws-samples/aws-greengrass-samples.git
cd aws-greengrass-samples
cd greengrass-dependency-checker-GGCv1.5.0
sudo modprobe configs
sudo ./check_ggc_dependencies | more
Follow these instructions: https://docs.aws.amazon.com/greengrass/latest/developerguide/gg-config.html
In order for your IoT Things to know how to connect to your Greengrass Core, you must set the following:
IoT Core > Greengrass > Groups > YourGreengrassGroup > Cores > YourGreengrassGroup_Core > Connectivity
Core endpoints:
- Your RaspberryPi's IP address
- Port 8883
Follow these instructions: https://docs.aws.amazon.com/greengrass/latest/developerguide/gg-device-start.html
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
- https://www.raspberrypi.org/documentation/installation/
- https://docs.aws.amazon.com/greengrass/latest/developerguide/module1.html
These instructions are derived directly from https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html
Install and configure the AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/installing.html
Install the boto3 library:
- On Windows in the mingw32 environment:
easy_install boto3
- On MacOS or Linux:
pip install boto3
Clone the Amazon FreeRTOS Github repo to your machine:
git clone https://github.com/aws/amazon-freertos
Add your thing name and wifi connection configuration:
vim amazon-freertos/demos/common/tools/aws_config_quick_start/configure.json
Run the configuration script to provision an AWS IoT thing:
cd amazon-freertos/demos/common/tools/aws_config_quick_start/
python SetupAWS.py setup
Update amazon-freertos/demos/common/demo_runner/aws_demo_runner.c
:
Uncomment the lines containing vStartGreenGrassDiscoveryTask
Comment the lines containing vStartMQTTEchoDemo
Update amazon-freertos/demos/esp32_devkitc_esp_wrover_kit/common/config_files/amazon_demo_config.h
Find democonfigGREENGRASS_DISCOVERY_TASK_STACK_SIZE
and make the following change:
/* original value was configMINIMAL_STACK_SIZE * 8 */
#define democonfigGREENGRASS_DISCOVERY_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 16 )
Run the menuconfig program to set your Serial flash config's default serial port. On Windows, this will be something like COM1
. On OSX, this will be something like /dev/cu.*
cd /demos/espressif/esp32_devkitc_esp_wrover_kit/make
make menuconfig
Next, run the flash command to flash the firmare to your ESP32:
make flash
In a separate terminal window, run the monitor command to view logs for the firmware running on the ESP32:
make monitor
IoT Core > Greengrass > Groups > YourGreengrassGroup > Cores > YourGreengrassGroup_Core > Devices
Click Add Device
Click Select an IoT Thing
Under the Devices screen, click the ...
for your newly added Thing, and click 'Sync to the Cloud'
IoT Core > Greengrass > Groups > YourGreengrassGroup > Cores > YourGreengrassGroup_Core > Subscriptions Click Add Subscription Source = Devices > your thing Target = Services > IoT Cloud Topic = freertos/demos/ggd
Add greengrass:Disover
to the Thing policy generated by the configuration script
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "arn:aws:iot:us-east-1:{account-id}:*"
},
{
"Effect": "Allow",
"Action": "iot:Publish",
"Resource": "arn:aws:iot:us-east-1:{account-id}:*"
},
{
"Effect": "Allow",
"Action": "iot:Subscribe",
"Resource": "arn:aws:iot:us-east-1:{account-id}:*"
},
{
"Effect": "Allow",
"Action": "iot:Receive",
"Resource": "arn:aws:iot:us-east-1:{account-id}:*"
},
{
"Effect": "Allow",
"Action": "greengrass:Discover",
"Resource": "arn:aws:iot:us-east-1:{account-id}:*"
}
]
}
- https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html
- https://esp-idf.readthedocs.io/en/latest/get-started/establish-serial-connection.html
- https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
When attempting to run make flash
, you receive the error A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
. This may indicate that you have a bad USB cable, or some other issue connecting to the ESB32 via your serial port. Often times, retrying the make flash
command will work, as well as unplugging your USB cable to/from the ESP32 and/or your computer.