|
ESP32 MQTT IoT Communication
|
The aim of the project was to communicate between an ESP32 microcontroller, a MQTT Broker Running on a raspberry pi and a desktop PC.
Microcontroller
ESP32_DevKitc_v4 was used, this was chosen due to the inbuilt wifi and bluetooth capabilitiesbblanchon/ArduinoJson@^7.1.0 For onboard JSON Encodingknolleary/PubSubClient@^2.8 for communicating with MQTT brokerMQTT Broker
Database
sqlite3 - C library that provides a lightweight disk based databasejson - Library that can encode dictionaries into JSON Objectspaho-mqtt - Library that provides a class which enables applications to communicate with an MQTT BrokerOnce all the credentials are inplace and everything is setup all that needs to be done for the ESP32 to communicate with the RPI is just to Power the RPI and ESP32.
In order to start inserting recieved readings and ID packets into the database simply run the following command from within the virtual environment.

Crude functionality to view the readings stored in the data base is available, simply run

Step 0 Install the prerequisites
Step 1 clone the Repository
Step 2 Create a virtual Environment
Step 3 Install Python Libraries
Step 4 Setup Mosquitto on a Raspberry Pi (The Guide I used)
Step 5 Replace variables with the correct values (Sensitive data such as IPs, SSIDs and router passwords have been replaced by X's)
Step 6 Using PlatformIO build and flash the firmware onto the ESP32
Step 7 Run server/db/db.py to generate the database and server/mqtt_sub.py to connect to the database and input data
Distributed under the MIT Licesnse. See LICENSE.txt for more information.