Constructing an MQTT Publish topic and payload in ESP32
In the previous chapter, we introduced two standard Arduino libraries related to TLS/MQTT functionality. The WiFiClientSecure.h
library is used to set up a TLS connection, while the PubSubClient.h
library is used for MQTT publish.
In this chapter, we will introduce another Arduino library, ArduinoJson.h
. This library is used to construct a JSON document and serialize it for transmission to AWS IoT Core.
ArduinoJson.h is a versatile C++ library used for parsing, serializing, and manipulating JSON data on microcontrollers such as the ESP32, making it ideal for IoT applications. It’s designed with memory efficiency, ease of use, and flexibility in mind, making it a popular choice among developers. To use it in a PlatformIO project, include it in your platformio.ini
file under lib_deps
. Then, incorporate it into your source code with #
include <ArduinoJson.h>
.
We will manually install this library in Platform...