This repository holds code for a Smart Mirror application using the Node.js MERN Stack. The project contains an Express Backend providing an HTTP Server, HTTP Request Handlers, a Socket.IO Server and an MQTT Server. It works with a MongoDB database and contains files to access a local MongoDB database.
It is designed to be configured by a React-Native Smartphone application we are currently building. Go check it out!
This project was created in the scope a selfmade smart mirror application we are currently building for university. It has only been tested on a 2017/2018 MacBook Pro so far and is developed on it mostly. It is designed on Raspberry Pi in the end
Follow these general steps to get this project running.
- Install Node, NPM, MongoDB
- Run an instance of MongoDB on port 27017 (default port)
- Clone this Repo
cd mirrorserver && npm install
cd client && npm install
cd .. & npm run dev
This project is developed and tested on MacOS mostly. In order to run it, follow these additional steps.
- This project is using face recognition by accessing the camera through node-webcam. It only works after installing imagesnap (using brew):
brew imagesnap
When using one of the camera features for the first time, MacOS will ask for access to the camera. It has to be granted in order for this feature to work. If not granted, this feature will not work. Another tip: When taking cameras in front of the mirror, make sure to have right lighting and standing in front of the camera properly. The feature has not been tested with multiple people being in the camera scope so far. We are working on it!
This project is designed to work on a Raspberry Pi
Make sure that you configure the Raspberry Pi with a static IP address. This is automatically done by the launch-script, but if it fails, take over manually:
sudo nano /etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.x.x/24
static routers=192.168.x.1
static domain_name_servers=192.168.x.1
Save it by pressing Ctrl+X, " Y", ENTER & Re-boot
**Important! Do not touch /etc/network/interfaces**
Go to Desktop and run following:
touch launch.sh
chmod 777 launch.sh
Then copy the content of launch.sh from Github
The Raspberry Pi should already come with the launch.sh script on the Desktop. This script is setup as an auto-script that runs after every boot automatically. This can be achieved by running following steps: Type:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
Add following line:
@lxterminal -e /home/pi/Desktop/launch.sh
Save it by pressing Ctrl+X, " Y", ENTER.
To hide the mouse cursor, type:
sudo nano /etc/xdg/lxsession/LXDE/autostart
Add following line:
@unclutter -display :0 -noevents -grab
Save it by pressing Ctrl+X, " Y", ENTER. Re-boot and the auto-script is setup. This will auto-run the launch.sh script after the Pi boot is finished and the GUI is loaded.
If executed correctly, an instance of the frontend will appear in your default browser in fullscreen listening on port 3000 after booting the Pi. Launch.sh will first rotate your display for the mirror itself, then check your internet connection. If your Pi is not connected with the internet, another script should let you setup Wifi over the smartphone (not implemented yet, not planned, just documented for now!). If your Pi has internet access, the script will install important dependencies (nodejs, jq, mongodb, git, xdotool, curl, unclutter and dirmngr), look for the Github repo on the Desktop and install its dependencies. Then it will configure the database, config.json and .env and launch the application in fullscreen in a browser.
This project is developed and maintained by Emre Besogul and Felix Waldbach. For questions reach out to us!