0% found this document useful (0 votes)
94 views

Aws Esp32

This document discusses connecting an ESP32 microcontroller to AWS IoT. It covers setting up the Arduino IDE, required libraries, creating an AWS IoT thing, configuring device connection parameters, and establishing an AWS IoT policy to authorize device interactions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views

Aws Esp32

This document discusses connecting an ESP32 microcontroller to AWS IoT. It covers setting up the Arduino IDE, required libraries, creating an AWS IoT thing, configuring device connection parameters, and establishing an AWS IoT policy to authorize device interactions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ESP32 & AWS Report

Héctor Emiliano González Martı́nez


Data Engineering
Universidad Politécnica de Yucatán
Ucú, Yucatán, México
[email protected]

I NTRODUCTION • Arduino JSON by Arduino (Version 0.2.0): Enables


The field of electronics has been greatly democratized by the JSON data processing within Arduino sketches, an inte-
advent of accessible development platforms. Among these, the gral feature for IoT applications requiring data serializa-
Arduino Integrated Development Environment (IDE) serves as tion.
a pivotal resource for constructing and programming electronic • PubSubClient by Nick O’Leary (Version 2.8): Facili-

devices. This report presents an overview of a project that tates communication using the MQTT protocol, providing
leverages the Arduino IDE, alongside the AWS IoT service, to a robust solution for IoT devices to publish and subscribe
program and connect an ESP32 microcontroller to the cloud. to messages.
This endeavor not only exemplifies the integration of cloud • esp32 by Espressif Systems (Version 2.0.14): A requi-

computing with embedded systems but also showcases the site library for programming the ESP32, it contains all
practical implementation of IoT concepts. Our work demon- the necessary drivers and functions for the development
strates the process of enabling communication between the board.
ESP32 module and AWS IoT, thereby illustrating the conver- To incorporate these libraries, access the Arduino IDE,
gence of the digital and physical domains in a professional navigate to ‘Sketch ¿ Include Library ¿ Manage Libraries...‘,
context. and execute a search for each library listed. Upon locating the
desired library, select it and proceed by clicking the ”Install”
OVERVIEW OF THE A RDUINO S OFTWARE (IDE) button to acquire the specified version.
The Arduino Software IDE, provided open-source by Ar-
Extending Arduino IDE with Additional Boards
duino.cc, is an essential tool for coding, compiling, and
uploading projects to Arduino devices. Its Java-based en- The Arduino IDE’s capabilities can be enhanced by adding
vironment supports cross-platform functionality for MAC, new boards through their respective Board Manager URLs.
Windows, and Linux. The IDE is celebrated for its user- This feature is particularly beneficial for incorporating boards
friendly interface, which simplifies the programming process such as the ESP32 and ESP8266, which are not present in the
for beginners and experienced users alike. It is particularly IDE’s default configuration.
advantageous for offline project development where internet • The Board Manager URL for the ESP32
access is scarce, supporting both C and C++ languages. is: https://raw.githubusercontent.com/espressif/
Within the IDE, the coding workflow is efficient and arduino-esp32/gh-pages/package esp32 index.json
straightforward, involving a text editor for writing sketches, a • For the ESP8266, the corresponding URL
compiler for code translation, and a seamless mechanism for is: http://arduino.esp8266.com/stable/package
uploading to various Arduino modules. A distinctive feature esp8266com index.json
set, including a menu bar, output pane, and debugging tools To add these board configurations to the Arduino IDE, one
like the Serial Monitor, enhances the development experience. should:
The availability of two versions, IDE 1.x.x and the more 1) Launch the Arduino IDE and go to the ”Preferences”
advanced IDE 2.x, offers users a choice between traditional window.
functionality and newer features such as autocompletion and 2) Locate the ”Additional Boards Manager URLs” input
an integrated debugger, with both versions maintaining a con- field.
sistent process for code management and device interaction. 3) Insert the URLs, ensuring each URL occupies its own
line.
R EQUIRED L IBRARIES FOR P ROJECT S ETUP
4) Confirm the changes by clicking ”OK” and closing the
The project necessitates the integration of several libraries, Preferences window.
each facilitating a unique aspect of the device’s functionality:
AWS
• DHT sensor library by Adafruit (Version 1.4.6): Es-
sential for interfacing with DHT11 and DHT22 sensors, IoT Thing
this library simplifies reading temperature and humidity AWS IoT Core enables the creation of ”Things” which
data on Arduino platforms. symbolize physical devices in the cloud. These Things are
uniquely identified within AWS IoT Core and have attributes
for effective device management.
1) Access the AWS Management Console and go to the
AWS IoT Core service section.
2) From the AWS IoT Core dashboard, select ”Manage”
followed by ”Things”.
3) Initiate a new Thing creation by clicking ”Create
things”.
4) Assign a distinctive name to your Thing, for instance,
‘ESP PRUEBA‘, and fill out the necessary details.
5) If desired, define attributes for your Thing, like device
type or model number, using key-value pairs for en-
hanced management.
6) Finalize the Thing’s details and save to establish it within
AWS IoT Core.
7) Secure your Thing by attaching the appropriate certifi-
cates and policies for trusted device communication.
Fig. 2. Setup of connection parameters in secrets.h

