Detailed Setup Guide

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.

  1. Download the latest Raspbian image and write it to the SD card.
  2. In the Pi, plug in the following. Leave out the sensors for now (GPS, OBD2, etc).
    1. SD card
    2. Ethernet cable, with the other end going to your router
    3. USB power cable
  3. Allow the device to boot up (15-30 seconds)
  4. Find it’s IP from your router’s list of DHCP clients. It’s listed as “raspberrypi”
    dd-wrt list of dhcp clients
  5. 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
  6. 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: raspi-config british locale
    Select the US option:
    raspi-config US locale UTF-8
    Confirm the selection on the next screen:
    raspi-config en_US.UTF-8
    Also change the password; never leave the default password in a system.

     sudo raspi-config
  7. OPTIONAL Change hostname for convenience. Change the name to whatever you’d like such as “carputer”.
     sudo nano /etc/hostname
  8. Update all the software on the Pi to the latest version:
     sudo apt-get update && sudo apt-get install -y
  9. OPTIONAL
    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
  10. 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.
  11. Install GPS software. This is the standard Linux library for using GPS devices.
     sudo apt-get install gpsd gpsd-clients
  12. Verify that the GPS receiver is working by running this GPS monitor. You may receive an error when running the command above.
    gpsmon /dev/ttyUSB0

    The output will look like this:
    Linux gpsmon output example

  13. 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
  14. Go to the github page for the client software: https://github.com/BizDevGeek/OBD2SDK_Python
  15. Instal pre-requisites:
    sudo apt-get install python-gps sqlite3 python-serial
  16. Copy the SDK from GitHub to the Pi:
    cd /home/pi
    git clone https://github.com/BizDevGeek/OBD2SDK_Python.git
  17. 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
  18. 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.
  19. Setup the Pi so that the service runs each time the Pi is booted:
    sudo apt-get install upstart
  20. 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.
  21. Reboot the Pi
    sudo reboot
  22. 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
  23. 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
  24. If you can’t get upstart working and you need to manually run the GPS logging script:
    python /home/pi/OBD2SDK_Python/gps_main.py

    It doesn’t output anything, as it normally runs as a background service.

  25. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

A Pi powered black box and cloud storage for your car