A cool raspberry pi project that uses the GPS breakout module and 2 small Digole displays to have a navigation computer on your dash.
Download "RASPBIAN JESSIE LITE VERSION" https://www.raspberrypi.org/downloads/raspbian/
Create your new hard disk for DashboardPI
Insert the microSD to your computer via USB adapter and create the disk image using the dd command
Locate your inserted microSD card via the df -h command, unmount it and create the disk image with the disk copy dd command
$ df -h /dev/sdb1 7.4G 32K 7.4G 1% /media/XXX/1234-5678
$ umount /dev/sdb1
Caution: be sure the command is completely accurate, you can damage other disks with this command
if=location of RASPBIAN JESSIE FULL VERSION image file of=location of your microSD card
$ sudo dd bs=4M if=/path/to/raspbian-jessie-lite.img of=/dev/sdb (note: in this case, it's /dev/sdb, /dev/sdb1 was an existing factory partition on the microSD)
Setting up your RaspberriPi
Insert your new microSD card to the raspberrypi and power it on with a monitor connected to the HDMI port
Login
user: pi pass: raspberry
Change your account password for security (from terminal)
sudo passwd pi
Enable RaspberriPi Advanced Options (from terminal)
sudo raspi-config
Choose: 1 Expand File System
9 Advanced Options
A2 Hostname change it to "TripComputer"
A4 SSH Enable SSH Server
A7 I2C Enable i2c interface
Enable the English/US Keyboard
sudo nano /etc/default/keyboard
Change the following line: XKBLAYOUT="us"
Reboot PI for Keyboard layout changes / file system resizing to take effect
$ sudo shutdown -r now
Auto-Connect to your WiFi
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add the following lines to have your raspberrypi automatically connect to your home WiFi (if your wireless network is named "linksys" for example, in the following example)
network={ ssid="linksys" psk="WIRELESS PASSWORD HERE" } Reboot PI to connect to WiFi network
$ sudo shutdown -r now
Now that your PI is finally on the local network, you can login remotely to it via SSH. But first you need to get the IP address it currently has.
$ ifconfig Look for "inet addr: 192.168.XXX.XXX" in the following command's output for your PI's IP Address
Go to another machine and login to your raspberrypi via ssh
$ ssh [email protected]
Start Installing required packages
$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt-get install build-essential git gpsd gpsd-clients i2c-tools libi2c-dev python3 python3-pip python-dev python-gps python-imaging python-pip python-smbus rpi.gpio vim python-psutil
$ sudo pip install RPi.GPIO
Update local timezone settings
$ sudo dpkg-reconfigure tzdata
select your timezone using the interface
Setup the simple directory l command [optional]
vi ~/.bashrc
add the following line:
alias l='ls -lh'
source ~/.bashrc
Fix VIM default syntax highlighting [optional]
sudo vi /etc/vim/vimrc
uncomment the following line:
syntax on
In the "3DPrint/" folder of this project, print the gauges-final.stl file which will produce the Digole display surrounds needed to mount the 2 screens inside the gauge mount container.
Connect the following Devices the pins on the Pi Zero
Digole (each): 3v / GND / SDA / SCL
DHT11: 5v / GPIO 16 (36) / GND
Connect the GPS USB Module to RaspberriPi via HW UART connections Using HW UART for the GPS module requires the following to free the UART connection up on your Pi.
"Cross"-Connect the TX and RX pins from the GPS module to the RPi TX (GPIO 14/8 pin) and RX (GPIO 15/10 pin) -- [TX goes to RX on the device and vice versa.] Connect RPi 5V to the VIN pin and the GPS module GND pin to an available RPi GND pin.
Configure your Pi to use the GPS Module on UART
sudo vi /boot/cmdline.txt
change:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
to:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
(eg, remove console=ttyAMA0,115200 and if there, kgdboc=ttyAMA0,115200)
Note you might see console=serial0,115200 or console=ttyS0,115200 and should remove those parts of the line if present.
Run the following commands:
sudo systemctl stop [email protected]
sudo systemctl disable [email protected]
GPS Module Install For testing force your USB device to connect to gpsd
sudo gpsd /dev/ttyS0 -F /var/run/gpsd.sock
sudo systemctl stop gpsd.socket
sudo killall gpsd
sudo dpkg-reconfigure gpsd
sudo vi /etc/default/gpsd
# Default settings for gpsd. START_DAEMON="true" GPSD_OPTIONS="-n" DEVICES="/dev/ttyS0" USBAUTO="false" GPSD_SOCKET="/var/run/gpsd.sock"
Make sure the command is working
cgps -s
DHT11 Install
cd ~
git clone https://github.com/adafruit/Adafruit_Python_DHT.g...
cd Adafruit_Python_DHT/
sudo python setup.py install
sudo python ez_setup.py
cd examples/
vi simpletest.py
Change the following line:
sensor = Adafruit_DHT.DHT11
Comment the line out
pin = 'P8_11'
Uncomment the line and change the pin number to 16
pin = 16
Run the test
python simpletest.py
You should see a metric reading of Temp and Humidity displayed on the command line.
Setup and Run the scripts cd ~
sudo apt-get install ifstat memcached python-memcache postgresql postgresql-contrib python-psycopg2
sudo vi /etc/postgresql/9.4/main/pg_hba.conf
Add the following line to the end of the file:
local all pi password
sudo -i -u postgres
psql
create role pi password 'password here';
alter role pi login;
alter role pi superuser;
\du
(you should see your PI user with the permissions granted)
create database driving_statistics;
\q
exit
psql -d driving_statistics
Run the following queries:
CREATE TABLE driving_stats ( id serial, time timestamp without time zone NOT NULL, new_trip_start timestamp without time zone NULL, gps_latitude double precision , gps_longitude double precision, gps_altitude real, gps_speed real, gps_climb real, gps_track real, locale_address text, locale_area text, locale_city text, locale_county text, locale_country text, locale_zipcode text, inside_temp real, inside_hmidty real, weather_time timestamp, weather_summary text, weather_icon text, weather_apparentTemperature real, weather_humidity real, weather_precipIntensity real, weather_precipProbability real, weather_windSpeed real );
CREATE UNIQUE INDEX time_idx ON driving_stats (time);
Hack required to get GPSD working with UART connection on reboot sudo su
crontab -e
@reboot /bin/sleep 5; killall gpsd
@reboot /bin/sleep 10; /usr/sbin/gpsd /dev/ttyS0 -F /var/run/gpsd.sock
Create the logs folder for the data to be saved mkdir /home/pi/TripComputer/computer/logs
Setup the scripts to run at boot
crontab -e
Add the following lines
@reboot /bin/sleep 15; nohup python /home/pi/TripComputer/computer/mtk3339.py > /home/pi/TripComputer/computer/mtk3339.log 2>&1
@reboot /bin/sleep 18; nohup python /home/pi/TripComputer/computer/driving.py > /home/pi/TripComputer/computer/driving.log 2>&1
@reboot /bin/sleep 19; nohup python /home/pi/TripComputer/computer/address.py > /home/pi/TripComputer/computer/address.log 2>&1
@reboot /bin/sleep 30; nohup python /home/pi/TripComputer/computer/gauges.py > /home/pi/TripComputer/computer/gauges.log 2>&1
@reboot /bin/sleep 21; nohup python /home/pi/TripComputer/computer/locale.py > /home/pi/TripComputer/computer/locale.log 2>&1
@reboot /bin/sleep 22; nohup python /home/pi/TripComputer/computer/notification.py > /home/pi/TripComputer/computer/notification.log 2>&1
@reboot /bin/sleep 24; nohup python /home/pi/TripComputer/computer/temperature.py > /home/pi/TripComputer/computer/temperature.log 2>&1
@reboot /bin/sleep 25; nohup python /home/pi/TripComputer/computer/upload.py > /home/pi/TripComputer/computer/upload.log 2>&1
@reboot /bin/sleep 26; nohup python /home/pi/TripComputer/computer/weather.py > /home/pi/TripComputer/computer/weather.log 2>&1
@reboot /bin/sleep 30; nohup python /home/pi/TripComputer/computer/stats.py > /home/pi/TripComputer/computer/stats.log 2>&1
Setup the root user crontab to make sure the GPS module connects correctly
sudo su
crontab -e
Add the following lines
@reboot /bin/sleep 5; systemctl stop gpsd.socket
@reboot /bin/sleep 8; killall gpsd
@reboot /bin/sleep 12; /usr/sbin/gpsd /dev/ttyS0 -F /var/run/gpsd.sock
Finally create the local settings needed to run the trip computer
Find the file /computer/includes/settings.shadow.py
Create your own version of the settings file named simply settings.py
forecast.io API key for local weather information
weatherAPIURL = 'https://api.forecast.io/forecast/'
weatherAPIKey = 'API KEY HERE'
if you have the device hub project running (https://github.com/khinds10/DeviceHub)
devicesServer = 'http://my.server.com'
if you have the dashboard phone project running (https://github.com/khinds10/RetroDashboard)
dashboardServer = 'http://my.server.com'