Giter VIP home page Giter VIP logo

roadapplepi's Introduction

RoadApplePi

RoadApplePi is a simple to install system for your Raspberry Pi designed to record dashcam videos and engine information from your car in real-time, and then make it all accessable from an easy-to-use Web App that can be viewed on your smartphone or computer.

Demonstration video: https://www.youtube.com/watch?v=-G1HIgr2cvU

Features

  • Dashcam Recordings with car stats: Whenever your RoadApplePi is powered on and connected to a webcam and Bluetooth OBD2 reader, it's recording every piece of information it can scrape up. Using hardware-accelerated video encoding, this results in smooth dashcam footage and an instrument cluster that shows exactly what you (and others around you) were doing at any given time.
  • Real-time OBD (II) Information: See what's going on under-the hood in real time with our "Dashboard" view
  • Web App Access: Many "carputers" based around the Raspberry Pi require the installation of a screen in your car, making them difficult to install. RoadApplePi works around this issue by giving you a modern web app that can be accessed from any internet-enabled device.
  • Offline Access: Need to view dashcam recordings while away from your RoadApplePi? Not a problem! The Web App works without an active connection to your Pi, and you can cache videos and instrument clusters for offline viewing.
  • Wireless connectivity: Most of the time, your car will be out of range of any WiFi network. RoadApplePi solves this issue by having the option to create a wireless network, specifically for ease-of-access to the web app. You also have the option to connect to an existing wireless network if you're in range.
  • Set it up and forget about it: If you're going all the way with an automated car power system, you won't have to touch your RoadApplePi again after the initial setup (see "Power and Time Options" for more details)
  • ..And more to come! RoadApplePi is free software, developed in my free time. Depending on your help and support I hope to implement other features, such as:
    • More OBD pids (car stats)
    • The ability to read and log engine trouble codes
    • Tune your ECM
    • Export dashcam recordings with superimposed obd information as a video for complete compatibility
    • Become fully self-aware (just joking ... I hope)

What you need

RoadApplePi is designed to work with as little or much as you have. Bare minimum, you'll need

  • A Raspberry Pi. Any model will work, but the RPi Zero W or RPi 3 is recommended since they have Bluetooth and WiFi built in. Otherwise, a USB Bluetooth/WiFi dongle is required
    • Side note: This software was developed almost entirely on a RPi Zero W with few issues. However, due to the slow processor on this model, some things run slow. The Real-Time dashboard runs around 15 seconds behind, and loading the instrument cluster on recorded videos may take 20-30 seconds (after which, they play fine). If you're opting to use a slower model, I recommend doing the initial setup of a spare Raspberry Pi 2/3 to speed up the software compilation process. After that, the SD Card can be moved to your pi of choice
  • Class 10 SD Card with Raspbian Stretch (optionally, the lite flavor): This software was written to work on Raspbian Stretch, but it may work on other OSs. YMMV. Also, I recommend using at least a 16GB SD Card to give you enough space for your dashcam recordings. I've been using the same 32GB SD Card for the past 6 months with no issues. This gives me enough space to retain, on average, 3 weeks of recordings. If you need help setting up an SD Card with Raspbian, see here.
  • A Webcam: All development was done with an old USB webcam, but any webcam should work including Raspberry Pi-specific ones
  • A power source: Powering the beast is the trickiest part of the whole build. If you're just getting started, I'd recommend a 2A car phone charger with a micro USB cable to power the Pi. This won't automatically/cleanly power off your Pi, but it'll get it powered until you have a better solution in place. See "Power and Time Options" for more details.
  • Bluetooth ELM327 OBDII adapter (optional) While technically optional, a Bluetooth ELM327 adapter is required to record engine information. They're around $10 on Amazon and completely worth the price.

Installation

  1. Flash Raspbian (lite) onto an SD Card and boot your Raspberry Pi, performing any initial setup needed to get it connected to the internet
  2. From the command line, run:
    sudo apt update && sudo apt install -y git
    git clone https://github.com/JVital2013/RoadApplePi
    cd RoadApplePi
    ./setup.sh
    sudo reboot
    
    The setup script may take several hours to run, depending on your Raspberry Pi model
  3. On another device, go to http://raspberrypi/. --Note: Your device hostname can be changed by running sudo raspi-config on your pi. I've changed mine to "roadapplepi". A feature to change this from the web app will be added in the future
  4. Put it into Access Point mode, specifying a network SSID and Password
  5. After verifying that you can connect to the newly created WiFi network, shut down your Pi and move it out to your car. Connect your webcam to the Pi and the OBDII reader to your car and power the Pi back on
  6. With your ignition in the "Run" position, go to http://raspberrypi/ (or other hostname if you changed it). From the settings menu, pair your pi with the OBDII reader. Most of them use "1234" for the PIN.
  7. Go for a drive and see how it works!

