Skip to content

Commit

Permalink
EEE expo 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
Avishek8136 committed Aug 25, 2023
0 parents commit a179774
Show file tree
Hide file tree
Showing 52 changed files with 18,018 additions and 0 deletions.
Binary file added 22AIE114_Future_Work_A12.docx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include <Servo.h>

#define SERVO_PIN 9
#define TRIG_PIN 2
#define ECHO_PIN 3
#define GAS_SENSOR_PIN A0 // Analog input pin for the MQ2 gas sensor
#define LM35_SENSOR_PIN A1 // Analog input pin for the LM35 temperature sensor

Servo servo;

void setup() {
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(GAS_SENSOR_PIN, INPUT); // Set the gas sensor pin as input
pinMode(LM35_SENSOR_PIN, INPUT); // Set the LM35 temperature sensor pin as input
servo.attach(SERVO_PIN);
Serial.begin(9600); // Initialize the serial communication
}

void loop() {
// Call the function to continuously rotate the servo motor
rotateServo();

// Call the function to measure and display the distance on the serial plotter
measureDistanceAndPlot();

// Call the function to measure and display the gas sensor reading on the serial plotter
measureGasSensorAndPlot();

// Call the function to measure and display the LM35 temperature sensor reading on the serial plotter
measureTemperatureAndPlot();
}

void rotateServo() {
for (int angle = 0; angle <= 45; angle++) {
servo.write(angle);
delay(30); // Adjust the speed of rotation if needed
}
for (int angle = 45; angle >= 0; angle--) {
servo.write(angle);
delay(30); // Adjust the speed of rotation if needed
}
}

void measureDistanceAndPlot() {
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);

long duration = pulseIn(ECHO_PIN, HIGH);
int distance = duration * 0.034 / 2; // Convert the duration to centimeters (Speed of sound in air is approximately 34 cm/ms)

Serial.print("Distance: ");
Serial.print(distance); // Send the distance value to the serial plotter
Serial.print(" cm \t");
}

void measureGasSensorAndPlot() {
int gasSensorValue = analogRead(GAS_SENSOR_PIN); // Read the analog value from the gas sensor

Serial.print("Gas Sensor Value: ");
Serial.print(gasSensorValue); // Send the gas sensor value to the serial plotter
Serial.print("\t");
}

void measureTemperatureAndPlot() {
int lm35SensorValue = analogRead(LM35_SENSOR_PIN); // Read the analog value from the LM35 temperature sensor
float voltage = lm35SensorValue * (5.0 / 1023.0); // Convert the analog value to voltage
float temperatureC = (voltage - 0.5) * 100.0; // Calculate temperature in Celsius

Serial.print("Temperature: ");
Serial.print(temperatureC); // Send the temperature value to the serial plotter
Serial.println(" °C");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include <Wire.h>
#include <SoftwareSerial.h>
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
// D6 = Rx & D5 = Tx
SoftwareSerial nodemcu(D6, D5);
//intiliazing wifi module to send the telegrm messages
const char* ssid = "Avishek"; // Enter your WIFI SSID
const char* password = "eeeproject"; // Enter your WIFI Password
#define BOTtoken "6598907365:AAHzMOd_MuAUUKnAHqd9JSt8djXO8mOuMw4" // Enter the bottoken you got from botfather
#define CHAT_ID "211246197" // Enter your chatID you got from chatid bot
X509List cert(TELEGRAM_CERTIFICATE_ROOT);
WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);
//end of telegram messsnage intialization
void setup() {
// Initialize Serial port
Serial.begin(9600);
nodemcu.begin(9600);
//intialize lcd port
while (!Serial) continue;
// Serial.begin(115200);
configTime(0, 0, "pool.ntp.org");
client.setTrustAnchors(&cert);

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
int a = 0;
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
a++;
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
bot.sendMessage(CHAT_ID, "Wifi Connected!", "");
bot.sendMessage(CHAT_ID, "System has Started!!", "");
}
void loop() {
StaticJsonDocument<1000> jsonBuffer;
DeserializationError error = deserializeJson(jsonBuffer, nodemcu);
if (error) {
Serial.println("Error parsing JSON");
jsonBuffer.clear();
return;
}
// Check if the received data is an object
if (!jsonBuffer.is<JsonObject>()) {
Serial.println("Invalid JSON Object");
jsonBuffer.clear();
return;
}
JsonObject data = jsonBuffer.as<JsonObject>();
Serial.println("-----------------------------------------");
//jsonBuffer.clear();
Serial.println("Json object Recieved..");
float distance=data["distance"];
String a =String (distance);
Serial.print("Recieved Status :");
Serial.println("fire");
Serial.print("Direction ::");
Serial.print("status");
bot.sendMessage(CHAT_ID,a ,"");
jsonBuffer.clear();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#include <Servo.h>
#include <ArduinoJson.h>

Servo myservo;

#define SERVO_PIN 11
#define TRIG_PIN 2
#define ECHO_PIN 3
#define GAS_SENSOR_PIN A0 // Analog input pin for the MQ2 gas sensor
#define LM35_SENSOR_PIN A1 // Analog input pin for the LM35 temperature sensor

int pos = 0;
boolean fire = false;
int sign = 0;

void setup() {
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(GAS_SENSOR_PIN, INPUT);
pinMode(LM35_SENSOR_PIN, INPUT);
servo.attach(SERVO_PIN);
Serial.begin(9600); // Initialize the serial communication with the PC
Serial1.begin(9600); // Initialize the serial communication with ESP8266
delay(1000);
Serial.println("Program started");
}

void loop() {
// Call the function to continuously rotate the servo motor
rotateServo();

// Read sensor data
int distance = measureDistance();
int gasSensorValue = analogRead(GAS_SENSOR_PIN);
float temperatureC = measureTemperature();

// Send sensor data to ESP8266
transferData(distance, gasSensorValue, temperatureC);

// Call the function to measure and display the distance on the serial plotter
measureDistanceAndPlot();

// Call the function to measure and display the gas sensor reading on the serial plotter
measureGasSensorAndPlot();

// Call the function to measure and display the LM35 temperature sensor reading on the serial plotter
measureTemperatureAndPlot();

delay(1000); // Adjust delay as needed
}

void rotateServo() {
for (int angle = 0; angle <= 90; angle++) {
myservo.write(angle);
delay(15); // Adjust the speed of rotation if needed
}
for (int angle = 90; angle >= 0; angle--) {
myservo.write(angle);
delay(15); // Adjust the speed of rotation if needed
}
}

int measureDistance() {
// Measure and return distance
// ...
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);

long duration = pulseIn(ECHO_PIN, HIGH);
int distance = duration * 0.034 / 2; // Convert the duration to centimeters (Speed of sound in air is approximately 34 cm/ms)

Serial.print("Distance: ");
Serial.print(distance); // Send the distance value to the serial plotter
Serial.print(" cm \t");

}

