Detailed Step-By-Step Instructions
These instructions are intentionally broken out so you can see what’s happening at each step. It also makes debugging and fixing problems easier. It seems long, but these are all just simple copy/paste commands to put into an SSH terminal when connected to your Pi.
- Download the latest Raspbian image and write it to the SD card.
- In the Pi, plug in the following. Leave out the sensors for now (GPS, OBD2, etc).
- SD card
- Ethernet cable, with the other end going to your router
- USB power cable
- Allow the device to boot up (15-30 seconds)
- Find it’s IP from your router’s list of DHCP clients. It’s listed as “raspberrypi”
- Open up an SSH terminal window and log in with the default username of “pi”. Default password is “raspberry”. EX:
ssh -l pi 192.168.1.128
- Run the first time Raspberry Pi software setup to expand filesystem to use all the space available on the SD card. Then set the locale from Britain to US.
Unselect the British option:
Select the US option:
Confirm the selection on the next screen:
Also change the password; never leave the default password in a system.
- OPTIONAL Change hostname for convenience. Change the name to whatever you’d like such as “carputer”.
sudo nano /etc/hostname
- Update all the software on the Pi to the latest version:
sudo apt-get update && sudo apt-get install -y
I like to install these helpful utilities on every Linux server. “htop” is a graphical and easier to visualize version of “top”, the Linux command to see how your system is being used (CPU, RAM, etc), similar to the Task Manager in Windows. “bwm-ng” is a basic bandwidth monitor that shows you how much up/down usage there is.
sudo apt-get install htop bwm-ng
- So far, none of these steps have been BlackBoxPi-specific. This is what you do when you get a Raspberry Pi for the first time. You run the basic config, then update all the software on it so it’s up to date. Nothing special so far. Next, we’ll start getting it setup to work as a vehicular black box by installing standard Linux tools as well as the custom software.
- Install GPS software. This is the standard Linux library for using GPS devices.
sudo apt-get install gpsd gpsd-clients
- Verify that the GPS receiver is working by running this GPS monitor. You may receive an error when running the command above.
- Your standard NMEA GPS receiver has 2 modes: binary and NMEA (text). We need it in NMEA (text) mode so that the Pi can read the coordinates. It may be in binary mode by default. Switch it from binary mode to NMEA mode:
sudo gpsctl -f -n /dev/ttyUSB0
- Go to the github page for the client software: https://github.com/BizDevGeek/OBD2SDK_Python
- Instal pre-requisites:
sudo apt-get install python-gps sqlite3 python-serial
- Copy the SDK from GitHub to the Pi:
cd /home/pi git clone https://github.com/BizDevGeek/OBD2SDK_Python.git
- Now setup the client software. This is the software that runs the Pi’s “black box” functionality
cd /home/pi/OBD2SDK_Python python setup.py
- Answer each of the questions; the defaults will do unless you’re running your own API server. That is, the server that the Pi syncs all it’s data to. The default is to use this project’s free server. The only thing you need is an email address to keep track of your account. After that, you will have an API key to keep track of your data. Write this down and save it, along with the email address you used.
- Setup the Pi so that the service runs each time the Pi is booted:
sudo apt-get install upstart
- The above will prompt you to confirm, you may proceed. It’s switching from the traditional Linux method, sysvinit, of managing background services to the newer “upstart” system.
- Reboot the Pi
- Continue setting up the Pi so the logging software runs at startup. As of right now, only the GPS logging runs in the background. The same scripts can be copied to use the OBD2 logging.
sudo cp /home/pi/OBD2SDK_Python/gpslogger.conf /etc/init sudo service gpslogger start
- The gpslogger service is now running in the background. It’s recording GPS data and storing it in the local buffer on the SD card. Verify it’s running:
sudo service gpslogger status
This is what the output should look like:
gpslogger start/running, process 739
- If you can’t get upstart working and you need to manually run the GPS logging script:
It doesn’t output anything, as it normally runs as a background service.
- Your Raspberry Pi is now a working car black box. It’s logging GPS data right now! At each boot-up, the background service will log GPS data to a local database on the Pi. Continue reading below for instructions on syncing the data off the Pi and onto the cloud service, which is being built up to generate maps, graphs, and more.
Post-setup usage such as browsing to the Pi’s web based status page and other details.