Exploring Raspberry Pie

I have been doing a lot of experiments with the Arduino platform. I wanted to play with something else and learn if there’s a better world out there that

7 years ago

Latest Post The Great Escape Tunnel by Mario Esposito public

I have been doing a lot of experiments with the Arduino platform. I wanted to play with something else and learn if there’s a better world out there that I don’t know about it or an alternative way to connect Sensoria SDK to other platforms. My choice has fallen on a popular one: Raspberry Pi.
As the first project, I wanted to automate the opening of my garage door. Given that I had to start from zero with the new toy, I took notes of what I had to learn and what I did through my journey. Below my notes, hopefully, they will be of good use to you too. Do comment if I have missed something. Keep in mind that the community is very vibrant therefore at some point those notes might get outdated by a better process. If you find that it is the case, let me know and I will try to refresh accordingly.


You need a Raspberry Pi (RBPI) which is the core of the whole sh’bam and if you don’t want to connect to your router via Ethernet you can buy this for wireless communications. On the board of the RBPI, there’s a slot for an SD card, that will host the operating system that boots up once you power on the hardware.



If you have attached an HDMI cable and a USB keyboard you can log in using user: pi and pwd: raspberry
If you want to do everything from the remote, then what you want to do is to connect power, network and after the system booted (give a couple of minutes) find out the IP address that your router has associated to the RBPI and connect using ssh pi@<IP_ADDRESS>.local if you are on a Mac. If you are on Windows you have to adjust based on the client that you are using.Occasionally it can be a bit of pain to find the IP address assigned. There are multiple ways and the most obvious and less convenient is log in to your router and take a look, I found that annoying so I built this script for the Bash shell.

cidr=$(while read y; do echo ${y%.*}".0/$(m=0; while read -n 1 x && [ $x = f ]; do m=$[m+4]; done < <(ifconfig $i | awk '/mask/             {$4=substr($4,3); print $4}'); echo $m )"; done < <(ifconfig $i | awk '/inet[ ]/{print $2}'))myip=`ifconfig $i | grep "inet " | awk 'NR==1 {print $2}'`
echo "sudo nmap -n -T4 -PN -p9091 --exclude $myip $cidr"
sudo nmap -n -T4 -PN -p9091 --exclude "$myip" "$cidr"

Just put that into an editor save it with extension .sh and launch from the command line as ./ (or whatever name you used) - Note that it leverages the wonder free map, therefore you have to install it if you don’t already have it installed. It might be necessary to run chmod +x to grant execution permission to your script.

I keep the script on Github up to date, so if you run into troubles with a copy and paste from this post leverage the script posted there.


Run this command after login

sudo apt-get updateit

downloads the package lists from the repositories and “updates” them to get information on the newest versions of packages and their dependencies. It will do this for all repositories and PPAs.

There are different ways to connect and run code remotely however the most obvious way and also more interactive is to have a small web server installed so you can code some PHP pages to control remotely the RBPI. You can achieve that by installing apache with the following command

sudo apt-get install apache2 php5 libapache2-mod-php5

Once that is done, you want to double-check that everything works as expected. On your computer open the Internet browser and type the IP address of the RBPI. If you see “It works!” celebrate. That is the default page of Apache webserver.

At any given time if you have to stop what you are doing and resume later don’t pull the power, you will have problems with the filesystem later or other weird symptoms. Instead, issue this command sudo shutdown -h 0 that will do a proper shutdown. And as usual playing with electronics, watch for static energy, so don’t touch too much the components if you don’t have anything that grounds you.


At some point, you might need to enable root access to do some awful things like, fix filesystem errors. To enable the root account, log in to your raspberry pi, then type “sudo -i” and hit Return / Enter. (you’ll need to type your password in). Then type “passwd root” and hit Return / Enter. You will be asked to type a password, then confirm it.

I found that performing a disk check proved to be quite a pain as what can be easily corrupted is the root file system, so it is not easily unmounted. It could probably be re-mounted as read-only, but a simpler way is to schedule an fsck at the next reboot. In that case, here is what I did:

  1. df (to find out what /dev use)
  2. sudo touch /forcefsck
  3. shutdown -rF now


Given all the work done so far, you don’t want to run in the situation where your SD card either gets corrupted (it happens) or you mess some critical configuration file causing the system to either not run or not function properly. To do that I followed this instruction that is beautifully spelled out.


I am going to clean up a bit my garage code and take some better pictures than I originally took before even realizing that my hacking was going to be of any use. A conversation on Facebook with my friend Aldo sparked the idea that sharing my learning could have been of use to others. I plan to use the Sensoria Smart Socks as an authentication system to open the garage door. Let’s see what I can get into place :-)Enjoy your raspberry ride

Mario Esposito

Published 7 years ago