OLD AND OUTDATED!! (Raspberry Pi setup guide) - noradtux/evnotipi GitHub Wiki

This guide assumes you are running on some Linux system.

You will need some kind of cli access, either through UART or USB-OTG-serial

Modify boot-config etc

# MNT=/mnt
# DEV=/dev/sdXX  #<< i.e. check dmesg
# sudo mount ${DEV}2 ${MNT}
  • Optional: Convert rootfs to f2fs
# sudo tar -C ${MNT} -c . -S --numeric-owner --acls --xattrs -f /tmp/rootfs.tar
# sudo umount ${MNT}
# sudo parted ${DEV} resizepart 2 100%
# sudo mkfs -t f2fs -l rootfs ${DEV}2 (might need -f)
# sudo mount ${DEV}2 ${MNT}
# sudo tar -C ${MNT} -x --numeric-owner --acls --xattrs -f /tmp/rootfs.tar
# sudo mount ${DEV}1 ${MNT}/boot
# sudo sed -i -re '/PARTUUID=[a-f0-9-]+ +\/ +/ s/ext4/f2fs/' ${MNT}/etc/fstab
# sudo sed -i -re 's/ext4/f2fs/' ${MNT}/boot/cmdline.txt
# sudo umount ${MNT}/boot
  • Boot-settings
# sudo mount ${DEV}1 ${MNT}/boot
# sudo sed -i -re '/^gpu_mem=/ s/^/#/' ${MNT}/boot/config.txt
# sudo sed -i -re '/^dtparam=audio=/ s/^/#/' ${MNT}/boot/config.txt
# echo "gpu_mem=16" | sudo tee -a ${MNT}/boot/config.txt
# echo "max_usb_current=1" | sudo tee -a ${MNT}/boot/config.txt
  • use second UART
# echo "enable_uart=1" | sudo tee -a ${MNT}/boot/config.txt
  • or use primary UART and disable Bluetooth
# echo "dtoverlay=pi3-disable-bt" | sudo tee -a ${MNT}/boot/config.txt
  • enable shutdown signaling on pin 26
# echo "dtoverlay=gpio-poweroff:active_low" | sudo tee -a ${MNT}/boot/config.txt
  • enable i2c
# echo "dtparam=i2c_arm=on" | sudo tee -a ${MNT}/boot/config.txt
# echo "i2c-dev" | sudo tee -a ${MNT}/etc/modules
  • enable spi for MCP2515
# echo "dtparam=spi=on" | sudo tee -a ${MNT}/boot/config.txt
# echo "dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25" | sudo tee -a ${MNT}/boot/config.txt
# echo "dtoverlay=spi-bcm2835-overlay" | sudo tee -a ${MNT}/boot/config.txt
  • Optional: Enable OTG serial Console
# echo "dtoverlay=dwc2" | sudo tee -a ${MNT}/boot/config.txt
# echo "dwc2" | sudo tee -a ${MNT}/etc/modules
# echo "g_serial" | sudo tee -a ${MNT}/etc/modules
# sudo ln -s /lib/systemd/system/[email protected] ${MNT}/etc/systemd/system/getty.target.wants/[email protected]
# sudo mkdir -p ${MNT}/etc/systemd/system/[email protected]
# echo -e "[Service]\nTTYReset=no\nTTYVHangup=no\nTTYVTDisallocate=no" | sudo tee -a ${MNT}/etc/systemd/system/[email protected]/override.conf
# echo -e "ttyGS0" | sudo tee -a ${MNT}/etc/securetty

Cleanup

# sudo umount ${MNT}/boot
# sudo umount ${MNT}
# sudo rm /tmp/rootfs.tar

Rest wwill be done on the running Pi

  • Boot RasPi from sdcard

Setup networking

##* Allow for simultaneous STA- and AP-modes (not working) ##> # cat > /etc/udev/rules.d/70-wifi-ap.rules ##> SUBSYSTEM=="ieee80211", ACTION=="add|change", KERNEL=="phy0",
##> RUN+="/sbin/iw phy phy0 interface add ap0 type __ap"

  • Setup wifi client
# cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
country=DE
ctrl_interface=/run/wpa_supplicant GROUP=netdev
update_config=1
network={
    ssid="MYSSID"
    psk="passphrase"
}
# cat > /etc/systemd/network/wifi_sta.network
[Match]
Name=wlan*

[Network]
DHCP=yes
  • Configure wifi ap
# cat > /etc/hostapd/wlan0.conf
interface=wlan0
ssid=EVNotiLAN
driver=nl80211
country_code=DE
wpa=2
auth_algs=1
rsn_pairwise=CCMP
wpa_key_mgmt=WPA-PSK
wpa_passphrase=MY-SECRET-PASSWORD
# cat > /etc/systemd/network/wifi_ap.network 
[Match]
Name=wlan*

[Network]
Address=192.168.8.200/25
DHCPServer=yes
[DHCPServer]
EmitRouter=yes
# cat > /etc/systemd/network/eth.network 
[Match]
Name=en*

[Network]
DHCP=yes
IPv4ProxyARP=yes
IPForward=yes
  • Configure system services
# systemctl disable --now dhcpcd
# systemctl enable --now systemd-resolved
# systemctl enable --now systemd-networkd
# systemctl enable --now systemd-timesyncd
# systemctl disable --now wpa_supplicant.service
# systemctl enable --now [email protected]
# systemctl enable --now ssh
  • Install packages
# apt update
# apt upgrade
# apt install f2fs-tools libnss-resolve hostapd gpsd gpsd-clients git
# apt purge rsyslog
# systemctl disable --now hostapd
# systemctl enable --now hostapd@ap0
  • Bluetooth Serial
# bluetoothctl
[bluetooth]# power on
[bluetooth]# scan on

[bluetooth]# scan off
[bluetooth]# pair <MAC>
# rfcomm bind 0 <MAC>
  • /dev/rfcomm0 should appear

  • Install EVNotipi

# git clone --recurse-submodules https://github.com/EVNotify/EVNotiPi /opt/evnotipi
# cd /opt/evnotipi
# apt install python3-{pip,rpi.gpio,pexpect,serial,requests,sdnotify,can,pyroute2,smbus,influxdb,rfc3339}
# pip3 install -r requirements.txt
# systemctl link /opt/evnotipi/evnotipi.service
# systemctl link /opt/evnotipi/evnotipi_shutdown.service
# systemctl link /opt/evnotipi/evnotipi_shutdown.timer
  • Automatic start at boot
# systemctl enable evnotipi.service
# systemctl enable evnotipi_shutdown.timer
  • edit /opt/evnotipi/config.json
⚠️ **GitHub.com Fallback** ⚠️