Smart Mirror With Raspberry Pi
by NickL200 in Workshop > Home Improvement
2027 Views, 14 Favorites, 0 Comments
Smart Mirror With Raspberry Pi
The smart mirror is a rewarding project to create.
You can give your choose from a veriety of sensors to equip your smart mirror with.
Some people use touch screen to create a more user friendly design and some people use voice recognition to control their smart mirror.
We will try to keep cost as low a possible. therefor we will stick to a bluetooth module and a fingerprint sensor to control our Smart Mirror.
In this tutorial i will show you how you can create your own smart mirror using biometric authentication controlled by a android application.
Ordering Materials
When you order the materials for the Smart Mirror, it is fine to buy variants of the materials that we are using.
I will show you a list of things that i used to make this but just keep mind that for example you buy a different monitor or a different kind of plank, the outcome will be the same. you just to need to make shure that your screen will fit in the center of the wooden casing and that all the required materials are ordered.
The material used for the casing is wood.
Try to buy the lightest kind of wood that you can find, i advice to visit a brico to buy this.
For the outer frame you need a thin plank like displayed on the picture.
Use the same material that u use for the front of the mirror for the back of the mirror. with this thin wooden plank, we will create a sliding door to close up the back of the mirror casing.
In the second picture above, i drew the lines where all the parts will be assembled. the full line in the middle are the measurements of the monotor screen. This piece will be cut out so that the monitor can be placed there.
The broken lines next to the monitor are where a small frame will be attached. the width of the planks that create this frame will be wide enough to cover the corners of the monitor. By doing this, the monitor will be pushed through the holl that we created in the middle and be supported by the small frame that will be glued onto the thin wooden plank.
At the top of the wooden plank you will see a small rectangle, this is the spot where the fingerprint sensor will be attached. Next to the fingerprint sensor is a small square, this is where the motion sensor will be placed.
This will be used to turn on the monitor when a person walks in front of the monitor.
For this project you need a plastic bar with a 45 degree angle like showed on the last picture
List of materials:
-TTL usb to serial convertor(x2)
-construction angle
-screws
-rope
Downloads
Creating the Smart Mirror
First of all we need to draw the lines where alle the pieces will be placed of cut out.
The inner rectangle has the following measurements: height:32 cm , width: 53 cm.
the rectangle with the broken lined border will be 1 cm wider and higher then the inner rectangle.
Now we need to draw the borders of the fingerprint and motion sensor.
Place the sensor at the top of the wooden plank and draw a line next to the edge of the sensor, this way your measurements will be accurate.
when you create the small framer that will be placed in front of the monitor you need to make shure that the height is 34 cm and that you cut the wooden planks in parquet, the same goes for the 4 planks that will create the large outer frame.
STEP 1:
Take the wooden planks and create a rectangle with the following measurements: height: 52 cm , width: 42cm.
Be shure to cute the planks in parquet! Put all the planks together and screw them together using the construction angles and some screws like displayed on the picture. Create a small holl at the bottom of the frame where the power wires of the monitor and the rasberry pi can fit through.
STEP 2:
Take the thin wooden plank where we drew the lines on and cut out the middle where the screen will be placed and cut out the spots where the motion and fingerprint sensor will be placed. now put tec 7 glue at the corners of the plank and place it on top of the wooden frame that we created earlier. Let this dry for 10 minutes.
STEP 3:
Now we need to create the small frame to keep the monitor in place.
Create a small frame like you see on picture 5, make shure to cut the planks into parquet just like we did for the outer frame. Now glue the planks onto the broken lines so that the frame overlaps the corners of the inner frame.
By doing this, the monitor won't fall through the hol but will be held in place by the frame.
STEP 4:
Now we will cut the plastic bar into 3 pieces so that they fit inside the wooden frame and stick out 4 mm. The 4 mm is required so that a plank can be slided into the back to cover up the rear of the mirror. Glue the pieces into the wooden frame using tec 7. Now cut out a plank with the following measurements: height: 45cm, width: 38cm
like displayed on the last picture.
STEP 5:
Now place the screen into the frame en place a wooden plank at the top of the screen to keep the screen in place. Connect the plank to the frame using construction angles and some screws like displayed on the pictures.
STEP 6:
At this point the housing part of the smart mirror is complete. The only thing left to do is paint the wooden frame with the white paint that you bought.
STEP 7:
Now we need to install debian on the raspberry pi. When debian is installed, you need to create a user named dp-user and create the following folder: /home/dp-user/mirror. Now deploy the github code inside of the mirror folder.
STEP 8:
Open the debian console and install apache2 and mysql-workbench.
STEP 9:
To store the data required for the smart mirror to work, we need to create a database. download mysql workbench from internet and fun the following command.:
<------------------------------------------------------------------------------------------------------------------------------------->
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
CREATE SCHEMA IF NOT EXISTS `mirror` DEFAULT CHARACTER SET utf8 ; USE `mirror` ;
-- ----------------------------------------------------- -- Table `mirror`.`user` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mirror`.`user` ( `userId` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NULL DEFAULT NULL, `verificationId` INT(11) NULL DEFAULT NULL, `password` VARCHAR(45) NULL DEFAULT NULL, `email` VARCHAR(45) NULL DEFAULT NULL, PRIMARY KEY (`userId`), UNIQUE INDEX `name_UNIQUE` (`name` ASC)) ENGINE = InnoDB AUTO_INCREMENT = 2 DEFAULT CHARACTER SET = utf8;
-- ----------------------------------------------------- -- Table `mirror`.`agenda` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mirror`.`agenda` ( `agendaId` INT(11) NOT NULL AUTO_INCREMENT, `description` VARCHAR(250) NULL DEFAULT NULL, `startTime` TIME NULL DEFAULT NULL, `endTime` TIME NULL DEFAULT NULL, `startDate` DATE NOT NULL, `endDatte` DATE NOT NULL, `userId` INT(11) NOT NULL, PRIMARY KEY (`agendaId`), INDEX `fk_agenda_user1_idx` (`userId` ASC), CONSTRAINT `fk_agenda_user1` FOREIGN KEY (`userId`) REFERENCES `mirror`.`user` (`userId`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
-- ----------------------------------------------------- -- Table `mirror`.`sensor` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mirror`.`sensor` ( `sensorId` INT(11) NOT NULL AUTO_INCREMENT, `sensorName` VARCHAR(45) NULL DEFAULT NULL, PRIMARY KEY (`sensorId`)) ENGINE = InnoDB AUTO_INCREMENT = 4 DEFAULT CHARACTER SET = utf8;
-- ----------------------------------------------------- -- Table `mirror`.`log` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mirror`.`log` ( `logId` INT(11) NOT NULL AUTO_INCREMENT, `sensorId` INT(11) NOT NULL, `value` INT(11) NULL DEFAULT NULL, `userId` INT(11) NULL DEFAULT NULL, `timeStamp` VARCHAR(45) NULL DEFAULT NULL, `endTime` VARCHAR(45) NULL DEFAULT NULL, PRIMARY KEY (`logId`), INDEX `fk_log_sensor_idx` (`sensorId` ASC), INDEX `fk_log_user1_idx` (`userId` ASC), CONSTRAINT `fk_log_sensor` FOREIGN KEY (`sensorId`) REFERENCES `mirror`.`sensor` (`sensorId`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_log_user1` FOREIGN KEY (`userId`) REFERENCES `mirror`.`user` (`userId`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB AUTO_INCREMENT = 57 DEFAULT CHARACTER SET = utf8;
-- ----------------------------------------------------- -- Table `mirror`.`screensettings` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mirror`.`screensettings` ( `screensettingsId` INT(11) NOT NULL AUTO_INCREMENT, `UserId` INT(11) NOT NULL, `topLeft` VARCHAR(45) NULL DEFAULT NULL, `topRight` VARCHAR(45) NULL DEFAULT NULL, `bottomLeft` VARCHAR(45) NULL DEFAULT NULL, `bottomRight` VARCHAR(45) NULL DEFAULT NULL, PRIMARY KEY (`screensettingsId`), INDEX `user_idx` (`UserId` ASC), CONSTRAINT `user` FOREIGN KEY (`UserId`) REFERENCES `mirror`.`user` (`userId`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB AUTO_INCREMENT = 2 DEFAULT CHARACTER SET = utf8;
-- ----------------------------------------------------- -- Table `mirror`.`weather` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mirror`.`weather` ( `weatherId` INT(11) NOT NULL AUTO_INCREMENT, `temperature` DOUBLE NULL DEFAULT NULL, `description` VARCHAR(250) NULL DEFAULT NULL, `windSpeed` DOUBLE NULL DEFAULT NULL, `timeStamp` DATETIME NULL DEFAULT NULL, PRIMARY KEY (`weatherId`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
<--------------------------------------------------------------------------------------------------------------------------------------->
STEP 10:
In order for the program to start up when the raspberry pi boots up, we need to adjust some settings.
Open the debain console and enter the following code.
-sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
Inside this file, write the following code:
<------------------------------------------------------------------------------------>
@chromium-browser --start-fullscreen http://127.0.0.1:5000/
@/usr/bin/python3 /home/dp-user/mirror/app.py
<------------------------------------------------------------------------------------>
STEP 11:
Now place all the components into the case using the fritzing schema and the smart mirror is complete!