Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino Code for Level Monitoring using Buzzer #59

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/logo-icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo1-icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions hardware/Arduino_Level_Buzzer_Code.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#define trigPin 8 //ultrasonic sensor
#define echoPin 9
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int BUZZER = 10 ;

void setup(){
int duration,distance,percentage,heightTank;
Serial.begin (9600);
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
lcd.begin(16,2);
lcd.print("HELLO");
pinMode(BUZZER,OUTPUT);
}

void loop(){
int duration,distance,percentage,heightTank,deviation;
// We can change the next 2 lines.
// The first one is the max. level of the water.
// The next one is how high the sensor is above that max. level.
heightTank=65;
deviation=4;

digitalWrite(trigPin,HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin,LOW);
duration=pulseIn(echoPin,HIGH);
distance=(duration/2)/29.1;
percentage=100-(((distance-deviation)*100)/heightTank);
Serial.println(distance);
Serial.println(percentage);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Current tank");
//lcd.print(distance);
//lcd.print(" cm");
lcd.setCursor(0,1);
lcd.print("level: ");
lcd.print(percentage);
lcd.print(" %");
delay(1000);

digitalWrite(BUZZER,HIGH);
static unsigned long lastBuzzer = 0;

if(percentage > 99 && lastBuzzer == 0) {
lastBuzzer = millis();
}

if(percentage > 99) {
if(millis() - lastBuzzer < 15000L) {
digitalWrite(BUZZER,HIGH);
delay(100);
digitalWrite(BUZZER,LOW);
delay(100);
}
} else {
digitalWrite(BUZZER,LOW);
lastBuzzer = 0;
}
}
23 changes: 23 additions & 0 deletions hardware/Arduino_Timer_wakeup.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
To use the timer wake up with ESP8266, we need to connect the RST pin to GPIO 16 which is labeled as D0, in a NodeMCU board
Code to be uploaded to ESP866
*/

void setup() {
Serial.begin(115200);
Serial.setTimeout(2000);

// Wait for serial to initialize.
while(!Serial) { }

// Deep sleep mode for 30 seconds, the ESP8266 wakes up by itself when GPIO 16 (D0 in NodeMCU board) is connected to the RESET pin, the time can be changed as required
Serial.println("I'm awake, but I'm going into deep sleep mode for 30 seconds");
ESP.deepSleep(30e6); //30e6 corresponds to 30000000 microseconds which is equal to 30 seconds.

// Deep sleep mode until RESET pin is connected to a LOW signal
//Serial.println("I'm awake, but I'm going into deep sleep mode until RESET pin is connected to a LOW signal");

}

void loop() {
}