Power and Time Options

If you've made it to this point, great! You should have a fully functional black box in your car. However, you have most likely run into two issues

  1. Raspberry Pis don't come with any sort of Real-Time Clock (RTC). In an internet-less location such as your car, your pi won't keep the time when turned off. You can partially solve this issue by synchronizing the time on the Pi with the time on your connected device (e.g. phone) via the web app, but this isn't optimal.
  2. Powering your Pi with your car's cigarette lighter if fraught with peril. In many cars, these ports are not "always on" and turn off with the car. This won't gracefully shut down your Pi, corrupting all your data. Even if the port is always on, you don't want the Pi recording 24/7. There are power management options in the web app, but they again aren't optimal

To solve both of these issues, there are two solutions that I recommend

Mausberry Circuits 3A Car Supply / Switch and an RTC

Out of the two, this is the simplest option, although it requires two components. The Mausberry Circuits 3A Car Supply (https://mausberry-circuits.myshopify.com/collections/frontpage/products/3a-car-supply-switch-1) performs two functions: it steps the car voltage down to a Pi-Friendly level, and gracefully shuts the Pi down automatically when the car powers off. On their web site, they mention wiring the device into your battery and ignition. Don't fret, you don't need to go to this extreme: you can use fuse taps to tap an always-on line, and an ignition-powered line in your fusebox. For more details on this, take a look at the SleepyPi 2 option.

Unfortunately, the Mausberry power supply does not contain an RTC, so you'll need to purchase one separately (unless you don't care about incorrect times). For more information, see https://cdn-learn.adafruit.com/downloads/pdf/adding-a-real-time-clock-to-raspberry-pi.pdf.

Fair warning, I haven't actually tried this, but it should work fine.

SleepyPi 2

