Differences

This shows you the differences between two versions of the page.

Link to this comparison view

iothings:proiecte:2025sric:airquality [2025/05/28 21:58]
ion_andrei.toader [Code Snippet]
iothings:proiecte:2025sric:airquality [2025/05/28 22:29] (current)
ion_andrei.toader [Web Application]
Line 150: Line 150:
 ====== Software Description ====== ====== Software Description ======
  
-The Air Sense Visualizer ​is a web application created to monitor and display air quality data in real time. It retrieves sensor readingssuch as PPM values from an air quality sensor—and presents them through a clean, user-friendly interface. The application is designed for development and educational use, offering a simple way to test, view, and analyze environmental data either locally or through connection with cloud-based platforms. Its structure is modular and flexible, making it easy to adapt to different use cases and hardware setups.+The Air Quality ​is a web application created to monitor and display air quality data in real time. It retrieves sensor readings such as PPM values from an air quality sensor—and presents them through a clean, user-friendly interface. The application is designed for development and educational use, offering a simple way to test, view, and analyze environmental data either locally or through connection with cloud-based platforms. Its structure is modular and flexible, making it easy to adapt to different use cases and hardware setups.
  
 ===== Code Snippet ===== ===== Code Snippet =====
  
   * Wi-Fi & Firebase Initialization   * Wi-Fi & Firebase Initialization
 +This part connects to Wi-Fi and initializes Firebase for anonymous sign-in and Realtime Database communication.
  
-''​#include <​WiFi.h>​+<​code>​ 
 + 
 +#include <​WiFi.h>​
 #include <​Firebase_ESP_Client.h>​ #include <​Firebase_ESP_Client.h>​
 #include "​addons/​TokenHelper.h"​ #include "​addons/​TokenHelper.h"​
 #include "​addons/​RTDBHelper.h"​ #include "​addons/​RTDBHelper.h"​
  
-#define WIFI_SSID "WI-FI HOME+#define WIFI_SSID "********
-#define WIFI_PASSWORD "TREB-15-HOME+#define WIFI_PASSWORD "**********
-#define API_KEY "AIzaSyD...+#define API_KEY "********
-#define DATABASE_URL "https://​air-qulaity-default-rtdb.europe-west1..."+#define DATABASE_URL "**********"
  
 FirebaseData fbdo; FirebaseData fbdo;
Line 188: Line 191:
   Firebase.begin(&​config,​ &auth);   Firebase.begin(&​config,​ &auth);
   Firebase.reconnectWiFi(true);​   Firebase.reconnectWiFi(true);​
-}''​+} 
 + 
 +</​code>​ 
 + 
 +  * Sensor Reading & Conversion 
 +Reads the analog value from the MQ-135 sensor, calculates Rs, and then converts that to a PPM (parts per million) estimate using a logarithmic formula. 
 + 
 +<​code>​ 
 +#define MQ135_PIN 34 
 +#define RZERO 116404.0 
 +#define RL_VALUE 10000.0 
 +#define PARA 116.6020682 
 +#define PARB -2.769034857 
 + 
 +void loop() { 
 +  int adcValue = analogRead(MQ135_PIN);​ 
 +  float sensor_voltage = adcValue * (3.3 / 4095.0); 
 +  float rs = (3.3 - sensor_voltage) * RL_VALUE / sensor_voltage;​ 
 +  float ratio = rs / RZERO; 
 +  float ppm = PARA * pow(ratio, PARB); 
 +
 + 
 +</​code>​ 
 + 
 +  * Buzzer Alert Logic 
 +Activates a buzzer if the air quality degrades beyond a certain threshold (800 PPM in this case). 
 + 
 +<​code>​ 
 +#define BUZZER_PIN 25 
 + 
 +void setup() { 
 +  pinMode(BUZZER_PIN,​ OUTPUT); 
 +  digitalWrite(BUZZER_PIN,​ HIGH); // buzzer off 
 +
 + 
 +void loop() { 
 +  // ... 
 +  if (ppm > 800) { 
 +    digitalWrite(BUZZER_PIN,​ LOW); // buzzer on 
 +  } else { 
 +    digitalWrite(BUZZER_PIN,​ HIGH); // buzzer off 
 +  } 
 +
 + 
 +</​code>​ 
 + 
 +  * Sending Data to Firebase 
 +Uploads the latest calculated PPM value to Firebase Realtime Database under the path /​air_quality/​ppm. 
 + 
 +<​code>​ 
 +if (Firebase.RTDB.setFloat(&​fbdo,​ "/​air_quality/​ppm",​ ppm)) { 
 +  Serial.println("​Data sent to Firebase"​);​ 
 +} else { 
 +  Serial.print("​Failed to send data: "); 
 +  Serial.println(fbdo.errorReason());​ 
 +
 + 
 +</​code>​ 
 +
 +===== Web Application ===== 
 + 
 +{{ :​iothings:​proiecte:​2025sric:​web_app_2.png?​direct&​300 |}} 
 + 
 + 
 + 
 + 
 + 
 + 
 +===== References =====
  
 +  * [[https://​www.instructables.com/​Air-Quality-ESP32-Build-a-Portable-IoT-Sensor/​]]
 +  * [[https://​www.hackster.io/​dudelabweb/​air-quality-monitoring-made-easy-an-iot-project-with-esp32-ee2777]]
 +  * [[https://​randomnerdtutorials.com/​esp32-firebase-web-app/#​install-vs-code]]
 +  * [[https://​randomnerdtutorials.com/​getting-started-with-esp32/​]]
 +  * https://​www.elprocus.com/​mq135-air-quality-sensor/​
iothings/proiecte/2025sric/airquality.1748458692.txt.gz · Last modified: 2025/05/28 21:58 by ion_andrei.toader
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0