Setting up MotoReco Logger

Preparing for Raspbian Buster Lite

Download Raspbian Buster Lite image from official site.

Write image file to your SD card.

Edit config.txt under boot partition of your SD card.

Add following line at the end of config.txt,


Also edit commandline.txt. Insert modules-load=dwc2,g_etherĀ after rootwait so whole command is like,

console=serial0,115200 console=tty1 root=PARTUUID=738a4d67-02 rootfstype=ext4 elevator=deadline rootwait modules-load=dwc2,g_ether quiet init=/usr/lib/raspi-config/

Finally, put empty file named “ssh” .

Boot and initial settings

Connect your computer and raspberry pi zero with USB cable.

Raspberry Pi Zero have two micro USB port and use micro USB port pointed by green arrow in picture above.

When raspberry pi is recognized as serial port, you need to install USB ether driver. You can download RPI Driver OTG from following webpage,

Pi Zero OTG Ethernet

When your computer recognize Raspberry Pi Zero as an ethernet device, you can see on device manager as an USB Ethernet/RNDIS Gadget.

Since windows 10 rev 1909, mDNS is implemented so Bonjour is no longer not need to install.

Now open your SSH client and connect to raspberrypi.local.

User name is pi and passphrase is raspberry.

Set up raspi-config

pi@raspberrypi:~ $ sudo raspi-config
  • Change User Password -> change password for pi. motoreco is default password for MotoReco Logger.
  • Network Options -> Hostname -> change host name. MotoReco is default host name for MotoReco Logger.
  • Localisation Options
    • Change Timezone -> change timezone where you use.Tokyo is default timezone for MotoReco Logger.
    • Change Wi-fi Country -> changeĀ  to country name where you use. Japan is default Wi-fi country for MotoReco Logger.
  • Interfacing option->
    • Camera:Disable
    • SSH:Enable
    • VNC:Disable
    • SPI:Enable
    • I2C:Disable
    • Serial:Serial Login:NO, Serial Port:Yes
    • 1-Wire:Disable
    • Remote GPIO:Disable
  • Advanced Option->
    • Expand Filesystem
    • Memory Split -> 16

after finish, reboot Raspberry Pi Zero.

Change apt repository server

pi@MotoReco:~ $ sudo nano /etc/apt/sources.list


deb buster main contrib non-free rpi


#deb buster main contrib non-free rpi
deb buster main contrib non-free rpi

This is sample for Japanese so use nearest server in your country.

Update Raspbian

Now it’s time to update raspbian, but before to do that, you need to configure your computer to able to share internet connection for your raspberry pi.

Open network adaptor configuration dialogue.

In my computer, network adaptor pointed by green arrow is connected to internet and orange one is connection to Raspberry Pi Zero.

So to let share internet connection to Orange adapter, right click and open property of Green adaptor.

  1. Select tab for share setting.
  2. Check option.
  3. Select network interface name of Raspberry Pi.

After configuring your computer, renew IP of Raspberry Pi.

pi@MotoReco:~ $ dhclient -r usb0

Now you can check internet connection,

pi@MotoReco:~ $ ping

If you have connection to internet, ping respond will come.

Now time to update Raspbian,

pi@MotoReco:~ $ sudo apt-get update
pi@MotoReco:~ $ sudo apt-get upgrade

Configure as Access Point

Install hostapd and dnsmasq.

pi@MotoReco:~ $ sudo apt-get install hostapd dnsmasq -y

Edit dhcpcd.conf

pi@MotoReco:~ $ sudo nano /etc/dhcpcd.conf

Add these two lines at the end of the file.

interface wlan0
static ip_address=

Create hostapd.conf,

pi@MotoReco:~ $ sudo nano /etc/hostapd/hostapd.conf

Just copy these,


Edit hostapd.conf,

pi@MotoReco:~ $ sudo nano /etc/default/hostapd

Insert following,


Back up original dnsmasq.conf

