All Projects → JonnoFTW → Rpi Can Logger

JonnoFTW / Rpi Can Logger

Project to log CAN bus data from a PiCAN2 and a GPS module

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Projects that are alternatives of or similar to Rpi Can Logger

Openvoiceos
OpenVoiceOS is a minimalistic linux OS bringing the open source voice assistant Mycroft A.I. to embbeded, low-spec headless and/or small (touch)screen devices.
Stars: ✭ 64 (-5.88%)
Mutual labels:  raspberry-pi-3, rpi
Opencv 3.2.0 Compiling On Raspberry Pi
Download, Compile, Build, and Install OpenCV 3.2.0 with Extra Modules on RPI running Jessie
Stars: ✭ 65 (-4.41%)
Mutual labels:  raspberry-pi-3, rpi
rpi boat utils
Utilities for Raspberry Pi, mostly for usage on a boat. Includes UART control scripts, traffic measurement tools for Mikrotik (RouterOS) and OpenWrt, AIS wireless daemon, AIS decoder and an extensible boat & IoT sensor daemon for Signal K.
Stars: ✭ 71 (+4.41%)
Mutual labels:  rpi, gps
Linux-System-Info-Webpage
Material Design Dashboard for Linux System Info. Great for RPi and other linux Distros
Stars: ✭ 19 (-72.06%)
Mutual labels:  rpi, raspberry-pi-3
Raspberrypi tempmon
Raspberry pi CPU temperature monitor with many functions such as logging, GPIO output, graphing, email, alarm, notifications and stress testing. Python 3.
Stars: ✭ 52 (-23.53%)
Mutual labels:  raspberry-pi-3, rpi
Mocs
My Own Car System, a Go & Qt application for your car
Stars: ✭ 218 (+220.59%)
Mutual labels:  gps, rpi
RaspberryPi-Packet-Sniffer
An HTTP and HTTPS sniffing tool created using a Raspberry Pi
Stars: ✭ 79 (+16.18%)
Mutual labels:  sd-card, raspberry-pi-3
Rpi gpio
Ruby conversion of RPi.GPIO Python module
Stars: ✭ 185 (+172.06%)
Mutual labels:  raspberry-pi-3, rpi
Enclosure Picroft
Mycroft interface for Raspberry Pi environment
Stars: ✭ 649 (+854.41%)
Mutual labels:  raspberry-pi-3, rpi
esp32-f9p-io-board
An IO-PCB (two motor-driver/H-bridge, CAN, RS232, ADS1115, relay, ethernet, ardusimple f9p compatible connector) with an ESP32 for 12V power, three 15V tolerant analog inputs, three 5V tolerant inputs.
Stars: ✭ 24 (-64.71%)
Mutual labels:  gps, can-bus
imusensor
Python library for communication between raspberry pi and MPU9250 imu
Stars: ✭ 47 (-30.88%)
Mutual labels:  rpi, raspberry-pi-3
Rpi Battery Monitor
Monitor battery voltage from a Raspberry Pi
Stars: ✭ 51 (-25%)
Mutual labels:  raspberry-pi-3, rpi
Raspberrypipkg
DEPRECATED - DO NOT USE | Go here instead ->
Stars: ✭ 758 (+1014.71%)
Mutual labels:  raspberry-pi-3, rpi
Gassistpi
Google Assistant for Single Board Computers
Stars: ✭ 911 (+1239.71%)
Mutual labels:  raspberry-pi-3, rpi
Pi Camera In A Box
Stream your Raspberry Pi Camera Module directly to your web browser
Stars: ✭ 49 (-27.94%)
Mutual labels:  raspberry-pi-3
Gpx Simplify Optimizer
Free Tracks Optimizer Online Service
Stars: ✭ 61 (-10.29%)
Mutual labels:  gps
Fiscalberry
[JSON ↔ HW] Connect things using JSON API with the fiscalberry websocket server interact easily with any kind of Hardware. Another IoT solution...
Stars: ✭ 44 (-35.29%)
Mutual labels:  raspberry-pi-3
Potato Library
Easy to use Utility library for Android
Stars: ✭ 45 (-33.82%)
Mutual labels:  gps
Libgps
UART NMEA GPS library for Raspberry Pi
Stars: ✭ 60 (-11.76%)
Mutual labels:  gps
Touchosc2midi
a (linux compatible) TouchOSC Midi Bridge written in python
Stars: ✭ 44 (-35.29%)
Mutual labels:  rpi

