ESP32 and AWS IoT Core without using Thing
In this tutorial we will learn how to connect ESP32 with AWS IoT core and publish JSON format data without adding AWS IoT thing. The ESP32 will connect to the WIFI network and publish data to AWS IOT cloud. We will also cover how to send/receive data from AWS IoT dashboard.
This tutorial covers multiple sections:
- Installing necessary libraries to Arduino IDE.
- Generating certificates.
- Creating policy.
- Subscribe and publish data to and from AWS dashboard.
What is AWS IOT Core?
AWS IoT provides cloud services which helps you to connect IoT devices with other devices and AWS Cloud services.
It allows you to select the most appropriate and up-to-date technologies for your solution. AWS IoT core supports these protocols:
*MQTT (Message queuing and Telemetry Transport).
*MQTT over WSS (Web sockets Secure).
*HTTPS (Hypertext Transfer Protocol- Secure).
*LoRaWAN (Long Range-wide area network).
AWS IoT Core Dashboard:
After successfully signing in, the amazon console home page will get opened. In the service tab at the top search for IoT Core and then hit enter.
After entering the AWS IoT Core homepage, you will view a set of menus on the left. We are going to handle only two menus one is test and the other is manage.
GENERATE DEVICE CERTIFICATE:
For generating new certificate click on security->certificates. Then click on Add certificate->create certificate.
Once you click on create certificate it will take you to a new page, check whether your status is active and click on create.
You will get a pop-up page just download device certificate, public key file, private key file, there will be two root CA certificates just download amazon root CA1.
Out of these you need to use device certificate, private key file and amazon root CA1.
A device needs a certificate to connect to AWS IoT Core.
Next, open the downloaded certificates and key files in a text editor like notepad and open the device certificate in code editor like VS code and copy the content and paste it in the specified location in the code.
CREATING POLICY:
We have successfully created certificates next we have to attach a policy to the certificate. In the left side menu click on security->policies and click on create policy.
Now give policy a suitable name. For example, you give it a name as esp32 policy.
Now the policy statement part is very important. Here we will only need to publish, subscribe, connect and receive.
Now under the policy document attach four policy actions.
*Connect
*Publish
*Receive
*Subscribe and click on create.
Now click on create policy and your policy will be created successfully.
Read more: ESP32 and AWS IoT Core without using Thing