feat(integration): uAgents IoT Connector (MQTT connection using ESP32, AWS IoT and Fetch.ai) #540
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
uAgent_IoT_Connector
Made by: Aleen Dhar
The uAgent IoT Connector bridges several powerful technologies to create a robust, real-time interaction framework between an ESP32 microcontroller, AWS EC2 instances, and Fetch.ai's DeltaV platform. The architecture is designed to facilitate data collection, processing, and control for sensors and GPS modules integrated into the ESP32. It uses MQTT, a lightweight messaging protocol, ensuring efficient, scalable, and low-latency communication for real-time applications.
Architecture Design
Key Components:
ESP32 Microcontroller: At the heart of this system, ESP32 is responsible for collecting sensor data from connected modules, including the MPU6050 (a motion-tracking device) and the Ublox Neo-6m GPS (for location tracking). The data is then transmitted via MQTT for further analysis or control operations.
AWS EC2 MQTT Broker: The communication backbone relies on an AWS EC2 instance running a Mosquitto MQTT Broker. This broker enables efficient and secure bidirectional communication between the ESP32 microcontroller and various clients, including a web-based frontend and the Fetch.ai platform. The broker facilitates the publish-subscribe model, allowing clients to either publish data or subscribe to relevant topics. Setup Guide
Node.js Socket Server & Next.js Frontend: A Node.js Socket server enables real-time communication between a Next.js frontend and the ESP32 via MQTT. This server sends requests and receives data, providing a user-friendly interface for monitoring sensor outputs or controlling the ESP32. The frontend acts as a control dashboard, visualizing real-time data and enabling actions on the ESP32 device. Checkout the Template here
Fetch.ai uAgent Integration: Fetch.ai’s uAgent communicates with the ESP32 system by subscribing to specific topic. I have created 2 agents one who can directly control(by publishing data to AWS EC2 mqtt broker) the ESP32 from DeltaV and one that is subscribed to the topic where ESP32 is publishing the Sensor data.
Sensor Modules:
Communication Flow:
Sensor Data Collection: The ESP32 collects real-time data from the MPU6050 motion sensor and the Ublox GPS module.
MQTT Publish/Subscribe:
Frontend Communication: The Node.js Socket server handles communication between the MQTT broker and the Next.js frontend, ensuring real-time data visualization and control capabilities.
Fetch.ai uAgent: The uAgent listens for specific events or requests and interacts with the ESP32 accordingly, leveraging the Fetch.ai DeltaV platform for additional computational or decision-making tasks.
Working on DeltaV
esp32.blink_command.using.DeltaV.mp4
Applications:
Conclusion:
This system architecture is a powerful example of how modern IoT solutions can integrate cloud platforms, microcontrollers, and decentralized agents to deliver scalable, efficient, and intelligent solutions. From sensor data collection to remote control via web and decentralized intelligence, this design is suitable for a variety of advanced applications including robotics, monitoring, and automation.
Setup
In the main directory install all dependencies