New Final Micro
New Final Micro
New Final Micro
Submitted by:
Balana, Benard Gregg
Lopez, Jomer
Maitum, Queen Rochelyn
Submitted to:
ENGR. RANDY ANGELIA
DECEMBER 2023
Introduction
In the ever-evolving landscape of technology and the increasing
controlled system with an intruder alert that will help residential houses
to save power in their respective area and have security that ensures the
server. At the same time, there are added features: the intruder and
harmful gas alert. This is made possible by the use of the Arduino
controller. The user can access the web server anywhere and anytime
as long as there is internet. Gas can also be monitored there. When the
harmful gas level is reached, the system alerts that the level is
to the server with a specific date and time. The device also needs to be
connected to the internet. And lastly, the internet connection of the user
and the device needs to be strong, stable, and fast to ensure the
Objectives
The objective of this research is to delve into the realm of time-
saving:
Scheduling of loads:
allows the user to control and monitor the use of electronic equipment
that will transmit alerts to the home's owner through the Internet
continuously monitor the air quality for potentially harmful gases, causing
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <LiquidCrystal_I2C.h>
#include<Wire.h>
// Pin configurations
int lightPin1 = 2; // GPIO pin for Light 1
int lightPin2 = 4; // GPIO pin for Light 2
int lightPin3 = 5; // GPIO pin for Light 3
int buzzerPin = 14; // GPIO pin for the buzzer
int mq2Pin = 32; // Analog input pin for MQ-2
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pinMode(lightPin1, OUTPUT);
pinMode(lightPin2, OUTPUT);
pinMode(lightPin3, OUTPUT);
pinMode(buzzerPin, OUTPUT);
// initialize LCD
lcd.init();
// turn on LCD backlight
lcd.backlight();
void loop() {
Blynk.run();
checkSmoke();
}
BLYNK_WRITE(V0) {
int value = param.asInt();
digitalWrite(lightPin1, value);
}
BLYNK_WRITE(V1) {
int value = param.asInt();
digitalWrite(lightPin2, value);
}
BLYNK_WRITE(V2) {
int value = param.asInt();
digitalWrite(lightPin3, value);
}
void checkSmoke() {
int sensorValue = analogRead(mq2Pin);
Serial.print("MQ-2 Sensor Value: ");
Serial.println(sensorValue);
// You may need to adjust this threshold depending on your sensor and environment
Blynk.virtualWrite(V4, sensorValue); // Send the sensor value to the Gauge Widget (V4)
lcd.clear();
// set cursor to first column, first row
lcd.setCursor(0, 0);
// print message
lcd.print(" Attention!");
lcd.setCursor(0,1);
lcd.print(" GAS LEAK");
} else {
Blynk.virtualWrite(V3, 0); // Send a value of 0 to clear the notification in the Blynk app
digitalWrite(buzzerPin, LOW); // Turn off the buzzer
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("NO LEAK");
}
}
CODE 2
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
#include "esp_camera.h"
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>
#include <TFT_eSPI.h>
TFT_eSPI tft;
WiFiClientSecure clientTCP;
UniversalTelegramBot bot(BOTtoken, clientTCP);
#define FLASH_LED_PIN 4
bool flashState = LOW;
// the time we give the sensor to calibrate (approx. 10-60 secs according to datatsheet)
const int calibrationTime = 30; // 30 secs
//CAMERA_MODEL_AI_THINKER
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
void configInitCamera() {
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
delay(1000);
ESP.restart();
}
// Drop down frame size for higher initial frame rate
sensor_t * s = esp_camera_sensor_get();
s->set_framesize(s, FRAMESIZE_CIF);
s->set_vflip(s, true);
}
String sendPhotoTelegram() {
const char* myDomain = "api.telegram.org";
String getAll = "";
String getBody = "";
camera_fb_t * fb = NULL;
fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Camera capture failed");
delay(1000);
ESP.restart();
return "Camera capture failed";
}
if (clientTCP.connect(myDomain, 443)) {
Serial.println("Connection successful");
clientTCP.print(tail);
esp_camera_fb_return(fb);
void setup() {
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
// Init Serial Monitor
Serial.begin(115200);
// Initialize TFT display
tft.init();
// Connect to Wi-Fi
WiFi.mode(WIFI_STA);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
clientTCP.setCACert(TELEGRAM_CERTIFICATE_ROOT); // Add root certificate for api.telegram.org
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("ESP32-CAM IP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {
val = digitalRead(PIRsensor);
if (val == HIGH) {
digitalWrite(led, HIGH);
if (PIRstate == LOW) {
// we have just turned on because movement is detected
Serial.println("Motion detected!");
delay(500);
Serial.println("Sending photo to Telegram");
sendPhotoTelegram();
PIRstate = HIGH;
}
}
else if (sendPhoto) {
Serial.println("Preparing photo");
digitalWrite(FLASH_LED_PIN, HIGH);
Serial.println("Flash state set to HIGH");
delay(500);
sendPhotoTelegram();
sendPhoto = false;
digitalWrite(FLASH_LED_PIN, LOW);
Serial.println("Flash state set to LOW");
}
else if (millis() > lastTimeBotRan + botRequestDelay) {
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
while (numNewMessages) {
Serial.println("got response");
handleNewMessages(numNewMessages);
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
}
lastTimeBotRan = millis();
}
else {
digitalWrite(led, LOW);
if (PIRstate == HIGH) {
Serial.println("Motion ended!");
PIRstate = LOW;
}
}
}
Documentation
References
[1] Hybrid Solar Energy System as
Alternative Power Supply in Mindanao
State University-Sulu: Impact on Quality Services
https://journalsocialsciences.com/index.php/oaijss/article/view/63
[2] PV Energy Performance in a Sustainable Campus https://www.mdpi.com/2079-
9292/9/11/1874
[3] Feasibility Study on the Installation of Solar Photovoltaic Rooftop System for the Pangasinan
State University https://www.semanticscholar.org/paper/FeasibilityStudy-on-the-Installation-
of-Solar-forPereyras/e27f7bdacc45ef3f1e035870b899de3e7ea1c100
[4] Sustainable Solar Energy in Mexican Universities. Case Study: The National School of Higher
Studies Juriquilla (UNAM) https://www.mdpi.com/2071- 1050/12/8/3123
[5] “How To - How Solar Panels Work,” Live Science Forums, Mar. 26, 2020.
https://forums.livescience.com/threads/how-solar-panels-work.1659/ (accessed Dec. 15,
2023).
[6] “ASU Solar | Arizona State University,” cfo.asu.edu. https://cfo.asu.edu/solar
[7] “Solar power| Environment America,” Solar power (environmentamerica.org