Window opener, based on gas detection

  • Author: Neaga Matei
  • Email: mateineaga@outlook.com, matei.neaga@stud.mec.upb.ro
  • Master: IA

Introduction

This project aims to build a setup based on a servomechanism and a sensor MQ-5, with the purpose of opening a window in case the gas concentration rises above a desired value.

Context

Block diagram of the project

Flowchart of the project

Hardware

  • ESP32 board
  • MQ-4 sensor, detecting SnO2
  • SG90 servomechanism
  • microusb - usb A cable
  • dupont cables

Software

Code snippets

#include <WiFi.h>
#include <WebServer.h>
#include <ESP32Servo.h>
 
const char* ssid = "";
const char* password = "";
 
#define ANALOG_PIN 34  // Pinul conectat la AO al senzorului MQ-4
#define SERVO_PIN 13   // Pinul conectat la servomotor
 
int valoare_analogica = 0;
String nivelGaz = "";
String culoareNivel = "green";
bool servoActiv = false;
bool modAutomat = true;
int pragActivare = 800;  
 
Servo myservo;
void loop() {
  server.handleClient();
 
 
  valoare_analogica = analogRead(ANALOG_PIN);
 
 
  if (modAutomat) {
    if (valoare_analogica >= pragActivare && !servoActiv) {
      activeazaServo();
    } else if (valoare_analogica < pragActivare && servoActiv) {
      dezactiveazaServo();
    }
  }
 
  delay(100); 
}
 
// Funcție pentru activarea servomotorului
void activeazaServo() {
  myservo.write(90); 
  servoActiv = true;
  Serial.println("Servo activat!");
}
 
// Funcție pentru dezactivarea servomotorului
void dezactiveazaServo() {
  myservo.write(0); 
  servoActiv = false;
  Serial.println("Servo dezactivat!");
}

Challenges

Figuring out a way to design the webpage to allow me to switch the servomechanism to “automated” or “manual” mode.

References

-

iothings/proiecte/2025sric/windowopener.txt · Last modified: 2025/05/18 18:18 by matei.neaga
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