Pi Based Parking Assist System


Introduction: Pi Based Parking Assist System

Hey there! Here's a cool little project you can make in a single afternoon and then use it daily. It's based on the Raspberry Pi Zero W and will help you to park your car perfectly everytime.

Here's the complete list of the parts you will need:

  • Raspberry Pi Zero W (we will call this 'rpi' or 'pi' in this article)
  • 4GB or larger micro SD card for the pi OS
  • Two tinyLiDAR Time of Flight distance sensor modules
  • 32x32 RGB LED Panel (there are many manufacturers for this with varying dot pitches, you can for instance use the Adafruit 1484 or similar, just search for '32x32 LED Matrix' on Google). Our panel had a 6mm pitch.
  • 25 feet of CAT5 cable
  • approx 22 colored male to male header pin jumper wires
  • 5v 2Amp microUSB power supply (cell phone charger)

    All set? Let's go!

TL;DR Summary

  • Download Raspbian Lite OS for the rpi
  • Configure the pi to run headless over WiFi with a static IP
  • Setup your PC dev environment with PuTTY, WinSCP and optionally SublimeText w/ FTP addon
  • Download, make and bind the LED panel driver
  • Download and install pigpio
  • Download our Python code
  • Wire up the 32x32 LED display panel
  • Make the CAT5 extension cable for the side tinyLiDAR sensor
  • Optional step (but only for advanced users): do a quick happy dance when all is working ;)

Step 1: What's a Pi Zero W?

You undoubtedly have heard of the Raspberry Pi but what the heck is a pi 'Zero W'?

The Raspberry Pi Zero and Zero W were more recent additions to the Pi family meant more for IoT and other low cost embedded applications. They are stripped down versions of the original pi board but still with a powerful 1GHz processor. Here's a good comparison of all the models.

The benefit for us in choosing the Pi Zero W here over other controller boards is that we can easily program it in the higher level Python language while still using the fast C/C++ LED panel drivers. It's also attractively priced at only $10USD.

Bear in mind that since this board is a stripped down version of a full pi - some things have changed. In particular, the ethernet jack has been eliminated, the HDMI connector has changed to a mini size and the four USB ports have been simplified down to just one micro USB type. There's another micro USB connector onboard, but it's only for powering the board. Elimination of the all the full size USB connectors introduces some complexities. Namely, how can you hookup a keyboard and mouse? Standard USB perfipherals and hubs use Type A connectors not the micro kind.

So what can we do?

We can go headless!

No, we don't mean to go crazy but to use an alternative to the normal direct wired setup. Headless means to "tunnel" into the pi remotely using a secure shell (SSH) network connection. For this project we will use the headless approach over WiFi. Hence the reason for us in choosing the W version of the pi zero instead of the even lower cost pi zero.

