/*
This Secure Keypad captures user input of numbers.
encrypts and sends the number to a cloud server using secure mqtt.
The cloud server compares the number with a secure DB kept in cloud.
and returns an encrypted message containing the unlock or error code and
a string containing the user admitted in. The system uses a web interface for all
password setting and data view.
Hardware: this project has an esp32 for data input, processing and actuations.
this project has 4X4 keypad, OLED screen, A buzzer and a RGB LED.
operation: we turn on the device, The OLED shows power on status message.
We enter numbers in keypad, it shows on OLED display.
We press "B". It behaves like backspace and erases previous charecter.
we press "C". It clears the whole display.
we press "A" It enters the number in the system as shown in OLED display. enter our keycode and press the "D" key to enter our input.
We can use only numbers 0-9 and "#" , "*" special charecters.
if the entered number is correct, OLED shows welcome message and name of the person admitted.
Buzzer sounds welcome tone, and RGB LED turns green.
if entered number is incorrect, OLED shows reject message, buzzer sounds reject tone,
RGB led turns red.
consecutive 3 retries, rejects the user and an alarm tone is generated at field.
The RGB LED starts flashing red.
This condition can be overcome by a security guard entering a special code in keypad.
with correct code, the OLED will show terminal alarm was reset by ... the security guards name.
through logging into the web interface, We can
set the passwords against Name of trusted persons
view the log of persons admitted against time.
view the alarm log and reset by person info against time.
New text
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Keypad.h>
#include "helpers.cpp"
const byte ROWS = 4; /* four rows */
const byte COLS = 4; /* four columns */
/* define the symbols on the buttons of the keypads */
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {35, 0, 45, 48}; /* connect to the row pinouts of the keypad */
byte colPins[COLS] = {47, 21, 20, 19}; /* connect to the column pinouts of the keypad */
/* initialize an instance of class NewKeypad */
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
// initialize an instance of the keypad buffer and callback function for data submission.
Mkeypad keybuff(&UploadCallback);
// text added
#define BZR 5
#define Red 6
#define Green 7
#define SCREEN_WIDTH 128 // OLED width, in pixels
#define SCREEN_HEIGHT 64 // OLED height, in pixels
int welcome[3] = {1200,1300,1400}; //the frequency of the tones are given
int reject[3] = {1200,1000,500};
// create a locker object and supply the lock unlock pin values to it
Locker lck(Red,Green);
// create a buzzer object and assign the initial parameters
Buzzer bz(BZR,welcome, reject);
// create an OLED display object connected to I2C
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void UploadCallback(void)
{
// this callback will simply call blynks virtualwrite.
//std::cout<<"Blynk Keypad Callback executed"<<std::endl;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-S3!");
}
void loop() {
char customKey = customKeypad.getKey();
if (customKey){
// every keystroke is captured here.
// update the keypad buffer with input.
keybuff.ProcessInput(customKey);
//look at callback state means data has been submitted. wait for 10 seconds.
//Read the data returned from Blynk callbacks.
//play designated welcome / reject tone.
// execute lock/unlock.
Serial.println(customKey);
}
}
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1