Although this option is more complicated in initial setup compared to the Mausberry, it's the path I opted for and I've had great success. The SleepyPi 2 (https://spellfoundry.com/product/sleepy-pi-2/) is inherently an Arduino-based "Hat" for the Raspberry Pi that can be programmed as needed. Out-of-the-box, the SleepyPi 2 performs 2 functions that we care about: voltage transformation to Raspberry Pi friendly voltages, and an easy-to-configure RTC. However, it does not automatically power off the Pi when the car is switched off.

  • It must be programmed to do this. I've already modified one of Spell Foundry's example programs to do just this, and is the RoadApplePi.ino file in this repository. To flash this sketch onto your Sleepy Pi, see https://spellfoundry.com/sleepy-pi/programming-arduino-ide/.
  • You need to build a voltage divider for the program to be able to properly read the current power status of the car. Thanks to Spell Foundry, here's the voltage divider you need to build:
    Voltage Divider
    You can build this circuit on whatever you would like, but I used a solderable breadboard. For those less well-versed in reading schematics, here's a quick explanation of what you're doing
    • (Not shown in this schematic) Wire an always-hot line from your fuse box to the VIN of the SleepyPi
    • Wire an ignition-dependent line into the voltage divider (signified by the 14.4V in the diagram)
    • Wire a ground wire from your car into both the voltage divider (very bottom of the diagram) and the 0V part of the power input on the SleepyPi.
    • The outputs of the voltage divider are on the right of the diagram. If you're using my SleepyPi sketch, wire the 3.09V output into Pin 14 of the Sleepy Pi, and the 0V output to the SleepyPi's GND
  • Once assembled, you're left with a 3-layer sandwich: your raspberry pi, the sleepy pi, and your voltage divider. Here's what mine looks like installed in my car: Isn't it purdy?

Licensing

RoadApplePi is released under the GPLv3. For more information, see COPYING

Credits

The following software has made RoadApplePi possible

Special thanks to Zipcar for making the dream possible! I'd been playing with the idea for this project for quite some time, when on March 14, 2017, Zipcar ran a competition to give away 314 Raspberry Pi Zero Ws. I was a lucky winner with this idea. Thanks to this stroke of luck, I've been able to share this fun project with you all.

Also, extra special thanks to my wife, who put up with me shoving this project under her nose every time I made a tiny bit of progress.

Donate

If you really like this project and want to give back, donations are accepted!

  • Bitcoin: 177S69eip9mqpygozXKq9tzggK5aMpzKxQ
  • Ethereum: 0x40E182eF00F6834936Db68A1868699B0b23D8094
    paypal

roadapplepi's People

Contributors

jvital2013 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

roadapplepi's Issues

Record video off the CSI connection?

Does RoadapplePi record directly off the CSI connection without modifying the software? I saw you used an USB webcam in development and did not see information about the CSI connection.

Also, is there plans to add GPS data? I would be interested in potentially funding both of those options.

spent hours get to run on Pi3B+: last issue: No Gauges... No BT connection

Hey Folks!

Great Project...
I got issues with the connection of the ELM327 on a Rapsberry Pi3B+....
Tried a lot of things an visited other threads about connecting a Bluetooth OBD adapter to the pi...
checked with bluetoothctl: device is paired an trusted....
but on the LED´s of it i can see that there is no connection....

It´s paired but i´m getting no connection to it. Because of that i always get the " finfishing gauge sync" message.....

I used new Raspbian Buster install script, WIFI DHCP is working .... was a lot of work, but for now im stuck... it really kick´s my.... :(

Perhaps somebody can tell how the adapter is bind in as serial device....
I don´t have the experience to see how u implemented the data to be visible....

I only found out that the raprec service is listening on rfcomm0.... so stopping the service makes me able to use command "sudo rfcomm bind rfcomm0 " just to listen to it by the screen programm....

Help would be appreciated....
Thanks and greeting from Germany
Awesome Project!

No recordings

The web interface works, it just won't record any footage.

The webcam itself won't activate either, the led's on it won't light up.
I can get the webcam to work by using VLC, so i know the webcam itself works. Both VLC and RoadApplePi are setup to use /dev/video0, so that in itself is correct.

I also can't seem to find any error logging, even though it mentions setting up syslog in raprec.c.

I did use matt2005's version, at that seems to be updated to work with raspbian buster.

If i run raprec.c using the terminal, i am getting some errors from v4l2, such as:

invalid v4l2 control type encountered
Unknown v4l2 mpeg control id

Altough that might be because the software itself is already running at this point.

I did try a different webcam, that didn't change anything.

Anyone else with the same problem?

Access Point mode not working

I've tried this on a Pi 3, Pi Zero W, and a Pi 2 with USB Wifi adapter and none of them work in Access Point mode. I cannot discover the device from my phone or laptop once I've enabled it. I also tried reimaging the SD card with Raspbian Stretch Lite a few different times and running the script all from scratch (once on each of my Pi's)

Pi Camer

Hello. Can this be modified to record via the pi camera module?

Installing Error

Code: Select all

Step 4. Building and installing RoadApplePi
gcc raprec.c -o raprec -Wall -lmysqlclient -lm
raprec.c:34:10: fatal error: mysql/mysql.h: No such file or directory
#include <mysql/mysql.h>
^~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:3: raprec] Error 1
cp raprec /usr/bin
cp: cannot stat 'raprec': No such file or directory
make: *** [Makefile:8: install] Error 1
rm: cannot remove '/var/www/html/index.html': No such file or directory
sudo: mysql: command not found
Done! Please reboot your Raspberry Pi now
pi@DashCamPi:/RoadApplePi $

I tried matt2005 version also but same problem
IMG_20201223_221828

Where do videos save?

I can view videos no issue from webapp and they cache. Then where can I find the files on the pi?

Issue uploading RoadApplePi to Sleepy PI 2

I can’t get the RoadApplePi.ino to upload to the Sleepy Pi 2. I’ve tried everything I could possibly think of. The Arduino IDE always throws any error when trying to include file located in the sys directory (sys/time.h), says no such file or directory. Does anyone have any ideas?

Idea/issue

I'm a truck driver and really like your project.
Recently I bought a retroflag rpi case it uses the gpio pins to power on, reset and launches a script for safe shutdown shouldn't that be possible with this. I honestly have no idea I'm a hardware guy that dabbles in code.

Setup error

Hi there!

I tried to install it following the guide in the readme file, but no luck. Every time it gets stuck on:

"Step 4. Building and installing RoadApplePi
gcc raprec.c -o raprec -Wall -lmysqlclient -lm
raprec.c:34:10: fatal error: mysql/mysql.h: No such file or directory
#include <mysql/mysql.h>
^~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:3: raprec] Error 1
cp raprec /usr/bin
cp: cannot stat 'raprec': No such file or directory
make: *** [Makefile:8: install] Error 1
rm: cannot remove '/var/www/html/index.html': No such file or directory
chown: cannot access '/var/www/html': No such file or directory
chmod: cannot access '/var/www/html': No such file or directory
Created symlink /etc/systemd/system/multi-user.target.wants/raprec.service → /lib/systemd/system/raprec.service.
mkdir: cannot create directory ‘/var/www/html/vids’: No such file or directory
chown: cannot access '/var/www/html': No such file or directory
sudo: mysql: command not found
Done! Please reboot your Raspberry Pi now
"

Any idea what am I missing? Thanks!

GPIO Triggers

Would GPIO triggers be able to be added. Example is if GPIO pin 6 can be enabled with trigger offroad lights. And if it sees a positive voltage it displays as on along with odb gauges.

Many dependencies now deprecated and or missing, leads to non working setup script.

Step 4. Building and installing RoadApplePi
gcc raprec.c -o raprec -Wall -lmysqlclient -lm
raprec.c:34:10: fatal error: mysql/mysql.h: No such file or directory
#include <mysql/mysql.h>
^~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:3: raprec] Error 1
cp raprec /usr/bin
cp: cannot stat 'raprec': No such file or directory
make: *** [Makefile:8: install] Error 1
rm: cannot remove '/var/www/html/index.html': No such file or directory
chown: cannot access '/var/www/html': No such file or directory
chmod: cannot access '/var/www/html': No such file or directory
Created symlink /etc/systemd/system/multi-user.target.wants/raprec.service → /lib/systemd/system/raprec.service.
mkdir: cannot create directory ‘/var/www/html/vids’: No such file or directory
chown: cannot access '/var/www/html': No such file or directory
sudo: mysql: command not found
Done! Please reboot your Raspberry Pi now

