Hi, I'm Huhn and I had no idea how to build a smart mirror.
So, I have changed it. I did implement IOTA related information to the open-source project MagicMirror2. This is a very easy way, to set up the Software for a Magic Mirror.
Disclaimer: This is no tutorial to build a whole MagicMirror - just the Magic.
So, first a few things to the MagicMirror2 project.
Looks easy. I forked the repository and clone it to my computer. Run it on development mode and added my settings.
git clone https://github.com/IOTA-Mirror
cd IOTA-Mirror
npm i
npm run start devAnd this is how it looked
Now we set up the Raspberry Pi and install the IOTA-Mirror.
Step 1 - Install Raspbian
First, we want to install Raspbian - we recommend to install Raspbian Buster with desktop (Download here). To do that plug the Pi's SD card in your computer and flash the Raspian on it. Tip: To do that you can use Etcher.
Step 2 - Connect to WLAN
After the flashing process finished, the SD card has been ejected from your computer. All you need to do is to plug it out and in to let the OS recognize it again. As soon as your boot drive has appeared to open your terminal and execute:
cd /Volumes/bootNow we want to enable SSH, which is disabled by default on the Raspberry Pi. We simply create a file called ssh within the boot drive. To do that execute:
touch sshEven if the file is empty it will enable ssh as soon as the Pi boots.
Lastly, we also want the Pi to connect with wifi as soon as it boots. To do that we store the connection details at the boot drive of the Pi. Execute the following command:
nano wpa_supplicant.confNow go ahead and paste the following code in the file. Also, enter your wifi connection details and press ctrl + x to save the changes.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
ssid="YOUR_SSID"
psk="YOUR_WIFI_PASSWORD"
key_mgmt=WPA-PSK
}Now we are ready to connect via SSH to the Pi.
Step 3 - Enable SSH
Before we plug in the SD card into the Raspberry. We want to enable SSH, which is disabled by default. We simply create a file called ssh within the boot drive like the WLAN configuration file above. To do that, just execute:
touch sshThis creates a new empty file. Even if the file is empty, it will enable ssh as soon as the Pi boots.
Step 4 - Connect to the PI
We want to open a WIFI with the Raspberry, so we connect vie normal LAN to the Raspberry for configuration.
Checks the Raspberry Pi IP in your Router, or try to connect with the hostname "raspberrypi".
ssh pi@raspberrypiNow you have to enter the default password "raspberry" and you're in!
For security reasons, let's change the default password of the user "pi. Input this command:
passwdNow you need to type in the current password again (raspberry) and then your new password and the confirmation.
Now you're safe and ready for the next step!
Step 5 - Install dependencies
For this example, we need to install NodeJS and npm, and some Python libraries to control the e-ink display.
Install NodeJS
sudo apt-get update
sudo apt-get dist-upgrade
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
node -vAfter the last command, you should see your node version.
Install python dependencies
sudo apt-get install python3-pip libtiff5-dev libopenjp2-7-dev fonts-freefont-ttf
sudo pip3 install RPi.GPIO spidev qrcode Pillowinstall git, to clone the example code.
sudo apt install gitClone and install the application dependencies
git clone https://github.com/IOTA-Mirror/IOTA-Mirror
cd IOTA-Mirror
npm installNOTEThe installation step for npm install will take a very long time, often with little or no terminal response! For the RPi3 this is ~10 minutes and for the Rpi2 ~25 minutes. Do not interrupt or you risk getting a 💔 by Raspberry Jam.
We need to upgrade Electron. This can be done by running the following command.
npm install electron@6.0.12We use the default configuration file, you can easily input your own sources.The default configuration loads different things:
- News: https://blog.iota.org/
- Events: https://community.einfachiota.de/calendar/
- The time and date
- and a nice compliment
Just run this command:
cp ./config/config.js.sample ./config/config.jsNow, run the application
npm startAnd the magic is done!
Plugin your Raspberry Pi to your TV or monitor and you will see the latest IOTA news and next events. Enjoy it!
Not done yet - just one things todo.
If the Raspberry PI turns out, the program won'T start automatically. We solve this by making a service.
Create a serviceWe will run the NodeJS app as a Linux service, so we can easily start, stop and watch them. Also, they automatically start after reboot or crashes. Create a file called “snapshot.service” in this directory: “/etc/systemd/system”.
Just create a new file for the service and add the configuration.
sudo nano /etc/systemd/system/iota-mirror.serviceAdd these lines and save it (CTRL+X and Y).
[Unit]
Description=IOTA-Mirror Service
After=network.target
[Service]
WorkingDirectory=/home/pi/IOTA-Mirror
ExecStart=/usr/bin/npm start
Restart=on-failure
User=pi
[Install]
WantedBy=multi-user.targetAdd and start the service.
sudo systemctl enable iota-mirror.service
sudo systemctl start iota-mirror.serviceThat’s how you can see the logs:
journalctl -u iota-mirrorThat's all! You're done!
If you liked or disliked the tutorial, please let me know. Let's build some cool IOTA features together! Ideas: look here and join or create a new feature!







Comments