pi@MotoReco:~ $ sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig

Create dnsmasq.conf,

pi@MotoReco:~ $ sudo nano /etc/dnsmasq.conf 

Copy following,


Enabling hostapd and dnsmasq service,

pi@MotoReco:~ $ sudo systemctl unmask hostapd
pi@MotoReco:~ $ sudo systemctl enable hostapd
pi@MotoReco:~ $ sudo systemctl enable dnsmasq

Edit rc.local

pi@MotoReco:~ $ sudo nano /etc/rc.local

Copy following,

# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"

service dnsmasq stop
sleep 8
service dnsmasq start

exit 0


pi@MotoReco:~ $ sudo reboot

After rebooted, you can see ssid:MotoReco as WiFi access point.

Setting up Samba

Install samba,

pi@MotoReco:~ $ sudo apt-get install samba

During installation, you will be asked question and select No.

Open samba conf file with editor,

pi@MotoReco:~ $ sudo nano /etc/samba/smb.conf

Add these settings on global section,

    max protocol = SMB2
    security = user
    log level = 1

Also add these settings on the end of file,

    comment = Raspberry Pi
    path = /home/pi
    guest ok = yes
    read only = no
    public = yes
    browsable = yes
    force user = pi

Restart samba,

pi@MotoReco:~ $ sudo service smbd restart

Now you can access Raspberry Pi Zero with Windows explorer. Access “\\”. You will see your motorcycle logging data inside of this folder.

Install MotoReco Logger related packages

Install gpsd.

pi@MotoReco:~ $ sudo apt-get install gpsd gpsd-clients

Open gpsd conf file,

sudo nano /etc/default/gpsd

Configure conf file,

sudo nano /etc/default/gpsd
# Default settings for the gpsd init script and the hotplug wrapper.

# Start the gpsd daemon automatically at boot time

# Use USB hotplugging to add new USB devices automatically to the daemon

# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/ttyAMA0 /dev/pps0"

# Other options you want to pass to gpsd


Install wireing pi,

pi@MotoReco:~ $ sudo apt-get install wiringpi

Install libgps,

pi@MotoReco:~ $ sudo apt-get install libgps-dev

Configure MotoReco Logger specific setting

Modifying /boot/config.txt

pi@MotoReco:~ $ sudo nano /boot/config.txt

Add CAN setting, enabling GPS PPS, disabling audio and enabling Watch Dog at the end of config.txt

# CAN0 setting


Also, comment out


Modifying /etc/network/interfaces

pi@MotoReco:~ $ sudo nano /etc/network/interfaces

Add these setting at the end of file,

#CAN interface setting
auto can0
iface can0 inet manual
pre-up /sbin/ip link set can0 type can bitrate 500000 triple-sampling on listen-only on
up /sbin/ifconfig can0 up
down /sbin/ifconfig can0 down

auto usb0

Setting up ntp

Install ntp,

pi@MotoReco:~ $ sudo apt-get install ntp

Edit /etc/ntp.conf

pi@MotoReco:~ $ sudo nano /etc/ntp.conf

Comment out these,

#statistics loopstats peerstats clockstats
#filegen loopstats file loopstats type day enable
#filegen peerstats file peerstats type day enable
#filegen clockstats file clockstats type day enable

#pool iburst
#pool iburst
#pool iburst
#pool iburst

Adding these just after the comment out

server iburst
server prefer minpoll 4 maxpoll 4
fudge time1 0.32 refid GPS stratum 14
fudge time1 -0.03 refid PPS stratum 3

Use your nearest ntp server instead of

Create bash script that configure system date and time from GPS,

pi@MotoReco:~ $ sudo touch /usr/local/bin/
pi@MotoReco:~ $ sudo chmod 755 /usr/local/bin/
pi@MotoReco:~ $ sudo nano /usr/local/bin/

Copy these,