The first run of the setup script terminated here.

Running it again shows, that there are a lot of packages missing:

RoadApplePi Setup v0.1-4-g34ee10a
Welcome to RoadApplePi setup. RoadApplePi is "Black Box" software that
can be retrofitted into any car with an OBD port. This software is meant
to be installed on a Raspberry Pi running unmodified Raspbian Stretch,
but it may work on other OSs or along side other programs and modifications.
Use with anything other then out-of-the-box Vanilla Raspbain Stretch is not
supported.

This script will download, compile, and install the necessary dependencies
before finishing installing RoadApplePi itself. Depending on your model of
Raspberry Pi, this may take several hours.

Would you like to continue? (y/N) y
Step 1. Updating system
Hit:1 http://raspbian.raspberrypi.org/raspbian buster InRelease
Hit:2 http://archive.raspberrypi.org/debian buster InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Step 2. Install pre-built dependencies from Apt
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'php7.0-thrift' for regex 'php7.0'
Note, selecting 'php7.0-remctl' for regex 'php7.0'
Note, selecting 'php7.0-common' for regex 'php7.0'
Note, selecting 'php7.0-curl' for regex 'php7.0'
Note, selecting 'php-remctl' instead of 'php7.0-remctl'
Note, selecting 'libmariadb-dev-compat' instead of 'libmariadbclient-dev-compat'
E: Unable to locate package php7.0-mysql
E: Couldn't find any package by glob 'php7.0-mysql'
E: Couldn't find any package by regex 'php7.0-mysql'
E: Unable to locate package php7.0-bcmath
E: Couldn't find any package by glob 'php7.0-bcmath'
E: Couldn't find any package by regex 'php7.0-bcmath'
Failed to disable unit: Unit file hostapd.service does not exist.
Step 3. Build ffmpeg (this may take a while)
FFMpeg already found at /usr/local/bin/ffmpeg! Using installed version.
Step 4. Building and installing RoadApplePi
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target 'install'. Stop.
cp: cannot stat 'html': No such file or directory
rm: cannot remove '/var/www/html/index.html': No such file or directory
chown: cannot access '/var/www/html': No such file or directory
chmod: cannot access '/var/www/html': No such file or directory
cp: cannot stat 'raprec.service': No such file or directory
cp: cannot stat 'hostapd-rap.conf': No such file or directory
cp: cannot stat 'dnsmasq.conf': No such file or directory
mkdir: cannot create directory ‘/var/www/html/vids’: No such file or directory
chown: cannot access '/var/www/html': No such file or directory
cp: cannot stat 'roadapplepi.sql': No such file or directory
sudo: mysql: command not found
Done! Please reboot your Raspberry Pi now

Mysql error during compilation

Hello,
I get following error during compilation (the same on Rpi Zero W and Pi 4B):

"gcc -o database1 chapter5_1.c -I/usr/include/mysql
gcc: error: chapter5_1.c: No such file or directory
gcc: fatal error: no input files
compilation terminated."

Any ideas how to get over this, please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.