You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wenfei 346cce37a8 esp32 add new file 3 days ago
..
esp32_DS18B20_temp_chart esp32 add new file 3 days ago
esp32_connect_mqtt.ino esp32 add new file 3 days ago
README.md esp32 add new file 3 days ago
README_ZH.md esp32 add new file 3 days ago
broker.emqx.io-ca.crt esp32 add new file 3 days ago
emqxsl-ca.crt esp32 add new file 3 days ago
esp32_DS18B20_sensor_via_tls.ino esp32 add new file 3 days ago
esp32_connect_mqtt_via_tls.ino esp32 add new file 3 days ago
esp32_soil_moisture_sensor_via_tls.ino esp32 add new file 3 days ago

README.md

ESP32 MQTT Client Examples

In this example we provide sample code for TCP protocol connection to the MQTT Broker. For more documentation on using the ESP32 MQTT client, see the Pubsubclient Documentation.

Prerequisites

Arduino settings

  • Installing the ESP32 Board
Tools -> Board -> Boards Manager... -> -> Type ESP32 in Search field -> Install
  • Installing the PubSubClient Library
Sketch -> Include Library -> Manage Libraries... -> Type PubSubClient in Search field -> Install PubSubClient by Nick OLeary

Ino File

  • esp32_connect_mqtt.ino: ESP32 connects to the MQTT broker
  • esp32_connect_mqtt_via_tls.ino: ESP32 connects to the MQTT broker via TLS
  • esp32_DS18B20_temp_chart: ESP32 connects to the MQTT broker and uploads DS18B20 temperature sensor data, while displaying the temperature chart in real time
  • esp32_DS18B20_sensor_via_tls.ino: ESP32 connects to the MQTT broker via TLS and uploads DS18B20 temperature sensor data
  • esp32_soil_moisture_sensor_via_tls.ino: ESP32 connects to the MQTT broker via TLS and uploads soil moisture sensor data

TLS Config

For TLS connection example code, the default includes DigiCert Global Root G2 (broker.emqx.io.crt) and DigiCert Global Root CA (emqxsl-ca.crt) ca_cert certificates, please modify according to the usage scenario.