Raspberry PI CAN Bus Logger

This project provides code for logging CAN Bus data with a Raspberry Pi. It additionally also logs GPS data. All of this data is stored on an SD card and can then be easily uploaded to a server for easy viewing.

Features

  • Logs and interprets CAN bus data from:
    • OBD2
    • Tesla vehicles
    • Bus and Truck with FMS
    • Outlander PHEV
  • Logs GPS
  • Can operate in querying and sniffing mode
  • Stores data on SD card. Can be configured to automatically upload via web API when connected to WiFi or 4G internet.
  • Can be powered entirely from power provided by the OBD port in your vehicle! You can also wire it into your fuse box or cigarette lighter to prevent it being powered permanently and draining your battery.
  • Accompanying Bluetooth App to:
    • Visualise your data in realtime
    • Fetch and upload stored data
  • Web based data visualiser

Parts

The following parts are used:

If you want WiFi to work with the PiCAN2 shield attached, you'll need to unsolder the GPIO pins and drop them to the bottom and reattach the shield.

If you are using the DC-DC converter, you will need to plug its outputs into the GPIO pins of the Raspberry Pi at pins 2 (5v power) and 6 (ground):

Rpi Pins

To make your own OBD connector, you will need:

You'll only need to connect pins:

  • 4 Chassis Ground
  • 6 CAN High
  • 14 CAN Low
  • 16 12V Power

OBD Pins

Tesla

Please follow steps 1 and 2 from this instructable to access the Tesla CAN bus http://www.instructables.com/id/Exploring-the-Tesla-Model-S-CAN-Bus/:

You will need the following parts:

Full Setup

  1. Download the latest raspbian lite image from here: https://raspberrypi.org/downloads/raspbian
  2. Insert your SD card into your computer
  3. Use your preferred method to put the rasbpian image onto your machine. On linux:
wget https://downloads.raspberrypi.org/raspbian_lite_latest
tar -xvf  raspbian_lite_latest
# the if argument might be different
dd if=2017-09-07-raspbian_stretch-lite.img of=/dev/sdb bs=4M conv=fsync status=progress
  1. Unmount your SD card, and plug it into your raspberry pi
  2. Run the following commands after logging in (default username is pi, password is raspberry) and configuring wifi by putting your settings in /etc/wpa_supplicant/wpa_supplicant.conf (you will need to restart the wifi to have the settings take effect by running sudo service networking restart):
sudo apt update
sudo apt install git make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils bluez python-bluez pi-bluetooth python3-yaml python-yaml
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.6.2
git clone https://github.com/JonnoFTW/rpi-can-logger.git

Install Rpi-Logger

  1. Determine the configuration file you want to use or roll your own.
  2. To install the dependencies and system services, run:
pip3 install -r requirements.txt
sudo python3 setup.py config_file.yaml
  1. Enable UART on your RPI (for the GPS) and CAN (skip the second dtoverlay line if your CAN shield only has 1 input) for the CAN shield by adding these lines to /boot/config.txt:
enable_uart=1
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=24
dtoverlay=spi-bcm2835
  1. In order to stop the RPI from asking your serial ports /ttyS0 to log on, change /boot/cmdline.txt and remove:
console=serial0,baudrate=115200
  1. Add these lines to your /etc/network/interfaces file (set it to 250000 if you are using FMS and skip can1 if you only have 1 CAN port):
auto can0
iface can0 inet manual
    pre-up /sbin/ip link set can0 type can bitrate 500000 triple-sampling on restart-ms 100
    up /sbin/ifconfig can0 up
    down /sbin/ifconfig can0 down

auto can1
iface can1 inet manual
    pre-up /sbin/ip link set can1 type can bitrate 500000 triple-sampling on restart-ms 100
    up /sbin/ifconfig can1 up
    down /sbin/ifconfig can1 down

  1. The logging and file upload service will now run on startup. By default it will use: example_fms_logging.yaml.
  2. To setup uploading of files, you will need to create a mongo_conf.yaml file in the project directory:
log_dir: ~/log/can-log/
keys:
 - vid_key_1
 - vid_key_2
