DEV Community

Uthsob Chakraborty
Uthsob Chakraborty

Posted on

Creating an IoT Device Frontend: A High-Level Overview

Recently, I had the opportunity to work on a university project focused on building a Smart Dustbin. Although I can't share specific code snippets or show the actual device nor the frontend screenshot due to project restrictions, I’m excited to provide a high-level overview of how the project was structured, the technologies we used, and the challenges we faced. Below, you’ll find the high-level architecture that guided our work:

Data Flow

Project Overview

The idea behind the Smart Dustbin is simple yet powerful: to create an intelligent waste management system that monitors the fill level of a dustbin, measures various environmental parameters, and alerts stakeholders when the dustbin needs to be emptied. Here's how we approached the project.

Tech Stack Breakdown

Our project was divided into three main components: the IoT device, the server, and the frontend dashboard. Let’s dive into the details of each component:

1. IoT Device

The IoT device was designed and managed by a friend of mine, who did a fantastic job handling the hardware aspect of the project. Here's what was involved:

  • Hardware: We used a NodeMCU microcontroller, which provides built-in Wi-Fi support, making it ideal for connecting to the MQTT server.
  • Programming Language: The entire code for the device was written in C++.
  • Data Transmission: The NodeMCU collected data such as trash level, gas concentrations (CO2, O2, NH4), and GPS coordinates. This data was then sent to an MQTT server over a wireless connection.

2. Server

The server played a pivotal role in our project. Its main functions were to manage real-time data, store it in a database, and communicate with the frontend.

  • Server Setup: We used Node.js to build the server, which allowed us to handle multiple connections efficiently.
  • Real-Time Communication: For real-time data updates, we leveraged Socket.IO, enabling the server to push data directly to the frontend.
  • Database & Authentication: We chose Firebase as our backend service for both data storage and authentication. Firebase's flexibility allowed us to store sensor readings and manage user authentication seamlessly.

3. Frontend

The frontend was the core of the project, where most of the data visualization and user interactions were handled. It involved extracting meaningful data from server responses and presenting it in a user-friendly manner.

  • Data Handling: The server sent a string of data through MQTT and Socket.IO. I extracted the necessary information and stored it in variables for further processing.
  • Data Visualization: The data received from the device and server included:

    1. Level of Trash: Displayed using a gauge meter to visually represent how full the dustbin was.
    2. Coordinates (Latitude and Longitude): Used to pinpoint the exact location of the dustbin on a map.
    3. Gas Levels (CO2, O2, NH4): Each gas level was shown in separate sections using individual gauge meters for clarity.
  • Key Functionalities:

    • Trash Level Monitoring: The trash level was constantly checked to see if it exceeded 75%. If it did, an automated email was triggered to notify the relevant parties, including the current location of the dustbin.
    • Mapping: Using the Leaflet.js library, I integrated the latitude and longitude data to display the dustbin's location on an interactive map using OpenStreetMap.
    • Gas Monitoring: Each gas sensor reading was visualized using distinct gauges to allow easy monitoring of environmental parameters.

Challenges and Solutions

  1. Parsing String Data: The server sent data as a single string, so I had to develop custom logic to parse it and extract each data type (trash level, coordinates, gas levels). Careful parsing was crucial for maintaining data accuracy.

  2. Real-Time Updates: Displaying real-time data while ensuring smooth user interaction was challenging. Leveraging Socket.IO allowed me to deliver instantaneous updates without affecting the UI's responsiveness.

  3. Visualizing Sensor Data: Making sensor data comprehensible required well-thought-out visual elements. Using gauge meters provided an intuitive way to present real-time changes, especially for trash levels and gas concentrations.

Results and Achievements

The final product was a fully functioning Smart Dustbin system that provided live updates on the trash fill level, monitored various environmental parameters, and used map integration to show its exact location. Here's a summary of what we achieved:

Image description

Here is how it looks. As i mentioned earlier i can't really add device picture nor the code.

  • Live Data Monitoring: Real-time monitoring of trash levels and gas concentrations.
  • Automated Alerts: Email notifications when the trash level exceeded a certain threshold.
  • Geolocation Tracking: Real-time location updates of the dustbin on an interactive map.
  • User-Friendly Dashboard: A clean and informative UI that made it easy to monitor and manage data.

Conclusion

This project was a fantastic opportunity to work with real-time data and build an IoT application from the ground up. It provided valuable hands-on experience with technologies like MQTT, Node.js, Socket.IO, Firebase, and React. Each component brought unique challenges, but by leveraging the strengths of each technology, we were able to create a seamless system that effectively managed and displayed real-time IoT data.

Building a Smart Dustbin might sound simple, but the complexity lies in ensuring all the moving parts work together efficiently. It was an enriching project, and I hope this overview gives you an idea of how you can approach similar IoT projects with a real-time data focus.

Top comments (0)