Devices & Components
16x2 LCD display with I²C interface
Arduino Nano
Arduino Uno Rev3
5 mm LED: Red
Keypad (4x4)
SPST Switch
IR Remote
SG90 Micro-servo motor
Jumper wires (generic)
NodeMCU ESP8266 Breakout Board
5 mm LED: Green
MLX90614
High Bright Leds
Ultrasonic Sensor - HC-SR04 (Generic)
9V battery (generic)
Graphic OLED, 128 x 64
IR receiver (generic)
DHT22 temperature-humidity sensor
Wires (Single Stand Wires)
Resistor 10k ohm
Hardware & Tools
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Hot glue gun (generic)
Soldering iron (generic)
Software & Tools
Arduino IDE
Blynk
Project description
Code
Adafruit GFX Library
MLX90614 Library
LCD I2C Library
Arduino Uno-1
arduino
Main Door System
1#include <DHT.h> 2#include <LiquidCrystal_I2C.h> 3#include<Keypad.h> 4#include<Servo.h> 5#include<Wire.h> 6#include<SparkFunMLX90614.h> 7#include <Adafruit_GFX.h> 8#include <Adafruit_SSD1306.h> 9 10LiquidCrystal_I2C lcd(0x27, 16, 2); 11Servo myservo; 12IRTherm therm; 13 14#define LED_RED 11 //Main door Red_LED 15#define LED_GREEN 12 //Main door Green_LED 16 17#define SCREEN_WIDTH 128 // OLED display width, in pixels 18#define SCREEN_HEIGHT 32 // OLED display height, in pixels 19#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) 20Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); 21 22#define DHTPIN 10 23#define DHTTYPE DHT22 24DHT dht(DHTPIN,DHTTYPE); 25 26#define codeLength 5 27char Code[codeLength]; //define code length 28char pswd[codeLength]="A1B2"; //Change your password here 29byte keycount=0; 30const byte ROWS=4; 31const byte COLS=4; 32 33char hexakeys[ROWS][COLS]={ 34 {'1','2','3','A'}, 35 {'4','5','6','B'}, 36 {'7','8','9','C'}, 37 {'*','0','#','D'}}; 38 39 40byte rowPins[ROWS]={2,3,4,5}; 41byte colPins[COLS]={6,7,8,9}; 42 43Keypad customKeypad=Keypad(makeKeymap(hexakeys),rowPins,colPins,ROWS,COLS); 44 45void setup() { 46 Serial.begin(9600); 47 Wire.begin(); 48 49 pinMode(LED_RED,OUTPUT); 50 pinMode(LED_GREEN,OUTPUT); 51 red(); 52 53 dht.begin(); 54 therm.begin(); 55 therm.setUnit(TEMP_F); 56 myservo.attach(A0); //attach servo motor to A0 57 myservo.write(130); 58 display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //Start the OLED display 59 display.clearDisplay(); 60 display.display(); 61 lcd.begin(); 62 lcd.backlight(); 63 lcd.setCursor(0,0); 64 lcd.print("HOME AUTOMATION"); 65} 66 67void loop() { 68 char customkey=customKeypad.getKey(); 69 if(customkey){ 70 Code[keycount]=customkey; 71 Serial.print(Code[keycount]); 72 lcd.setCursor(keycount,1); 73 lcd.print(Code[keycount]); 74 keycount++; 75 } 76 door_system(); 77 DHT22_OLED(); 78} 79 80void door_system(){ 81 if(keycount==codeLength-1){ 82 Serial.println(" "); 83 lcd.print(" "); 84 85 if(!strcmp(Code,pswd)){ 86 Serial.println("PASSWORD CORRECT"); 87 lcd.clear(); 88 lcd.setCursor(0,1); 89 lcd.print(" WELCOME HOME "); 90 delay(1000); 91 lcd.clear(); 92 if (therm.read()){ // On success, read() will return 1, on fail 0. 93 Serial.print("Object: " + String(therm.object(), 2)); 94 Serial.println("F"); 95 Serial.print("Ambient: " + String(therm.ambient(), 2)); 96 Serial.println("F"); 97 Serial.println(); 98 Serial.println(String(therm.object(), 2)); 99 100 if (therm.object()>=90 && therm.object()<=95){ 101 myservo.write(0); //unlock 102 green(); 103 delay(8000); 104 myservo.write(130); //auto lock the door after 8secs. 105 red(); 106 } 107 } 108 } 109 else{ 110 Serial.println("PASSWORD INCORRECT"); 111 myservo.write(130); 112 red(); 113 lcd.clear(); 114 lcd.setCursor(0,1); 115 lcd.print(" NOT ALLOWED "); 116 delay(1000); 117 lcd.clear(); 118 } 119 deleteCount(); 120 } 121} 122 123void DHT22_OLED(){ 124 float h= dht.readHumidity(); 125 float t= dht.readTemperature(); 126 display.clearDisplay(); 127 display.setTextSize(1); 128 display.setTextColor(WHITE); 129 display.setCursor(0,4); 130 display.println("TEMP"); 131 132 display.setTextSize(2); 133 display.setCursor(50,0); 134 display.println(dht.readTemperature(),1); 135 136 display.setCursor(110,0); 137 display.println("C"); 138 139 display.setTextSize(1); 140 display.setTextColor(WHITE); 141 display.setCursor(0,20); 142 display.println("HUMI"); 143 144 display.setTextSize(2); 145 display.setCursor(50,17); 146 display.println(dht.readHumidity(),1); 147 148 display.setCursor(110,17); 149 display.println("%"); 150 151 display.display(); 152} 153 154void deleteCount(){ 155 while(keycount != 0){ 156 Code[keycount--]=0; 157 } 158 return; 159} 160 161void red(){ 162 digitalWrite(LED_RED,HIGH); 163 digitalWrite(LED_GREEN,LOW); 164} 165 166void green(){ 167 digitalWrite(LED_RED,LOW); 168 digitalWrite(LED_GREEN,HIGH); 169} 170
Keypad-Master Library
Blynk Library
SSD Library
DHT Library
Arduino Nano
arduino
Water Level Indicator System
1const int trigPin = 9; // pin on the arduinowhere the trigger pin is connected 2const int echoPin = 10;// pin on the arduino where the echo pin is connected 3const int led1 = 2; // water level indicator 1 4const int led2 = 3; // water level indicator 2 5const int led3 = 4; // water level indicator 3 6const int led4 = 5;// pin connected to the base of NPN transistor through a resistor for switching the pump ON and off 7const int buzzer=6; 8long duration; // variable where the the reflection time of the ultrasound is stored 9int distance; // variable where the distance of the measured object is stored 10void setup() 11{ 12pinMode (led1, OUTPUT);// sets as output 13pinMode (led2, OUTPUT);//sets as output 14pinMode (led3, OUTPUT);//sets as aoutput 15pinMode(led4, OUTPUT);//sets as output 16pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output 17pinMode(echoPin, INPUT); // Sets the echoPin as an Input 18pinMode(buzzer, OUTPUT); 19Serial.begin(9600); // Starts the serial communication 20} 21 22void loop() 23{ 24// Clears the trigPin 25digitalWrite(trigPin, LOW); 26delayMicroseconds(2); 27// Sets the trigPin on HIGH state for 10 micro seconds 28digitalWrite(trigPin, HIGH); 29delayMicroseconds(10); 30digitalWrite(trigPin, LOW); 31// Reads the echoPin, returns the sound wave travel time in microseconds 32duration = pulseIn(echoPin, HIGH); 33// Calculating the distance 34distance= duration*0.034/2; 35// Prints the distance on the Serial Monitor 36Serial.print("Distance: "); 37Serial.println(distance); 38 39 40if ( distance<=3)// when water has gotten to this level or is less than this level 41{ 42digitalWrite (led1, HIGH);// led1 comes ON and remains ON 43digitalWrite (led2, HIGH); 44digitalWrite (led3, HIGH); 45digitalWrite (led4, HIGH); 46tone(buzzer,3000); 47delay(3000); 48noTone(buzzer); 49delay(3000); 50} 51if (distance>=4&&distance<=6)// when the level of water has gotten to this level 52{ 53digitalWrite(led1, HIGH);// switch ON the Tap 54digitalWrite(led2, HIGH); 55digitalWrite(led3, HIGH); 56digitalWrite(led4, LOW); 57} 58if ( distance>=7&&distance<=9)// when water has gotten to this level or is less than this level 59{ 60digitalWrite (led1, HIGH); 61digitalWrite (led2, HIGH);//switch ON the led2 62digitalWrite (led3, LOW); 63digitalWrite (led4, LOW); 64} 65if( distance>=10&&distance<=12)// when water has gotten to this level or is less than this level 66{ 67digitalWrite (led1, HIGH);//switch ON the led3 68digitalWrite (led2, LOW); 69digitalWrite (led3, LOW); 70digitalWrite (led4, LOW); 71} 72if (distance>12)// when the level of water has gotten to this level 73{ 74digitalWrite(led1,LOW); 75digitalWrite(led2,LOW); 76digitalWrite(led3,LOW); 77digitalWrite(led4,LOW);//led4 goes OF and stays OF 78} 79} 80
Adafruit Sensor Master
Arduino Uno-2
arduino
LEDs Controlling System
1#include <IRremote.h> 2 3int RECV_PIN=13; // IR_Receiver data pin 4IRrecv irrecv(RECV_PIN); // Define IR Receiver and results objects 5decode_results results; 6 7int LED_1=14; // indicates Hall LED 8int LED_2=15; // indicates Kitchen LED 9int LED_3=16; // indicates Bed_Room LED 10int LED_4=17; // indicates Bath_Room LED 11int LED_5=18; // indicates Parking_Garage LED 12int LED_6=19; // indicates Garden_Light LED's 13 14int LED_7=2; //IR_Remote_Mode indicating LED 15int LED_8=3; //Blynk_Mode indicating LED 16int LED_9=4; //Manual_Mode indicating LED 17 18//int LED_9=8; // Flame_Sensor indication LED 19//int Flame_Sensor=9; // Flame_Sensor Digital output 20 21int toggleState_1 = 0; //Define integer to remember the toggle state for Hall LED 22int toggleState_2 = 0; //Define integer to remember the toggle state for Kitchen LED 23int toggleState_3 = 0; //Define integer to remember the toggle state for Bed_Room LED 24int toggleState_4 = 0; //Define integer to remember the toggle state for Bathroom LED 25int toggleState_5 = 0; //Define integer to remember the toggle state for Parking_Garage LED 26int toggleState_6 = 0; //Define integer to remember the toggle state for Garden_LED's 27 28int mswitch_1=7; //Manual switch for Hall LED 29int mswitch_2=8; //Manual switch for Kitchen LED 30int mswitch_3=9; //Manual switch for Bed_Room LED 31int mswitch_4=10; //Manual switch for Bath_Room LED 32int mswitch_5=11; //Manual switch for Parking_Garage LED 33int mswitch_6=12; //Manual switch for Garden LED's 34 35int mswitch_7=5; //Manual switch for IR_Remote Mode 36int mswitch_8=6; //Manual switch for Blynk Mode 37 38void setup(){ 39 Serial.begin(115200); 40 irrecv.enableIRIn(); // Enable the IR Receiver 41 for(int i=2; i<5; i++){ 42 pinMode(i,OUTPUT); 43 digitalWrite(i,LOW); 44 } 45 for(int j=14; j<20; j++){ 46 pinMode(j,OUTPUT); 47 digitalWrite(j,LOW); 48 } 49 for(int k=5; k<13; k++){ 50 pinMode(k,INPUT); 51 } 52 //pinMode(Flame_Sensor,INPUT); 53} 54 55void loop(){ 56 if(digitalRead(mswitch_7)==HIGH && digitalRead(mswitch_8)==LOW){ 57 digitalWrite(LED_7,HIGH); digitalWrite(LED_8,LOW); digitalWrite(LED_9,LOW); 58 IR_Remote_Mode(); 59 } 60 else if(digitalRead(mswitch_7)==LOW && digitalRead(mswitch_8)==HIGH){ 61 digitalWrite(LED_7,LOW); digitalWrite(LED_8,HIGH); digitalWrite(LED_9,LOW); 62 Blynk_Mode(); 63 } 64 else{ 65 digitalWrite(LED_7,LOW); digitalWrite(LED_8,LOW); digitalWrite(LED_9,HIGH); 66 Manual_Mode(); 67 } 68} 69 70void LedOnOff(int led){ 71 switch(led){ 72 case 1: 73 if(toggleState_1 == 0){ 74 digitalWrite(LED_1,HIGH); //Hall LED is in "On Condition" 75 toggleState_1 = 1; 76 } 77 else{ 78 digitalWrite(LED_1,LOW); //Hall LED is in "Off Condition" 79 toggleState_1 = 0; 80 } 81 break; 82 83 case 2: 84 if(toggleState_2 == 0){ 85 digitalWrite(LED_2,HIGH); //Kitchen LED is in "On Condition" 86 toggleState_2 = 1; 87 } 88 else{ 89 digitalWrite(LED_2,LOW); //Kitchen LED is in "Off Condition" 90 toggleState_2 = 0; 91 } 92 break; 93 94 case 3: 95 if(toggleState_3 == 0){ 96 digitalWrite(LED_3,HIGH); //Bed_Room LED is in "On Condition" 97 toggleState_3 = 1; 98 } 99 else{ 100 digitalWrite(LED_3,LOW); //Bed_Room LED is in "Off Condition" 101 toggleState_3 = 0; 102 } 103 break; 104 105 case 4: 106 if(toggleState_4 == 0){ 107 digitalWrite(LED_4,HIGH); //Bathroom LED is in "On Condition" 108 toggleState_4 = 1; 109 } 110 else{ 111 digitalWrite(LED_4,LOW); //Bathroom LED is in "Off Condition" 112 toggleState_4 = 0; 113 } 114 break; 115 116 case 5: 117 if(toggleState_5 == 0){ 118 digitalWrite(LED_5,HIGH); //Parking_Garage LED is in "On Condition" 119 toggleState_5 = 1; 120 } 121 else{ 122 digitalWrite(LED_5,LOW); //Parking_Garage LED is in "Off Condition" 123 toggleState_5 = 0; 124 } 125 break; 126 127 case 6: 128 if(toggleState_6 == 0){ 129 digitalWrite(LED_6,HIGH); //Garden_Light LED's is in "On Condition" 130 toggleState_6 = 1; 131 } 132 else{ 133 digitalWrite(LED_6,LOW); //Garden_Light LED's is in "Off Condition" 134 toggleState_6 = 0; 135 } 136 break; 137 default : break; 138 } 139} 140 141void IR_Remote_Mode(){ //Function for IR_Remote operating 142 if(irrecv.decode(&results)){ 143 Serial.println(results.value); 144 switch(results.value){ 145 //case 33480735: LedOnOff(0); break; 146 case 33444015: LedOnOff(1); break; //IR_Remote control for Hall LED 147 case 33478695: LedOnOff(2); break; //IR_Remote control for Kitchen LED 148 case 33486855: LedOnOff(3); break; //IR_Remote control for Bed_Room LED 149 case 33435855: LedOnOff(4); break; //IR_Remote control for Bath_Room LED 150 case 33468495: LedOnOff(5); break; //IR_Remote control for Parking_Garage LED 151 case 33452175: LedOnOff(6); break; //IR_Remote control for Garden LED's 152 //case 33423615: LedOnOff(7); break; 153 //case 33484815: LedOnOff(8); break; 154 //case 33462375: LedOnOff(9); break; 155 default : break; 156 } 157 irrecv.resume(); // Receive the next value 158 } 159} 160 161void Blynk_Mode(){ //Function for blynk operating 162 if(Serial.available()){ 163 char data=Serial.read(); 164 switch(data){ 165 case 'A': LedOnOff(1); break; //Blynk_App control for Hall LED 166 case 'a': LedOnOff(1); break; 167 case 'B': LedOnOff(2); break; //Blynk_App control for Kitchen LED 168 case 'b': LedOnOff(2); break; 169 case 'C': LedOnOff(3); break; //Blynk_App control for Bed_Room LED 170 case 'c': LedOnOff(3); break; 171 case 'D': LedOnOff(4); break; //Blynk_App control for Bath_Room LED 172 case 'd': LedOnOff(4); break; 173 case 'E': LedOnOff(5); break; //Blynk_App control for Parking_Garage LED 174 case 'e': LedOnOff(5); break; 175 case 'F': LedOnOff(6); break; //Blynk_App control for Garden LED's 176 case 'f': LedOnOff(6); break; 177 default : break; 178 } 179 Serial.println(data); 180 } 181 delay(100); 182} 183 184void Manual_Mode(){ //Function for manual operating 185 Manual_LED_1(); 186 Manual_LED_2(); 187 Manual_LED_3(); 188 Manual_LED_4(); 189 Manual_LED_5(); 190 Manual_LED_6(); 191} 192 193void Manual_LED_1(){ 194 if(digitalRead(mswitch_1)==HIGH){ //Manual control for Hall LED 195 digitalWrite(LED_1,HIGH); 196 } 197 else{ 198 digitalWrite(LED_1,LOW); 199 } 200} 201void Manual_LED_2(){ 202 if(digitalRead(mswitch_2)==HIGH){ //Manual control for Hall LED 203 digitalWrite(LED_2,HIGH); 204 } 205 else{ 206 digitalWrite(LED_2,LOW); 207 } 208} 209void Manual_LED_3(){ 210 if(digitalRead(mswitch_3)==HIGH){ //Manual control for Hall LED 211 digitalWrite(LED_3,HIGH); 212 } 213 else{ 214 digitalWrite(LED_3,LOW); 215 } 216} 217void Manual_LED_4(){ 218 if(digitalRead(mswitch_4)==HIGH){ //Manual control for Hall LED 219 digitalWrite(LED_4,HIGH); 220 } 221 else{ 222 digitalWrite(LED_4,LOW); 223 } 224} 225void Manual_LED_5(){ 226 if(digitalRead(mswitch_5)==HIGH){ //Manual control for Hall LED 227 digitalWrite(LED_5,HIGH); 228 } 229 else{ 230 digitalWrite(LED_5,LOW); 231 } 232} 233void Manual_LED_6(){ 234 if(digitalRead(mswitch_6)==HIGH){ //Manual control for Hall LED 235 digitalWrite(LED_6,HIGH); 236 } 237 else{ 238 digitalWrite(LED_6,LOW); 239 } 240} 241
BUSIO (I2C) Library
LCD I2C Library
Keypad-Master Library
MLX90614 Library
Adafruit GFX Library
Adafruit Sensor Master
DHT Library
Adafruit_BusIO Library
IR Remote Library
SSD Library
BUSIO (I2C) Library
Blynk Library
Downloadable files
Arduino Uno-1
Main Door System: Interfaced MLX90614, Keypad (4x4), LCD I2c (16x2), Servo Motor, DHT22 & OLED (128x64)
Arduino Uno-1
Arduino Uno-2
LEDs Controlling System: 1. Interfaced manual switches for manual mode operation. 2. Interfaced IR Receiver for IR mode operation. 3. Interfaced Node_Mcu for blynk mode operation. (IOT Application)
Arduino Uno-2
Arduino Nano
Water Level Indicator: Interfaced Ultrasonic sensor & LEDs.
Arduino Nano
Arduino Nano
Water Level Indicator: Interfaced Ultrasonic sensor & LEDs.
Arduino Nano
Arduino Nano
Water Level Indicator: Interfaced Ultrasonic sensor & LEDs.
Arduino Nano
Arduino Uno-1
Main Door System: Interfaced MLX90614, Keypad (4x4), LCD I2c (16x2), Servo Motor, DHT22 & OLED (128x64)
Arduino Uno-1
Arduino Uno-1
Main Door System: Interfaced MLX90614, Keypad (4x4), LCD I2c (16x2), Servo Motor, DHT22 & OLED (128x64)
Arduino Uno-1
Arduino Uno-2
LEDs Controlling System: 1. Interfaced manual switches for manual mode operation. 2. Interfaced IR Receiver for IR mode operation. 3. Interfaced Node_Mcu for blynk mode operation. (IOT Application)
Arduino Uno-2
Arduino Uno-2
LEDs Controlling System: 1. Interfaced manual switches for manual mode operation. 2. Interfaced IR Receiver for IR mode operation. 3. Interfaced Node_Mcu for blynk mode operation. (IOT Application)
Arduino Uno-2
Comments
Only logged in users can leave comments