Programming ESP32 using MQTT with AWS and FreeRTOS
2021-01-08
Previous article
What we’re doing
Set up your ESP-32 running FreeRTOS to subscribe and publish events to AWS IoT via MQTT
Install the development environment (I use a Mac)
I used this excellent guide from Espressive
Get started with the example code
Read the post by Espressive here and use the code here. I don’t have the WROOM-32Se, so I skipped the instructions for “Using an ATECC608A with the ESP-AWS-IoT” and embedded the creds in code.
Using ‘idf.py menuconfig’:
- Set up your WiFi SSID and password
- Set up to embed the AWS certs into the binary
- Set up AWS IoT endpoint
Copy your credentials
Get started on the AWS side by creating, activating, and downloading your credentials as described in my previous post. The demo comes with the AWS CA in the cert directory (main/certs), so you need to only copy your certificate and private key to the same place.
Compile, flash, monitor
Use idf.py flash monitor --port /dev/cu.usbserial-0001
, substituting your connection port accordingly.
You’ll see the trace output in your terminal:
I (75682) subpub: test_topic/esp32 Hello from ESP32 (QOS0) : 112
I (75712) subpub: Subscribe callback
I (75712) subpub: test_topic/esp32 Hello from ESP32 (QOS1) : 113
I (75802) subpub: Stack remaining for task 'aws_iot_task' is 3544 bytes
I (76862) subpub: Subscribe callback
I (76862) subpub: test_topic/esp32 {
"message": "Hello from AWS IoT console"
}
I (76882) subpub: Subscribe callback
I (76882) subpub: test_topic/esp32 Hello from ESP32 (QOS0) : 114
I (76912) subpub: Subscribe callback
I (76912) subpub: test_topic/esp32 Hello from ESP32 (QOS1) : 115
I (77002) subpub: Stack remaining for task 'aws_iot_task' is 3544 bytes
I (78062) subpub: Subscribe callback
Note that ‘Hello from AWS IoT console’ trace above is the result of going to the AWS console and publishing to the topic. The demo program subscribes and publishes to the topic, so anything coming from the simulator on that topic will be picked up and displayed.
You can see the messages sent to AWS:
Next step
Publish meaningful events from sensors? Have a second ESP32 communicate with this one?
Previous article
Filed under
AWS
- Quick AWS IoT Setup and test
- Set up AWS API GW with a Typescript authorizer and logging
- Use AWS CodePipline to execute CloudFormation templates
- Use GitHub Actions to deploy your SPA hosted on Amazon S3
- Use an AWS CloudFormation script to create and host an SPA on S3 with SSL and apex/subdomain redirection using CloudFront
- Writing an Alexa skill using Ruby and AWS Lambda (Part 0)
C
Embedded
How-to
IoT
Other Tags
API GW
AWS
- Programming ESP32 using MQTT with AWS and FreeRTOS
- Quick AWS IoT Setup and test
- Set up AWS API GW with a Typescript authorizer and logging
- Use AWS CodePipline to execute CloudFormation templates
- Use GitHub Actions to deploy your SPA hosted on Amazon S3
- Use an AWS CloudFormation script to create and host an SPA on S3 with SSL and apex/subdomain redirection using CloudFront
- Writing an Alexa skill using Ruby and AWS Lambda (Part 0)
ActiveRecord
Agile
- A review of software development metrics
- Agile programme management brief
- An alternative to current product development metrics
- An alternative to the current product development governance model
- Command & Control Management - The Party Killer
- Document Driven Development
- Inceptions revisited
- Managing multiple stakeholders
- Returns Driven Development
- The tip of the (good) iceberg
Alexa
Analysis
Ansible
BDD
BLE
C
CAB
CloudFormation
- Set up AWS API GW with a Typescript authorizer and logging
- Use AWS CodePipline to execute CloudFormation templates
- Use GitHub Actions to deploy your SPA hosted on Amazon S3
- Use an AWS CloudFormation script to create and host an SPA on S3 with SSL and apex/subdomain redirection using CloudFront
- Writing an Alexa skill using Ruby and AWS Lambda (Part 0)
CloudFront
CloudWatch
Cross-compile
Cucumber
DevOps
Devops
DotNet
Embedded
Fitbit
GNU
GitHub Actions
Governance
How-to
Inception
IoT
Javascript
Jest
Lambda
Mac OS X
- Bluetooth Low Energy (BLE) Implementing a peripheral on Mac OS X
- Cross-compiling for Raspberry Pi on a Mac and debugging using NetBeans
- Drobo will not mount in Finder
- Quickie - ssh dynamic port forwarding to avoid unsecured public networks
- Remote compilation, execution and debugging Raspberry Pi from a Mac using NetBeans
- Weekend warrior - MacRuby and rSpec, Mac OS X Lion, Xcode V4.3.2
MacRuby
Metrics
MySQL
NetBeans
Objective-C
PMO
Product Management
- A path to accelerating value realization
- A review of software development metrics
- Agile programme management brief
- An alternative to current product development metrics
- An alternative to the current product development governance model
- Express initiative kickoff formula
- Inceptions revisited
- Managing multiple stakeholders
- Plan for value delivery
- Pre-prod activity - Futurespective
- Value Stream Mapping
- When planning, it's not only about relative complexity
Programme management
Project Management
- A path to accelerating value realization
- A review of software development metrics
- Agile programme management brief
- An alternative to current product development metrics
- An alternative to the current product development governance model
- Command & Control Management - The Party Killer
- Express initiative kickoff formula
- Inceptions revisited
- Managing multiple stakeholders
- Plan for value delivery
- Pre-prod activity - Futurespective
- Value Stream Mapping
- When planning, it's not only about relative complexity
Quality Assurance
Rails
Raspberry Pi
Remote compilation
Remote debugging
Remote execution
Risk Assessment
Route 53
Ruby
- Alexa on Rails - how to develop and test Alexa skills using Rails
- Arduino programming using Ruby, Cucumber & rSpec
- How to reconnect to a database when its connection was lost
- Oh, the places you'll go...
- Quick AWS IoT Setup and test
- Weekend warrior - MacRuby and rSpec, Mac OS X Lion, Xcode V4.3.2
- Writing an Alexa skill using Ruby and AWS Lambda (Part 0)