echo start at `/bin/date`
for i in 1m 1m; do
  echo sleep $i
  /bin/sleep $i
  GPSDATE="`/usr/bin/gpspipe -w | /usr/bin/head -10 | /bin/grep TPV | /bin/sed -r 's/.*"time":"([^"]*)".*/\1/' | /usr/bin/head -1`"
  echo $GPSDATE
  /bin/date -s "$GPSDATE"
echo end at `/bin/date`

Execute this script when reboot,

pi@MotoReco:~ $ crontab -e

Add this at the end of the file,

@reboot sudo /usr/local/bin/

Setting Up MotoReco Logger Programs

Modify /etc/rc.local again,

pi@MotoReco:~ $ sudo nano /etc/rc.local

Copy these,

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"

# turen off HDMI
/opt/vc/bin/tvservice -o


service dnsmasq stop
sleep 8
service dnsmasq start

exit 0

Create /usr/local/bin/

pi@MotoReco:~ $ sudo touch /usr/local/bin/
pi@MotoReco:~ $ sudo chmod 755 /usr/local/bin/
pi@MotoReco:~ $ sudo nano /usr/local/bin/

Copy these,


#check update program is available
if [[ -f /home/pi/update/mrlogger ]]; then
        mv /home/pi/update/mrlogger /usr/local/bin/mrlogger
        chmod 755 /usr/local/bin/mrlogger

if [[ -f /home/pi/update/mrserver ]]; then
        mv /home/pi/update/mrserver /usr/local/bin/mrserver
        chmod 755 /usr/local/bin/mrserver

if [[ -f /home/pi/update/mrgpio ]]; then
        mv /home/pi/update/mrgpio /usr/local/bin/mrgpio
        chmod 755 /usr/local/bin/mrgpio

#execute logger program
/usr/local/bin/mrgpio &
/usr/local/bin/mrlogger &
/usr/local/bin/mrserver &

exit 0

Next, download MotoReco Logger programs,

Extract zip file, and copy “update” folder into MotoReco Logger shared folder.

Next , just reboot logger.

pi@MotoReco:~ $ sudo reboot

When next reboot timing, /usr/local/bin/ invoked by /etc/rc.local will automatically copy program files under /home/pi/update to /usr/local/bin and start mrgpio, mrlogger and mrserver.

Tweak Raspberry Pi Zero

Add timeout for dhcpcd service,

pi@MotoReco:~ $ sudo nano /etc/systemd/system/dhcpcd.service.d/wait.conf 

Modify like this,

ExecStart=/sbin/dhcpcd -q -w -t 5

Disable not using services,

pi@MotoReco:~ $ sudo systemctl disable dphys-swapfile
pi@MotoReco:~ $ sudo systemctl disable keyboard-setup
pi@MotoReco:~ $ sudo systemctl disable triggerhappy
pi@MotoReco:~ $ sudo systemctl disable bluetooth
pi@MotoReco:~ $ sudo systemctl disable hciuart
pi@MotoReco:~ $ sudo systemctl disable raspi-config
pi@MotoReco:~ $ sudo systemctl disable avahi-daemon

Removing not using packages,

pi@MotoReco:~ $ sudo apt-get purge -y --auto-remove dphys-swapfile
pi@MotoReco:~ $ sudo apt-get purge -y --auto-remove dbus

Modify /boot/cmdline.txt again,

pi@MotoReco:~ $ sudo nano /boot/cmdline.txt


dwc_otg.lpm_enable=0 root=PARTUUID=738a4d67-02 rootfstype=ext4 elevator=deadline rootwait quiet

Modify /boot/config.txt again,

pi@MotoReco:~ $ sudo nano /boot/config.txt

Modify overclock section from

#uncomment to overclock the arm. 700 MHz is the default.


#uncomment to overclock the arm. 700 MHz is the default.

Now your MotoReco Logger is as same setting as MotoReco Logger Image. After this tweaking, you can not connect MotoReco Logger by USB cable, so connect WiFi access point.