api_url: http://url.to/api/ # the api on the end is important

Configuration

RPI-CAN-Logger is highly configurable and supports nearly all standard OBD-2 PIDs and the currently understood frames from Tesla as described in this document.

Configuring CAN Logging

We currently support 4 forms of logging:

Here we will examine the various configuration options:

interface: socketcan # can bus driver
channel: can1 # which can bus to use
log-messages: /home/pi/log/can-log/messages/ # location of debug messages
log-folder: /home/pi/log/can-log/ # location of log files
log-size: 32 # maximum size in MB before log file is rotated 
log-pids: # the pids we want to log, refer to rpi_can_logger/logger/obd_pids.py,  tesla_pids.py fms_pids.py outlander_pid
  - PID_ENGINE_LOAD
  - PID_THROTTLE
  - PID_INTAKE_MAP
  - PID_RPM
  - PID_SPEED
  - PID_MAF_FLOW
log-trigger: PID_MAF_FLOW # when this PID is seen, return the buffer in current state (only works in sniffing mode)
disable-gps: false # enable/disable GPS logging
gps-port: /dev/ttyS0 # serial port for GPS device
tesla: false # indicates whether or not we are logging a tesla vehicle
sniffing: false # indicates that we are sniffing
log-bluetooth: true # whether or not we log to bluetooth
bluetooth-pass: super_secret_password # the password required to stream the bluetooth data
log-level: warning # log level (warning or debug)
fms: false # are we logging FMS? (Bus and Truck only)
verbose: true # give verbose message output on stdout

Configuring Data Upload

In the root directory of this project create a file called: mongo_conf.yaml, it should look like this:

log_dir: /home/pi/log/can-log/
pid-file: ~/log/can-log.pid
api_url: 'https://url.to.server.com/api/'
keys:
    - vid_key_1
    - vid_key_2

The keys are the API keys for each vehicle that this logger will log for.

Cloning SD Cards

Because we're deploying to a lot of these devices, you'll need to make an image after setting everything up on your SD card. Once you're done, plug your SD card into another computer and run:

dd of=logger.img if=/dev/sdb bs=4M conv=fsync status=progress

Once that's finished you'll have a file called logger.img on your machine, insert a new card and run:

dd if=logger.img of=/dev/sdb bs=4M conv=fsync status=progress

This should clone the SD card assuming they're exactly the same. If the cards are different sizes:

Larger Card
  • Run raspi-config and resize the partition OR
  • Remount the SD card and use your favourite partitioning tool to expand the 2nd partition
Smaller Card

Assuming the amount of data used on the image is less than the target SD card size, then you will need to shrink the data partition before you make the clone SD card. You can do this on Linux with the following (from this tutorial):

sudo modprobe loop
sudo losetup -f
sudo losetup /dev/loop0 logger.img
sudo partprobe /dev/loop0
gksu gparted /dev/loop0

Use gparted to resize the 2nd partition so that it fits within the size of your target SD card. Then hit apply. Now we will truncate the image.

sudo losetup -d /dev/loop0
fdisk -l logger.img

You should get something like:

$ fdisk -l logger.img 

Disk fmslogger.img: 15.9 GB, 15931539456 bytes
255 heads, 63 sectors/track, 1936 cylinders, total 31116288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x96bbdd32

        Device Boot      Start         End      Blocks   Id  System
logger.img1            8192       93813       42811    c  W95 FAT32 (LBA)
logger.img2           94208    31116287    15511040   83  Linux

Record the sector size (on the 2nd line "Units = ...", 512 bytes here) and end for the 2nd partition (31116287 here), now you can run:

truncate --size=$[(31116287+1)*512] logger.img

You can now write the shrunken image.

Configuring Clones

After you've done all that set a new hostname (with no hyphens after rpi-logger-) for your device by running:

sudo python3 ./systemd/pariable.py rpi-logger-12345
sudo reboot

Where 12345 is the vehicle identifier. In order to connect via the bluetooth app, the device hostname must start with rpi-logger-

You'll also probably need to pair the bluetooth with your phone, run:

sudo bluetoothctl
discoverable on
pairable on

Initiate pairing on your phone. Then run:

discoverable off
pairable off
quit

Reboot your device and everything should be good to go.

Testing

There's a bunch of different tests provided the tests folder:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].