Note that there's also another way of running the pi in headless mode using something called VNC. It needs special VNC software running on your PC though as it provides a full virtual graphical desktop on your PC. We don't require (and really don't want) the desktop for our project so we will stick to the simpler SSH method.

Step 2: Scotty, We Need More Power!

The 32x32 LED matrix panel can, all by itself, take several amps of current. No kidding! That's why most of these panels include some hefty looking power cables to power it. Fortunately for us though we won't need to get a massive power supply for this project. We were able to power this whole system from only a spare 5v/2amp microUSB cell phone charger we had lying around.
The reason for the lower current is because we use relatively simple graphics and therefore don't turn on most of the LEDs. If you're thinking of making animation or using video/bright graphics then you should definitely consider powering the panel from a separate power supply.

Step 3: Sensor Placement and Software

Did you notice that we're using two tinyLiDARs in this system instead of just one? As shown in the garage setup diagram, one is placed in front of the car and the other is placed along one side of the car.

The side sensor will detect if you veer off center as you park the car and of course the front one will tell you when to stop.

The 32x32 LED display will assist you by showing arrows to move forward, left or right and a count down display with colored corners to indicate how far you still have to drive. Have a look at our short video for all the display states.

Game Plan

In a nutshell, we're using the ever popular hzeller C library for the LED driver, Python for the controlling code and the pipgpio C library for proper I2C control of our sensors.

Python is a super easy high level language that you can easily edit on any text editor. We normally use SublimeText and for this project we also used a very useful FTP plugin that allows us to edit the script files directly on the pi. This is an optional step as it's only needed if you want to edit the code. More details are available at the end of this article.

All rpi boards, as you may know, do not natively support I2C clock stretching. So we used the pigpio library again for this project to control the tinyLiDAR sensors but this time with a slight twist...

Multiple tinyLiDARs

When you buy a tinyLiDAR, it's always set to the default slave address of 0x10. This is fine for when you're using a single sensor but if you have more than one on the bus it maybe a problem if you write a command to 0x10 and all of them answer back!

So we have 3 options here:

First, we can use the (tinyLiDAR) "R" command to write a new slave address to the one sensor connected to the I2C bus. Then repeat this for each sensor. Physically attaching, writing and detaching each sensor for this procedure. tinyLiDAR will store the given address in its onboard non-volatile memory. The address will persist even after power cycling until you clear it by issuing the RESET command.

The second option is to use the convenient Auto Assign feature that we created as a stretch goal in the IGG campaign. This involves sending the "AR" command and then pointing your finger to each sensor individually to auto assign sequential I2C addresses to the individual sensors similar to the first option but you don't have to physically disconnect each sensor to do this.

The third option is the one that we're using here in this project and it's possible thanks to the pigpio library. To implement the I2C standard properly, pigpio bitbangs the GPIO. So because of this, we can easily create separate I2C buses on just about any pair of spare GPIO pins.

Hence there's no need to re-program slave addresses for the multiple LiDAR sensors. We can just use a separate bus for each one :)

Note that the I2C bus running at 100Kbps is actually pretty robust. We're using plain old CAT5 ethernet cable to run the I2C bus out to the side tinyLiDAR sensor that's a full 25 feet away without any active repeater components! Sensor wiring details are shown above.

Okay, enough jibber jabber, let's start downloading the code!

Step 4: Setting Up the Pi

Caution: The pi uses a Linux file system so it's best to perform the following steps on a Linux based system. You may end up reformatting your SD card if you do this on Windows. We used the awesome & free Ubuntu 18.04 desktop running in a virtual environment on a Windows 10 PC but you can try something similar.

You will need to first download the OS from raspberrypi.org and then burn it to your microSD card. So follow these steps:

(1) In Ubuntu go here and grab the Raspbian Lite image. Save it to your downloads folder.

(2) Next download the Etcher SD card writing utility. FYI - the official Etcher download link for the Linux version on their home page didn't work for us so we used the method described here instead:

In summary the steps described in the link were:

Add Etcher debian repository:

echo "deb https://dl.bintray.com/resin-io/debian stable etcher" | sudo tee /etc/apt/sources.list.d/etcher.list

Trust Bintray.com's GPG key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 379CE192D401AB61

Update and install:

sudo apt-get update
sudo apt-get install etcher-electron

Once completed, you can go ahead and launch Etcher from your Ubuntu desktop. It will ask you for the source file (which you put in the downloads folder).
The next step in Etcher is to choose the correct target. Etcher does a good job of detecting your micro SD card but you should be paranoid here. To verify it's finding the proper destination - try ejecting the microSD card by clicking eject in the Ubuntu file explorer window and verify that it goes away as the target option inside of Etcher. Then pop it back in and continue on to the final step, which is to write the file to this microSD card.

Wait for a while until it's done and then continue onwards.

Step 5: WiFi Time

Okay so now it's time to enter your WiFi details.

Tip: you can always copy (Ctrl+C) and paste (Right Click, Paste) information from this article to the PuTTY terminal screen instead of typing out the commands. Check the end of this article for several helpful Linux commands as well.

When Etcher is done writing to the micro SD card, there will be 2 drives showning up as shown above. One is called boot the other is called rootfs

We need to use the files manager to go into the boot folder and make a file called wpa_supplicant.conf.

To do this step you can just click on the left side where it says boot and then on the right side of the screen you can right click on the white backgroud and choose Open in Terminal.

This will pop open a terminal window (similar to CMD in Windows) where you can type the following:

sudo nano wpa_supplicant.conf 
Tip: You'll need to enter your Linux system password so that it can run as the Super User. This is required or else you will not be able to save the files when you are done editing.

The above command will then launch the "nano" text editor where you can enter the following information:

country = US
ctrl_interface = DIR = /var/run / wpa_supplicant GROUP = netdev
update_config = 1

network = {
    ssid = "WiFi_SSID"
    scan_ssid = 1
    psk = "WiFi_Password"
    key_mgmt = WPA - PSK

Note: Remember to replace WiFi_SSID and WiFi_Password with your own WiFi network name and password.

When you're done, just click Ctrl+X to exit and answer Yes to writing the file upon exit.

Our next step is to create an empty file called ssh. To do this, we just type the following in the terminal window:

touch ssh

Now we need to give our pi a static IP address so we know where it is every time we want to connect to it. Type the following in the terminal window:

sudo nano /etc/dhcpcd.conf

This should open the nano text editor again and we can add this text to the bottom of the file:

interface wlan0
static ip_address=
static routers=
static domain_name_servers=

Note: This assumes your network prefix is 192.168.0. If you have 192.168.1 etc then use your network instead. The domain name server is for Google and its optional here.

Type 'exit' in the Terminal to close it off. Then right click over the boot name in the left side of the Files manager window and select Eject.

You can now plug this microSD card into your pi and plug in the microUSB power cable to power your pi.

If all goes well, the green LED will blink for a while like it's accessing a hard disk drive and it should log you onto your WiFi network. Give it about a minute to settle down and wait for the LED to become solid green.

To verify that it all worked, we can try to ping it.

So just type the line below and check for a response.


In Ubuntu you should get something similar to this:

PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=128 time=752 ms
64 bytes from icmp_seq=2 ttl=128 time=5.77 ms
64 bytes from icmp_seq=3 ttl=128 time=7.33 ms
--- ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 5.777/255.346/752.922/351.839 ms

Note that the ping continues to operate until you hit Ctrl+C to quit.

In Windows you should get something like this:


Pinging with 32 bytes of data:
Reply from bytes=32 time=4ms TTL=64
Reply from bytes=32 time=5ms TTL=64
Reply from bytes=32 time=6ms TTL=64
Reply from bytes=32 time=5ms TTL=64

Ping statistics for
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 4ms, Maximum = 6ms, Average = 5ms

All good? Onwards...

Step 6: Logging In

Now that we have connectivity to the pi, we want to send it commands. But how?
PuTTY of course! You can download PuTTY from here

Setting up PuTTY
After downloading the PuTTY software, make a profile for your pi with the following information:

Host Name (or IP address):
Connection type: SSH
Give this profile a name under Saved Sessions and hit Save. You can use any name you like for example "rpizw_200"

To login, just select it from the list and hit Load. Then press Open. Enter the user name and password to log in:

login name: pi
Defalt password: raspberry

Here's a sample session shown in PuTTY when you login:

login as: pi
pi@'s password:
Linux raspberrypi 4.14.34+ #1110 Mon Apr 16 14:51:42 BST 2018 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: [date and time ] from 192.168.0.[ip address]

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

On first login, it will warn that you havn't yet changed the password. You should change it to something strong yet simple to remember so go ahead and change it by typing passwd and follow the prompts.

We should next update the software on the pi by typing this:

sudo apt-get update && sudo apt-get upgrade

This will download any updates it needs from your internet connection. Answer YES if prompted to allow it continue and then give it some time to update.

At this time we should probably also turn off the sound on the pi as it has some bad juju with the LED driver library. Copy, paste the following lines one at a time and press enter after each line:

cd ~
cat <<EOF | sudo tee /etc/modprobe.d/blacklist-rgb-matrix.conf
blacklist snd_bcm2835

sudo update-initramfs -u

The output will be something like this:

pi@raspberrypi:~ $ cd ~
pi@raspberrypi:~ $ cat <<EOF | sudo tee /etc/modprobe.d/blacklist-rgb-matrix.conf
> blacklist snd_bcm2835

blacklist snd_bcm2835

pi@raspberrypi:~ $ sudo update-initramfs -u
pi@raspberrypi:~ $

Then we have to reboot the pi to have the changes take effect, so type the following:

sudo reboot now

The connection will drop of course as the pi is rebooting so you can close off PuTTY. Try logging back in a minute later.

Now it's time to get a graphical FTP file manager called WinSCP. You can download WinSCP from here

WinSCP is a lot like the file mangager on Windows and Ubuntu. It allows us to easily drag and drop files to & from the pi and create diretories with just a right click of the mouse.

Once downloaded, you will need to setup a profile for your pi.

WinSCP Setup
At the Login popup, choose New Site. Use the following settings for the session:

File protocol: SFTP
Host name:
User name: pi
Password: {whatever password you changed the default to in the PuTTY step above}

In Advanced Site Settings go to Environment | Directories and enter /home/pi for the Remote directory and whatever you like for the Local Directory setting.

In Advanced Site Settings go to Environment | Shell and choose sudo su - in the Shell drop down list.

Then hit Save.

Keep both WinSCP and PuTTY open while performing the following steps.

Go to the PuTTY terminal and enter the following:

cd ~ 

This will get us to our home directory inside of the pi.

We can now grab the LED driver library from github. To use the latest code, we will need to pull the repo so we need to install the git utility.

Enter this in PuTTY:

sudo apt-get install git

answer Y to continue and it will take a few seconds to install git for us from the internet.

The output should look something like this:

pi@raspberrypi:~ $ sudo apt-get install git
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  git-man liberror-perl
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk
  gitweb git-arch git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  git git-man liberror-perl
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,848 kB of archives.
After this operation, 26.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://muug.ca/mirror/raspbian/raspbian stretch/main armhf liberror-perl all 0.17024-1 [26.9 kB]
Get:2 http://muug.ca/mirror/raspbian/raspbian stretch/main armhf git-man all 1:2.11.0-3+deb9u3 [1,433 kB]
Get:3 http://muug.ca/mirror/raspbian/raspbian stretch/main armhf git armhf 1:2.11.0-3+deb9u3 [3,388 kB]
Fetched 4,848 kB in 5s (878 kB/s)
Selecting previously unselected package liberror-perl.
(Reading database ... 34363 files and directories currently installed.)
Preparing to unpack .../liberror-perl_0.17024-1_all.deb ...
Unpacking liberror-perl (0.17024-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a2.11.0-3+deb9u3_all.deb ...
Unpacking git-man (1:2.11.0-3+deb9u3) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a2.11.0-3+deb9u3_armhf.deb ...
Unpacking git (1:2.11.0-3+deb9u3) ...
Setting up git-man (1:2.11.0-3+deb9u3) ...
Setting up liberror-perl (0.17024-1) ...
Processing triggers for man-db ( ...
Setting up git (1:2.11.0-3+deb9u3) ...

Now go back to WinSCP and navigate to the /home/pi folder. Then on the right side of this WinScp window, right click and choose to create a New Directory called "parking"

Back in the PuTTY screen you can type ls to confirm you did just make a new folder in the pi. Then enter this:

cd p[TAB]
Tip: Pressing the TAB key will autocomplete the partial name for you.

Press the enter key to get into this directory.

pi@raspberrypi:~ $ cd parking/
pi@raspberrypi:~/parking $ ls

Now we can get the driver files by entering the following in PuTTY:

git clone https://github.com/hzeller/rpi-rgb-led-matrix.git
The output will look something like this:
pi@raspberrypi:~/parking $ git clone https://github.com/hzeller/rpi-rgb-led-matrix.git
Cloning into 'rpi-rgb-led-matrix'...
remote: Counting objects: 3740, done.
remote: Total 3740 (delta 0), reused 0 (delta 0), pack-reused 3740
Receiving objects: 100% (3740/3740), 20.61 MiB | 1.32 MiB/s, done.
Resolving deltas: 100% (2550/2550), done.

Now compile the LED driver files by going into this new 'rpi-rgb-led-matrix' directory and typing the make command:

cd r[TAB]
And this is what it looked like on our board:
pi@raspberrypi:~/parking $ cd rpi-rgb-led-matrix/
pi@raspberrypi:~/parking/rpi-rgb-led-matrix $ make
make -C ./lib
make[1]: Entering directory '/home/pi/parking/rpi-rgb-led-matrix/lib'
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o gpio.o gpio.cc
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o led-matrix.o led-matrix.cc
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o options-initialize.o options-initialize.cc
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o framebuffer.o framebuffer.cc
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o thread.o thread.cc
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o bdf-font.o bdf-font.cc
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o graphics.o graphics.cc
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o transformer.o transformer.cc
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o led-matrix-c.o led-matrix-c.cc
cc  -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -c -o hardware-mapping.o hardware-mapping.c
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o content-streamer.o content-streamer.cc
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o pixel-mapper.o pixel-mapper.cc
g++ -I../include -Wall -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -Wextra -Wno-unused-parameter -fno-exceptions -c -o multiplex-mappers.o multiplex-mappers.cc
ar rcs librgbmatrix.a gpio.o led-matrix.o options-initialize.o framebuffer.o thread.o bdf-font.o graphics.o transformer.o led-matrix-c.o hardware-mapping.o content-streamer.o pixel-mapper.o multiplex-mappers.o
g++ -shared -Wl,-soname,librgbmatrix.so.1 -o librgbmatrix.so.1 gpio.o led-matrix.o options-initialize.o framebuffer.o thread.o bdf-font.o graphics.o transformer.o led-matrix-c.o hardware-mapping.o content-streamer.o pixel-mapper.o multiplex-mappers.o -lpthread  -lrt -lm -lpthread
make[1]: Leaving directory '/home/pi/parking/rpi-rgb-led-matrix/lib'
make -C examples-api-use
make[1]: Entering directory '/home/pi/parking/rpi-rgb-led-matrix/examples-api-use'
g++ -I../include -Wall -O3 -g -Wextra -Wno-unused-parameter -c -o demo-main.o demo-main.cc
make -C ../lib
make[2]: Entering directory '/home/pi/parking/rpi-rgb-led-matrix/lib'
make[2]: Leaving directory '/home/pi/parking/rpi-rgb-led-matrix/lib'
g++ demo-main.o -o demo -L../lib -lrgbmatrix -lrt -lm -lpthread
g++ -I../include -Wall -O3 -g -Wextra -Wno-unused-parameter -c -o minimal-example.o minimal-example.cc
g++ minimal-example.o -o minimal-example -L../lib -lrgbmatrix -lrt -lm -lpthread
cc -I../include -Wall -O3 -g -Wextra -Wno-unused-parameter -c -o c-example.o c-example.c
cc c-example.o -o c-example -L../lib -lrgbmatrix -lrt -lm -lpthread -lstdc++
g++ -I../include -Wall -O3 -g -Wextra -Wno-unused-parameter -c -o text-example.o text-example.cc
g++ text-example.o -o text-example -L../lib -lrgbmatrix -lrt -lm -lpthread
g++ -I../include -Wall -O3 -g -Wextra -Wno-unused-parameter -c -o scrolling-text-example.o scrolling-text-example.cc
g++ scrolling-text-example.o -o scrolling-text-example -L../lib -lrgbmatrix -lrt -lm -lpthread
g++ -I../include -Wall -O3 -g -Wextra -Wno-unused-parameter -c -o clock.o clock.cc
g++ clock.o -o clock -L../lib -lrgbmatrix -lrt -lm -lpthread
g++ -I../include -Wall -O3 -g -Wextra -Wno-unused-parameter -c -o ledcat.o ledcat.cc
g++ ledcat.o -o ledcat -L../lib -lrgbmatrix -lrt -lm -lpthread
make[1]: Leaving directory '/home/pi/parking/rpi-rgb-led-matrix/examples-api-use'
pi@raspberrypi:~/parking/rpi-rgb-led-matrix $

Our next step will be to bind the RGB matrix library to Python. We used the default Python 2 for this project. So to do this binding we enter the following one line at a time as before:

sudo apt-get update && sudo apt-get install python2.7-dev python-pillow -y
make build-python
sudo make install-python

Note: You can safely ignore the one warning about '-Wstrict-prototype' that shows up when running the two make statements. The make commands take a couple of minutes to run and they don't say anything in the while they are busy. So fear not - your pi should come back soon ;)

Here is partial output on the first make statement:

building 'graphics' extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-kKRR4y/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I../../include -I/usr/include/python2.7 -c rgbmatrix/graphics.cpp -o build/temp.linux-armv6l-2.7/rgbmatrix/graphics.o -O3 -Wall
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-kKRR4y/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-kKRR4y/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv6l-2.7/rgbmatrix/graphics.o -L../../lib -lrgbmatrix -o ./rgbmatrix/graphics.so
make[1]: Leaving directory '/home/pi/parking/rpi-rgb-led-matrix/bindings/python'
pi@raspberrypi:~/parking/rpi-rgb-led-matrix $

Next we'll install the pigpio C library. To do this properly we need to make it from source so just enter the following lines:

cd ~
sudo rm -rf PIGPIO
wget abyz.me.uk/rpi/pigpio/pigpio.zip
unzip pigpio.zip
sudo make install
rm pigpio.zip

The above install takes about 3 minutes.

Now it's time to get our Python project files. Enter the following:

cd ~
cd /home/pi/parking/rpi-rgb-led-matrix/bindings/python/samples
wget https://s3.amazonaws.com/microedco/tinyLiDAR/Raspberry+Pi/tinyL_parking.zip
unzip -j tinyL_parking.zip
rm tinyL_parking.zip

Then to execute it, type the following:

sudo python parking.py

But you don't need to do this right now as we still have to wire it all up...

Step 7: Wires

As mentioned earlier, we powered the LED panel from the same power adaptor that powers the pi. In order to do this, you will have to splice the hefty red and black wires to male header pins so they can be plugged into pins 2 and 9 of the 40pin pi connector.

Unplug the power to the pi now and wire up the LED panel as per the pictorial diagram above. Keep pin 2 disconnected for now.

NOTE: The LED matrix panel can sometimes power up in a funky state. If this happens it can load down your power supply severely no matter what current capacity it has. We noticed this during development on our bench supply which can provide over 4 amps. The solution to this is to run the pi code first and then plug in pin 2 to power the LED panel. In this way the panel should come up in a low power state since it flushes out the random LED states. Quiescent current (all LEDs off) for our LED panel was only 50mA at 5v.


We used a 25 foot CAT5 ethernet cable and modified it to plug into the pi header pins on one end and accept the GROVE connector pins on the other side so we could extend the distance to place our side tinyLiDAR sensor. The photos above show this cable before and after modifications. Disregard the colors of the header pin wires as they are not correlated to the diagrams. Just make sure you wire up your system as shown in the pictorial connection diagrams shown earlier in step 3.

Step 8: Light It Up!

The proper initial power up sequence should be to plug in the microUSB charger into the pi and wait for the blue LEDs on the tinyLiDAR sensors to blink rapidly showing that they are taking measurements. This proves the code is working properly.

You can then slowly but firmly connect pin 2 for the LED panel supply. Be careful not glitch it while doing this! If the LED panel shows a few frozen bright LEDs then it's probably glitched so remove the microUSB power from the pi and wait a few seconds to try the power up sequence again.

To run the code, enter the following:

cd /home/pi/parking/rpi-rgb-led-matrix/bindings/python/samples
sudo python parking.py

If all goes well you should get a display similar to the one shown in the video.

Have a quick look at the parking.py code to understand what limits we used. The default for the front sensor is 200mm. As the sensor range is 11mm to 2m it's a good idea to keep the nom_parked_Front distance at 200mm or higher. The side sensor nom_parked_Side is set to 600mm. See above picture for the Python code showing these configuration options.

If all is working, you can go ahead and mount the system in your garage and adjust the above parameters as needed. Since you're pi is connected to your WiFi, you can always go in and edit your distance settings as you need for your particular garage setup while it is still mounted.

"Is this now?"

Why yes, yes it is! -- time to do your happy dance :)

Thanks for reading and enjoy your new parking assistant!

Step 9: Optional Step and Helpful Commands

Optional Step - FTP addon for Sublime Text

To edit the Python script files directly on the pi, we can install the FTP addon called Sublime SFTP by Wbond. You can download this addon by following the instructions here

To setup this addon we need to configure the FTP credentials under the File | SFTP/FTP | Setup Server... page.

For our setup we used:

"type": "sftp",<br>"sync_down_on_open": true,
"sync_same_age": true,
"host": "",
"user": "pi",
"port": "22",
"remote_path": "/home/pi/",
"file_permissions": "664",
"dir_permissions": "775",

Use Ctrl+S or File | Save to save this information. You will be prompted for a name to call this configuration. We simply called it "rpizw_0_200"

Now to login to the pi from SublimeText, go to File | SFTP/FTP | Browse Server...

Select from the list of options that popup. You will want to choose the profile with the name you specified above ;) Follow the prompts to navigate the folders and edit the desired file.

Helpful Extras

Usefull Linux commands to use on the pi.

Before unplugging the pi, ALWAYS be sure to shut it down so you don't get file corruption on your microSD card. Enter this command:

sudo shutdown now 

and wait for the green led to turn off before unplugging power. Similarily to restart it, you can enter:

sudo reboot now

To list files in a directory, use this:


You can find other helpful Linux commands here



    • Creative Misuse Contest

      Creative Misuse Contest
    • Water Contest

      Water Contest
    • Clocks Contest

      Clocks Contest

    2 Discussions

    Hi jrlandau, good catch! We updated it now, thanks.