Skip to content
 
 

Repository files navigation

EVNotiPi

Work In Progress.
Adapted to suit MY hardware, some of which I already owned (OBDLink MX+, USB GPS antenna, Huawei MS2372H-517 4G Modem). I don't suggest that someone else repeat these steps, as I would do things differently if I had to do it again. But I still want to document what I did, mostly for myself:

Python Version of EVNotify

Needed Hardware

Wiring

OBD2 connection

OBD2       
4,5  GND   
  6  CAN_H 
 14  CAN_L 
 16  12V   

I only connected Pin4 to Ground as it is documented as Chassis Ground. Pin5 is the Signal Ground, I wanted to make sure I don't contaminate it.

Installation

Raspberry Pi

  • sudo apt update
  • sudo apt upgrade
  • sudo apt install python3-{pip,rpi.gpio,serial,requests,sdnotify,pyroute2,smbus,yaml,gevent} gpsd gpsd-clients git watchdog rsyslog-
  • sudo systemctl disable --now serial-getty@ttyAMA0.service
  • sudo sed -i -re "\$agpu_mem=16\nmax_usb_current=1\ndtoverlay=gpio-poweroff,gpiopin=4,active_low=1\ninitial_turbo=60\nboot_delay=0\ndisable_splash=1" -e "/^dtparam=audio=/ s/^/#/" /boot/config.txt
  • sudo sed -i -re '/console=/ s/$/ panic=1/' /boot/cmdline.txt
  • sudo sed -i -re '/max-load/ s/^#//' /etc/watchdog.conf
  • sudo sed -i -re "\$adtparam=watchdog=on" /boot/config.txt

If using the i2c watchdog (the one with the Trinket M0):

  • sudo sed -i -re "\$adtparam=i2c_arm=on,i2c_arm_baudrate=50000" /boot/config.txt
  • sudo sed -i -re "\$ai2c-dev" /etc/modules

EVNotiPi

  • sudo git clone https://github.com/DBestman/EVNotiPi /opt/evnotipi
  • cd /opt/evnotipi
  • sudo rm -r extras/ # Don't need this folder to operate
  • sudo git ls-files --deleted -z | sudo git update-index --assume-unchanged -z --stdin # Tell git to ignore the files deleted above.
  • sudo pip3 install -r requirements.txt
  • sudo systemctl link /opt/evnotipi/evnotipi.service
  • sudo systemctl enable evnotipi.service
  • sudo cp config.yaml.template config.yaml

Edit config, follow comments in the file

  • sudo nano config.yaml # nano or any other editor

Set up Bluetooth OBDII dongle

  • sudo bluetoothctl
  • [bluetooth]# power on
  • [bluetooth]# scan on
Note the MAC address of your dongle
  • [bluetooth]# scan off
  • [bluetooth]# pair <MAC>
  • [bluetooth]# quit
  • sudo rfcomm bind 0 <MAC>
  • ls /dev/rfcomm0 # /dev/rfcomm0 should appear
  • sudo systemctl link /opt/evnotipi/rfcomm-bind@.service
  • sudo systemctl enable rfcomm-bind@<MAC>.service

Set up USB LTE Stick

  • sudo nano USBModem.rules # nano or any other editor
  • sudo ln -s /opt/evnotipi/USBModem.rules /etc/udev/rules.d/20-USBModem.rules # Install USBModem.rules : http://reactivated.net/writing_udev_rules.html#why
  • sudo udevadm control --reload-rules && sudo udevadm trigger # reload udev rules
  • sudo apt install wvdial
  • sudo mv /etc/wvdial.conf /etc/wvdial.conf.bak # back up old configuration file
  • sudo ln -s /opt/evnotipi/wvdial.conf /etc/wvdial.conf # use my wvdial configuration file
  • sudo nano /etc/wvdial.conf # nano or any other editor
  • sudo wvdial # check that wvdial works
  • sudo systemctl link /opt/evnotipi/wvdial.{path,service}
  • sudo systemctl enable wvdial.{path,service}

Set up a GPS receiver

Verify that the GPS receiver is working correctly. If not, see a tutorial here: https://maker.pro/raspberry-pi/tutorial/how-to-use-a-gps-receiver-with-raspberry-pi-4

  • cgps -s

Because of a bug where the GPS position is not updated, I added a command (ExecStartPre=ubxtool -p RESET) in evnotipi.service, to be run before evnotipi. See https://www.reddit.com/r/raspberry_pi/comments/sthxpg/why_does_gpsd_not_update_a_location_past_its/

  • sudo sed -i -re '/^ExecStart=.*/i ExecStartPre=ubxtool -p RESET' evnotipi.service

Optional: Set up RaspAP

RaspAP allows the Pi to become a wireless access point, enabling access to Internet when you're in your car.
Follow the instructions here: https://docs.raspap.com/ap-sta/.
I had to uninstall/reinstall RaspAP several times before I could configure properly, but I don't remember what were the difficulties. Maybe it was a buggy version.

To uninstall RaspAP
  • cd /var/www/html
  • sudo installers/uninstall.sh

Optimizing Boot Time

Debug with systemd-analyze && systemd-analyze blame && systemd-analyze critical-chain evnotipi.service

  • sudo raspi-config nonint do_boot_wait 1 # Don't wait for network connection on boot. This saves a few seconds.
  • sudo sed -i -re '/console=/ s/$/ quiet fastboot/' /boot/cmdline.txt
  • sudo systemctl disable keyboard-setup.service # Keyboard not needed for headless
  • sudo systemctl disable triggerhappy.{service,socket} # Unless you have an external joystick or something that uses `/dev/input/`
  • sudo systemctl mask systemd-rfkill.service # Disabling won't work. Unless you have a hardware button to disable the WIFI you won't need this

About

Python Version of EVNotify

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages