Install MotoReco


  1. Removing rear seat.
  2. Removing front seat.
  3. Removing number-plate carrier.
    1. Disengage and disconnect plugs for the flashing turn indicators.
    2. Remove screws.
    3. Pull down and remove number-plate carrier.
  4. Releasing rear-wheel cover.
    1. Remove screw.
    2. Pull rear-wheel cover down slightly at the rear.
  5. Installing MotoReco Logger.
    1. Disengage and disconnect plugs for anti-theft alarm system.
    2. Connect MotoReco Logger.
    3. Set GPS antenna where facing open sky and avoiding rain. I set my GPS antenna on fuel tank under the cowl. You may think put antenna on the LED headlight unit, however, there is no good because of  noise from the unit.


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.


Fixed Formula GPS

Fixed Formula is implemented in DecodeRule.cs.


Ch Name CAN ID Formula
Latitude 7FF* (Data8*16777216+Data7*65536+Data6*256+Data5-90000000)/1000000
Longitude 7FF* (Data4*16777216+Data3*65536+Data2*256+Data1-180000000)/1000000
GPS Speed 7FE* (Data8*16777216+Data7*65536+Data6*256+Data5)/1000000*3600/1000
Altitude 7FE* (Data4*16777216+Data3*65536+Data2*256+Data1-1000000000)/1000000

*GPS data comes from GPSD so originally it have no CAN ID. However to treat GPS data as same as normal CAN data, MotoReco Logger intentionally added dummy CAN ID for GPS data.

Fixed Formula K51

Fixed Formula is implemented in DecodeRule.cs.


Ch Name CAN ID Formula
Engine RPM 10C (LoData4*255+Data3)*5
Throttel Valve Position 10C Data6/255*100
Throttel Position 10C Data8/255*100
Throttel Grip Position 110 Data6/255*100
FrBrake1 120 Data3/4
FrBrake2 120 Data5/4
RrBrake1 120 Data4/2
RrBrake2 120 Data6/2
FrStroke 29C (LoData7*256+Data6)/5
RrStroke 29C (Data8*16+HiData7)/3
LeanAngle 10C (Data5*90/128-90)*-1
FrSpeed1 293 (LoData5*256+Data4)/8
K51 FrSpeed2 293 (Data3*16+HiData2)/8
RrSpeed 293 (LoData2*256+Data1)/8
SlipRate * rrSpeed/frSpeed*100-100
Gear 2BC HiData6
YawRate 174 Data2*125/128+Data1/256-125
YAxisG 174 (Data6+Data5/256-128)/32
RollRate 178 Data2*125/128+Data1/256-125
XAxisG 178 (Data6+Data5/256-128)/32
ZAxisG 17C (Data6+Data5/256-128)/32

*Channel is calculated by MotoReco Viewer, not from CAN data itself.

Fixed Formula


BMW Motorrad CAN data have been analyzed like following links,

So well known channel is able to be hard corded in the program, however, at the moment only K51 and GPS fixed formula is implemented because that all I can analyze.

If you send me another BMW motorrad data, I can add model specific fixed formula for MotoReco Viewer.

Or since MotoReco Viewer is open source, you can inspect your CAN data and once find out formula, you can add fixed formula of your bike.

Fixed Formula are available following models


In MotoReco Viewer, you can define two types of formula to convert CAN data to recognizable physical value.

  1. Fixed Formula
  2. Dynamic Formula

Fixed Formula is hard coded in MotoReco Viewer, so much faster calculation than using Dynamic Formula. Some famous channels such as engine RPM, throttle valve position and so on have been analyzed already, so we can use fixed formula for known channel.

If you want to configure fixed channel, you can browse fixed formula by clicking button right next to Formula text edit box. Then you will see fixed formula categorized by motorcycle and GPS.

The other way is define formula manually into Formula text box. Each CAN data have 8 byte data so you can use these data expressions,

  • Data1~Data8*
  • HiData1~HiData8
  • LoData1~LoData8

*Data starts from 1 to 8.

HiData* mean higher 4 bit of Data*. LoData* mean lower 4 bit of Data*.

You can combine these data expressions and following arithmetic operation symbols,

  • +
  • /
  • *
  • ()

So you can define formula like this,

  • Data1 (Just using Data1 itself.)
  • Data1+Data2
  • HiData2+Data3/4
  • (LoData4*255+Data3)*5


MotoReco Viewer


MotoReco Viewer is Windows App to visualize and analyze CAN data. MotoReco Viewer source is available from github.


MIT License


Download and unzip wherever you want to install.


At first, download sample data and sample ddf file.

  1. Click Option->Ch Setting and Decode Option Dialogue will appear.
  2. Click Load button and select ddf file that you downloaded from link above.
  3. In this dialogue, you can configure how to convert data from ECU value to physical value and how to show on graph.
      1. Add button adds new channel. You must configure
        • Channel Name
        • CAN ID
        • Formula
        • Channel Color
        • Minimum physical value
        • Maximum physical value
      2. Edit button changes existing channel configuration.
      3. Delete button delete existing channel configuration.
      4. Up and Down button moves selected item.
      5. Load button loads ddf(data definition file).
      6. Save button saves list view items to ddf file.
      7. Clear button clears list view.
      8. Press the Ana button and select the MotoReco data file when the file selection dialog appears.The list on the left shows a list of all CAN IDs found in the data file. Select the CAN ID you want to analyze and display from the list on the left, and press the right button to add the CAN ID to the list on the right. In the options at the bottom of the screen, you can select the decoding method for analyzing the CAN ID.When you press the OK button, the Decode Option dialog will automatically add the decoding conditions for the selected CAN ID to the Decode Option dialog.Using this feature, you can efficiently analyze unknown channel information.
  4. Once the channel information is set on the main screen and the data is ready to be read, select the MotoReco data in File→Open.
    Reading the data takes a bit of time as the CAN data is read while converting the physical values. The time required depends on the number of channels, and if Dynamic Formula is included, it will be much slower.
  5. In the left graph area, rotate the wheel to fine-tune the displayed data to the left or right, or press Ctrl and rotate the wheel to zoom in/out on the data.

    In the top left graph area, left click to move cursor 1 and right click to move cursor 2.

    In the upper right corner, the data for cursor 1 and cursor 2 are displayed. The calculated value of Max-Min is useful for analyzing the CAN data to quickly distinguish between unchanged and unused channels, and between changing and likely to be used channels.

    The MAP is shown in the bottom right corner. The route highlighted with red line becomes the data range displayed on the main screen now. You can change the type of the map by right-clicking. The display position of the Map can be changed by right-click and dragging.In addition, when you use Google Maps, please get an API key by yourself and use it by registering an API key in the Option→Map Setting menu.



MotoReco is Raspberry Pi Zero based CAN logger system for recent models of BMW Motorrad.  MotoReco Logger is designed as “coupler-in”* so  all you need is just plug MotoReco Logger into DWA coupler of your motorcycle.

MotoReco is essentially just a CAN data logger** system, so you can also install MotoReco Logger to any kind of CAN bus.

*MotoReco Logger is “coupler-in” when your motorcycle is compatible to latest DWA unit of BMW Motorrad. Check DWA page.

**MotoReco Logger can record only base frame format at the moment. MotoReco Logger hardware itself is ready for extended frame format however MotoReco softwares are programmed to respond to  base frame format. (Because BMW Motorrad only uses it.)



MotoReco Logger consists of Raspberry Pi Zero, Original MotoReco Hat and GPS module.


MotoReco Logger mainly consists of 3 programs,

  1. mrlogger: The main program records CAN data in the key-on state.
  2. mrserver: The program broadcasts the latest data for each CAN ID via UDP. I plan to use it to develop an app that will allow you to connect your phone to MotoReco via WiFi to check CAN data.
  3. mrgpio: This little program is a power management program that works in conjunction with the bike’s key On/Off.

These three programs are running on Raspbian Buster Lite. Whole procedure of Setting up MotoReco Logger takes some time, so you can also download MotoReco Logger image.

MotoReco Logger image is configured as

  • WiFi access point, ssid:MotoReco and pass:motoreco
  • MotoReco Logger IP:
  • SSH server, login with user:pi and pass:motoreco

After first time login with ssh,

  • sudo raspi-config
  • go to Advanced Option
  • go to Expand Filesystem

After reboot, now MotoReco Logger become default setting.

MotoReco Viewer is windows software. MotoReco viewer allow you to visualize and analyze CAN data.


  1. Install MotoReco Logger to your motorcycle.
  2. Ride motorcycle.
  3. When you come back home, key on your motorcycle and wait MotoReco awake.
  4. MotoReco is configured as WiFi access point so just connect to ssid:MotoReco and password:motoreco.
  5. Open Windows file explorer and access “\\”. You’ll see motoreco folder and *.dat file which is logged data are there.
  6. Open data file with MotoReco Viewer to visualize or analyze.