This code adds a storage library that you can use to get or create a unique device ID for your device. This is especially relevant for MQTT, where brokers typically required devices to have unique device IDs. The code is explained in the YouTube video MQTT - ESP32 Unique Device IDs with Preferences.h.
👉 Subscribe to the OhioIoT YouTube Channel for more on "All Things IoT": hardware, firmware, connectivity, cloud computing, and dev toolkit.
git clone https://github.com/OhioIoT-MQTT-Examples/ESP32-Unique-Device-ID
- Change lib/credentials/credentials_template to lib/credentials/credentials.h, and edit the credentials
- Compile and upload your code
- Copy all folders in lib/ to your Arduino libraries/ folder
- Copy credentials/credentials_template to credentials/credentials.h, and edit the credentials
- Create a project folder, and copy src/main.cpp into that folder with a name that matches, ending in *.ino
- Download PubSubClient.h using the Arduino IDE Library Manager
- Copy all of the files from the subfolders inside lib/ into the same project folder created above, and keep all of the files, including the *.ino, together
OhioIoT is an IoT platform designed for small-scale IoT projects (https://www.ohioiot.com).