6) Ensure certificates and keys are correctly placed in PEM


format within the designated BEGIN and END tags.
Maintaining the confidentiality of the certificates and keys
is critical for the security of the connection between the IoT
device and AWS IoT.
Note: Actual content of certificates and private key should
be securely embedded within the placeholders in the code
structure.

Establishing an AWS IoT Policy


AWS IoT policies are essential for authorizing device inter-
actions with AWS IoT Core. Below is a guide to creating a
policy through the AWS IoT Console.

Fig. 1. AWS IoT Thing creation process.

Device Connection Setup with AWS IoT


To establish a secure connection between an IoT device
and AWS IoT, it is essential to configure credentials and
connection parameters, typically within a header file named
secrets.h in the device’s firmware.
1) Assign the THINGNAME constant with the name of the
AWS IoT Thing created earlier.
2) Enter your WiFi credentials: WIFI_SSID for the net-
work name and WIFI_PASSWORD for the password.
3) Adjust the TIME_ZONE to align with your local time
zone for accurate data timestamping.
4) Define MQTT_HOST as the endpoint address of your
AWS IoT Core instance.
5) Include the device’s certificate and private key issued by
AWS when registering your Thing, inputting them into
the cacert, client_cert, and privkey variables
respectively. Fig. 3. AWS IoT Policy creation interface.
1) Open the AWS IoT Core console, select ”Security” from
the sidebar, and then choose ”Policies.”
2) Begin the creation process by clicking the ”Create
policy” button.
3) Name your policy uniquely, for example,
‘ESP EXAMPLE‘.
4) Specify the allowable actions such as iot:Connect,
iot:Publish, iot:Subscribe, and
iot:Receive, along with the resources these
actions apply to, usually denoted by their ARN
(Amazon Resource Name).
5) Confirm the details of the policy, ensuring it grants the
appropriate permissions needed for your IoT device’s Fig. 4. Publishing messages to MQTT from the IoT device.
operations.
6) Finalize and save your policy, after which the system
By subscribing to a topic using the MQTT test client in
will display its active version, creation date, and last
AWS IoT Core, incoming messages from an IoT device are
modification details.
displayed, confirming successful message delivery.
B OARD T UTORIAL
A. Temperature and Humidity Measurement with ESP8266
and DHT11 Sensor
This section describes the procedure for programming an
ESP8266 microcontroller to capture temperature and humidity
readings using a DHT11 sensor, and subsequently publish
these readings to AWS IoT Core via MQTT.
To deploy this program onto an ESP8266 board, execute the
following steps:
1) Connect your ESP8266 board to the computer through
a USB cable.
2) Launch the Arduino IDE and navigate to Tools ¿ Board
to select the appropriate board model. Fig. 5. AWS IoT Core console displaying subscribed MQTT messages.
3) Identify and select the correct COM port connected to
the board under Tools ¿ Port. Moreover, messages sent from the AWS IoT Core can be
4) Update the ‘secrets.h‘ file with necessary credentials monitored on the IoT device’s Serial Monitor, establishing
and configurations, including WiFi details, AWS IoT two-way communication and validating the device’s connec-
endpoint, and security certificates. tion to AWS IoT Core.
5) Click the Upload button in the Arduino IDE to compile
the code and transfer it to the ESP8266 board.
6) Access the Serial Monitor from the Arduino IDE to
monitor the output and debugging messages from the
board.
Upon successful upload, the ESP8266 will continuously
measure the environmental temperature and humidity through
the DHT11 sensor and relay this information to AWS IoT Core
on a predefined MQTT topic at set intervals.

Verifying MQTT Publish and Subscribe Functionality


Testing the interaction between AWS IoT and IoT devices
involves subscribing to MQTT topics and publishing messages Fig. 6. Viewing AWS IoT console messages on the device’s Serial Monitor.
to them, a key step in ensuring successful device integration
with AWS IoT Core. The MQTT protocol enables real-time For testing, the ‘esp32/pub‘ and ‘esp32/sub‘ topics are
communication by allowing devices to publish messages that commonly used. When the device sends sensor data such as
are immediately received by all subscribers of the relevant temperature and humidity to ‘esp32/pub‘, it can be checked in
topic. This mechanism is critical for IoT applications involving the AWS console, and messages from the AWS console sent to
device telemetry and remote command and control. ‘esp32/sub‘ can be confirmed on the device’s Serial Monitor.
C ONCLUSIONS
This report has illustrated the effectiveness and accessibility
of the Arduino Integrated Development Environment (IDE),
which has made significant contributions to democratizing
electronics and programming. By facilitating a seamless inter-
face between hardware and software, Arduino enables a wide
range of possibilities in project development. The integration
of Arduino with AWS IoT was also discussed, showcasing the
straightforward process of connecting devices to the cloud and
enabling interactions within the Internet of Things. In sum-
mary, the Arduino IDE, paired with cloud solutions like AWS
IoT, provides a robust platform for educational, prototyping,
and hobbyist projects, empowering creators worldwide.

You might also like