float measureTemperature() {
// Measure and return temperature
// ...
}

void transferData(int distance, int gasSensorValue, float temperatureC) {
StaticJsonDocument<200> jsonBuffer;
JsonObject data = jsonBuffer.to<JsonObject>();
data["distance"] = distance;
data["gasValue"] = gasSensorValue;
data["temperature"] = temperatureC;

Serial1.print("Data:"); // Prefix to identify the data
serializeJson(data, Serial1); // Send JSON data to ESP8266
Serial1.println(); // End the data transmission
jsonBuffer.clear();
}

// The rest of your existing code for measuring and plotting sensor values goes here...
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#include <Wire.h>
#include <SoftwareSerial.h>
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>

// D6 = Rx & D5 = Tx
SoftwareSerial nodemcu(D6, D5);

const char* ssid = "Avishek";
const char* password = "eeeproject";
#define BOTtoken "6598907365:AAHzMOd_MuAUUKnAHqd9JSt8djXO8mOuMw4"
#define CHAT_ID "211246197"

X509List cert(TELEGRAM_CERTIFICATE_ROOT);
WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);

void setup() {
Serial.begin(9600);
nodemcu.begin(9600);

while (!Serial) continue;

configTime(0, 0, "pool.ntp.org");
client.setTrustAnchors(&cert);

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}

Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

bot.sendMessage(CHAT_ID, "Wifi Connected!", "");
bot.sendMessage(CHAT_ID, "System has Started!!", "");
}

int animalCount = 0;
String animalType;

void loop() {
StaticJsonDocument<1000> jsonBuffer;
DeserializationError error = deserializeJson(jsonBuffer, nodemcu);

if (error) {
Serial.println("Error parsing JSON");
jsonBuffer.clear();
return;
}

if (!jsonBuffer.is<JsonObject>()) {
Serial.println("Invalid JSON Object");
jsonBuffer.clear();
return;
}

JsonObject data = jsonBuffer.as<JsonObject>();
Serial.println("-----------------------------------------");
Serial.println("Json object Received..");
int count = data["count"];
String type = data["type"];

if (count > 0) {
Serial.print("Received Animal Count: ");
Serial.println(count);
Serial.print("Animal Type: ");
Serial.println(type);

animalCount = count;
animalType = type;

String message = "Wildlife Detected!\n";
String countMessage = "Number of Animals Detected: " + String(animalCount) + "\n";
String typeMessage = "Animal Type: " + animalType + "\n";
String finalMessage = message + countMessage + typeMessage;

bot.sendMessage(CHAT_ID, finalMessage, "");
} else {
Serial.println("No wildlife detected.");
animalCount = 0;
animalType = "";
}

jsonBuffer.clear();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import telebot

# Replace 'YOUR_API_TOKEN' with your actual Telegram Bot API token
API_TOKEN = '6598907365:AAHzMOd_MuAUUKnAHqd9JSt8djXO8mOuMw4'
bot = telebot.TeleBot(API_TOKEN)

@bot.message_handler(func=lambda message: True)
def print_chat_id(message):
print("Chat ID:", message.chat.id)

bot.polling()
Loading

0 comments on commit a179774

Please sign in to comment.