Carbon Monoxide Reader On Mobile App(IoT project)
The Carbon Monoxide Reader project aims to develop a robot that monitors carbon monoxide (CO) levels and reports the data to a mobile application using the Blynk platform. This integration allows for real-time data visualization and alerts through a WiFi connection, enhancing safety by providing timely notifications of dangerous CO levels. The project leverages components such as the ESP32, a CO sensor, and an LCD for local display, combined with the Blynk app for remote monitoring. This project highlights the practical applications of IoT in environmental monitoring and mobile app interfacing with microcontrollers.
Project : 9
Introduction
The Carbon Monoxide Reader project aims to develop a robot
that monitors carbon monoxide (CO) levels and reports the data to a mobile
application using the Blynk platform. This integration allows for real-time
data visualization and alerts through a WiFi connection, enhancing safety by
providing timely notifications of dangerous CO levels. The project leverages
components such as the ESP32, a CO sensor, and an LCD for local display,
combined with the Blynk app for remote monitoring. This project highlights the
practical applications of IoT in environmental monitoring and mobile app
interfacing with microcontrollers.
Components Required
ESP32:
A microcontroller with built-in WiFi and Bluetooth capabilities.
- CO
Sensor: For detecting carbon monoxide levels in the environment.
- LiquidCrystal_I2C
Display: To display sensor data and status messages locally.
- Power
Supply: Typically a battery pack to power the ESP32 and sensor.
- Connecting
Wires: For connecting all components.
Pin Configuration
- Sensor
Pin:
- Sensor_PIN:
34
- LCD
Pins: Connected via I2C
Libraries Used
- BlynkSimpleEsp32:
For interfacing with the Blynk platform.
- Wire:
For I2C communication.
- WiFi:
For WiFi connectivity.
- LiquidCrystal_I2C:
For interfacing with the LCD display.
Circuit Diagram:
Code:
//Copy the blynk
credential from your account device and paste it here
#define
BLYNK_TEMPLATE_ID "TMPL670BbO1Nl"
#define
BLYNK_TEMPLATE_NAME "Data Monitoring"
#define
BLYNK_AUTH_TOKEN "4Q5w-qYfY3jO82qXBaL3O0E3irLFfDwb"
#define BLYNK_PRINT
Serial
#include
<BlynkSimpleEsp32.h>
#include
<Wire.h>
#include
<WiFi.h>
#include
<LiquidCrystal_I2C.h>
LiquidCrystal_I2C
lcd(0x27, 16, 2);
#define Sensor_PIN 34
char auth[] =
BLYNK_AUTH_TOKEN;
char ssid[] =
"nepatronix_2.4"; //Enter your
WIFI SSID name
char pass[] =
"CLB269DA03"; //Enter your
WIFI password
BlynkTimer timer;
void notify() {
int value = analogRead(Sensor_PIN);
Serial.println(value);
Blynk.virtualWrite(V1, value);
display(1, 1, String(value));
// if
(value == 800) { // If 1 receive then turn ON
//
display(1, 1, "Toxic Air");
//
Blynk.logEvent("intruder_alert", "Intruder
Detected");
// }
else {// Else turn OFF
//
display(1, 1, "Noraml air");
// }
delay(100);
}
void setup() {
Serial.begin(9600);
Wire.begin();
lcd.init();
lcd.clear();
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("**NEPATRONIX**");
delay(2000);
lcd.clear();
pinMode(Sensor_PIN, INPUT);
display(1, 0, "Carbon MonoOxide:
");
Blynk.begin(auth, ssid, pass); //Connecting
to Blynk Server with ssid and password
delay(500);
Serial.println(WiFi.localIP());
timer.setInterval(100L, notify);
}
void loop() {
Blynk.run(); //run the blynk function in loop
timer.run();
}
void display(int col,
int row, String msg) {
lcd.setCursor(col, row);
lcd.print(msg);
}
Working
- Initialization:
- The
ESP32 initializes serial communication at a baud rate of 9600.
- The
I2C LCD display is initialized, and a welcome message is displayed.
- The
ESP32 connects to the Blynk server using the provided credentials (auth
token, WiFi SSID, and password).
- The
sensor pin is configured as an input.
- Main
Loop:
- The
program runs the Blynk and timer functions continuously.
- The
notify function is called at regular intervals to read the sensor value,
display it on the LCD, and send it to the Blynk app.
- The Blynk
platform is used to monitor the sensor data and potentially trigger
alerts.
- Sensor
Data Monitoring:
- The
notify function reads the CO sensor value using analogRead.
- The
value is printed to the serial monitor, displayed on the LCD, and sent to
the Blynk virtual pin V1.
- Additional
logic can be added to trigger alerts based on the sensor readings.
Testing
Setup:
Assemble the components and connect them as per the pin configuration.
- Power
Up: Turn on the power supply and ensure the ESP32 and sensor are receiving
power.
- WiFi
Connection: Ensure the ESP32 is connected to the specified WiFi
network.
- Blynk
App: Configure the Blynk app with the provided template ID and auth
token.
- Commands:
Test the sensor data monitoring and ensure that the data is correctly displayed
on the LCD and sent to the Blynk app.
- Display:
Verify the LCD shows accurate CO levels and status messages.
- Alerts:
Test the alert functionality by simulating high CO levels if applicable.
Conclusion
The Carbon Monoxide Reader project successfully demonstrates
the integration of WiFi communication, sensor data monitoring, and remote
control using the Blynk platform. By leveraging the ESP32 microcontroller and
various components, the project provides a practical application in
environmental monitoring. Users gain hands-on experience in IoT, mobile app
interfacing, and sensor data visualization, laying a foundation for more
advanced projects in the future. This project enhances safety by providing
timely notifications of dangerous CO levels, showcasing the importance of IoT
in modern environmental monitoring systems.