MakerPlane pyEFIS with CAN Bus -
Quick Start Guide
Quick Start Guide
MakerPlane pyEFIS is a great little project to get you started with home built avionics. The latest version has some significant updates and integrates with increasingly more interfaces.
As I started playing around with it again after the update, I found several things that there were a few things that were a little hard to find if you plan to integrate with the MakerPlane CAN protocol (CAN-FiX) - which is what I'm mostly interested in. So this is mostly a place for me to remember a few of the nuances that I had to do to get it up and running on a Raspberry Pi 4B.
Hardware
Monitor
Like I mentioned, I have a Raspberry Pi 4B connected to a small 7" HDMI touch screen. I won't cover connecting the monitor - it's pretty straight forward and you likely have different hardware anyway, but here's a link to buy one that I thought was decent. https://www.amazon.com/dp/B07VNX4ZWY/?th=1
The monitor above isn't sunlight readable, so you may want to consider buying one from MakerPlane. Theirs is smaller, but brighter:
https://store.makerplane.org/5-sunlight-readable-touchscreen-hdmi-display-for-raspberry-pi/
SD Card
I used a SanDisk 16GB Ultra microSDHC UHS-I Memory Card. 16GB should be plenty for this, but feel free to buy something larger. After installing everything, I only used about half of the microSD card's capacity:
https://www.amazon.com/dp/B073K14CVB?th=1
SD Card Reader
You'll also need a USB Flash Memory Card Adapter. This is the one I bought about five years ago. It plugs into a USB port on your computer and can accommodate either a full-size or microSD card. It works really well and is cheap:
https://www.amazon.com/dp/B0779V61XB
Raspbian Operating System
The first thing to do is to install the Raspbian Operating System on your microSD card. Raspberry Pi has a handy tool called the Raspberry Pi Imager:
https://www.raspberrypi.com/software/
The RPi Imager software makes it super easy to get everything installed and ready. It will automatically download your favorite OS image and it even allows you to do some configuration before-hand (e.g. turn on SSH or VNC) so you don't have to do anything but put the microSD card into your RPi and turn it on to get started.
To start:
open Raspberry Pi Imager
Select your Raspberry Pi Device (a Raspberry Pi 4 in my case, but maybe you have another board)
Select the Operating System you want to install. Typically you'll just want to select the one at the top of the list (that's the latest release)
Plug in your SD card reader and click on the Storage button to select it. In my case, it was called Generic MassStorageClass USB Device - 15.9 GB
Then click Next
You'll be asked Would you like to apply OS customization settings?
Select EDIT SETTINGS
This is how I configured mine (I only changed stuff on the GENERAL tab and the SERVICES tab). Obviously, you should remember your username/password combination and configure things for your own network and locale. Click SAVE when you're done with your custom configuration.
I like to have a backdoor into the pi, so I enable SSH. SSH stands for Secure SHell and it allows you to use a terminal:
click the YES button to apply the settings to your microSD Card.
click YES again to acknowledge that you plan to delete everything on the microSD Card
As soon as you click the second YES, the process will start start the process of erasing/imaging your microSD Card. On my Windows 10 computer, I was prompted by Windows to select a drive. Ignore this - RPi Imager has just erased the microSD card, unmounted and remounted it. Windows is just recognized it as a new device, but RPi Imager is already applying the new image in the background.
When prompted, remove the microSD card, insert it into your RPi and power the RPi on. It should automatically connect to your WiFi network and it will prompt you to let you know what your IP address is.
Remote Control of Your Raspberry Pi
Remember how we set up SSH? Well, you can use it to connect to your RPi over your network. Open a command prompt on your Windows computer and type (or whatever you set as a username and host name in the OS Customization tab above) and press Enter:
You'll be prompted to enter a password. You won't see text as you type ... just trust that you're entering it and press enter. If it works, you'll get a command prompt that says:
pi@makerplane:~$
(or whatever your username/hostname was set to)
Now we'll use a special configuration tool that comes installed on Rasbian called raspi-config.
pi@makerplane:~$ sudo raspi-config
Note that the sudo portion of that command gives you admin permissions when you run the command. If you don't add it, the Pi will complain that you don't have admin permissions.
raspi-config is a text-based graphical configuration tool that allows you to easily turn on or off configurations. You will use the arrow keys on your keyboard to move between menus. And you can press Esc to cancel the current screen (e.g. go back to the previous screen).
VNC Remote Control
One of the things I like to do is enable a VNC Server on the Raspberry Pi. With some software installed on your computer, you can remote control the Pi. With raspi-config, you can enable VNC by using your arrow keys to select to
3. Interface Options
I3 VNC
<YES>
<OK>
Esc (or you can use the arrows to select <Finish> if you prefer)
If you do, you'll be prompted that the VNC Server is Enabled.
Now that you have the VNC server running on your Pi, you'll want to install the VNC Viewer software. This one from RealVNC is free and it works pretty well:
https://www.realvnc.com/en/connect/download/viewer/
Just download the one that matches your system (e.g. Windows or Linux or Mac or whatever) and install it. Then open it.
In the address bar at the top enter makerplane.local (or whatever you set your hostname to be above) and press Enter.
The VNC Viewer software will fire up a remote control session with the Pi and prompt you for your credentials (which you set above). I like to save my password so I don't have to type it every time I open a VNC session. Press OK and a remote control window will open.
At this point, you have two options for entering the commands below to complete the set up of your pyEFIS installation.
You can continue to use the SSH tool that you have open on your Windows computer. That is perfectly acceptable (and I actually prefer to do it that way). The remote control window will just look like what you see above until pyEFIS is configured and it starts running. At that point, you will have a hard time running additional commands through VNC - which is why I prefer the terminal.
However, if you like to control the RPi directly, click the terminal icon in the menu at the top (notice the red square around the shortcut in the image above).
Before installing the MakerPlane software, you will want to get the latest updates for your Raspberry Pi. Do this from the terminal window on the Pi or using SSH from your Windows computer (this is the last time I'll mention this - you can run the commands below from either location).
$ sudo apt update
$ sudo apt dist-upgrade -y
$ sudo reboot
That last command will, obviously, reboot the RPi.
Installing MakerPlane Software
Now that you have your RPi updated, it's time to start installing the software and configuring it for use. I followed this tutorial on the MakerPlane github repository. It was a little hard to find, so this should make it easier to follow along:
https://github.com/makerplane/pyEfis/blob/master/INSTALLING.md
Run the following commands (note that they may take a few minutes each to complete - be patient):
$ sudo apt install -y snapd
$ sudo snap set system experimental.hotplug=true
$ sudo snap set system experimental.user-daemons=true
That's as far as we can go without a reboot:
$ sudo reboot
When it comes back up, continue:
$ sudo snap install core
$ sudo snap install fixgateway
$ sudo snap install pyefis
At this point, pyEFIS will start up and will take over your entire screen. This is not a problem if you're using SSH from your Windows computer. You can still run commands from there.
CAN Bus Configuration
If you want to use CAN, you ... uh ... can. This won't go into detail about pushing CAN data out to the CAN Bus network. But assuming you already have that happening, this is how you set up your RPi to consume it:
You will need a USB CAN Bus module - I have tested a couple of them. This one is cheap and works out of the box with a Rasberry Pi:
https://www.amazon.com/dp/B0CRB8KXWL
When you plug it in, nothing really happens. That's because you need to enable CAN Bus functionality on your Pi.
Install can-utils (which includes all the drivers for the CAN module and the candump command that we'll get to below):
$ sudo apt install can-utils
Connect your CAN module to the CAN network (e.g. the GND, CAN-H, and CAN-L cables need to be wired to at least one other CAN module with the same wires, outputting data over the CAN network).
At this point, you probably won't see anything, but try the candump command to see if your CAN module is set up correctly. (hint: it probably isn't)
$ candump can0
Since you probably didn't see any data come across the network, you'll likely need to actually start up the device. Note: I added some instructions to make this happen automatically on reboot farther down in this - just test it for now by running these two commands:
$ sudo ip link set can0 type can bitrate 250000
$ ip link set up can0
You should see lights start flashing on your CAN module now as the data starts flowing over it (provided you have something reporting data over the CAN network). Try to see the data again with candump:
$ candump can0
This time a bunch of data should start appearing in the terminal. Each of the lines below represents a single CAN message coming across the bus. In this case, I had a little project I made that pulls Attitude data from a SpeedyBee F405 Wing RC Flight Controller and converts it to MakerPlane CAN messages (based on the MakerPlane CAN-FiX standard).
Below you can see three messages repeated over and over: 180, 181, and 185 (expressed in Hexadecimal - as decimals, those values are 384, 385, and 390). Those message types are defined as Pitch Angle, Roll Angle, and Heading (respectively) in the CAN-FiX standard.
So each message will tell pyEFIS to move the Attitude Indicator slightly in those three axes.
Automatically Starting the CAN Module
If you want to make sure that the CAN module starts automatically on reboot, you can set up a Linux service. A Linux service runs in the background and is ready for use when ever it's running.
First, create a new file called can0.service in the /etc/systemd/system folder, using the terminal-based text editor called nano. You'll notice that we have to edit this file using elevated privileges (sudo) because the location where you need to save the file is a protected area (it's meant to prevent just anyone from enabling a background service on a Linux computer).
Type this command to open this new file in nano:
$ sudo nano /etc/systemd/system/can0.service
Unless you've already done this, nano will open with a blank file. Copy and paste (or type) this text verbatim into the new file:
[Unit]
Description=Setup SocketCAN interface can0 with a baudrate of 250000
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/sbin/ip link set can0 type can bitrate 250000
ExecStart=/sbin/ip link set can0 up
ExecStop=/sbin/ip link set can0 down
[Install]
WantedBy=default.target
Press Ctrl+x and then y to save the file and exit nano.
You have created the service, but it won't run until you tell the operating system to do so. You'll want to enable the service to run whenever the computer starts. This command tells Linux to look in where the system service files are located and read all of them (including your new file):
$ sudo systemctl daemon-reload
And this one will enable the new service to run when the RPi starts up:
$ sudo systemctl enable can0.service
That should be it. When you restart your Pi, the CAN bus module should start up automatically and then pyefis should start up automatically as well. And if you have a CAN enabled sensor spewing out MakerPlane formatted CAN messages, fixgw will receive it and pyefis should start displaying the data.
Well ... almost ... see the next section.
An anomaly with can0 on a slow VM Host
I've noticed that on an older computer I've been using as a Virtual Machine Host is a little too slow to ennumerate the USB CAN device on the VM (Ubuntu 24.04) before fixgw starts up without it.
On that VM, I decided to try to do this another way, which requires manual intervention. I first created a new networkd service:
$ sudo nano /etc/systemd/network/80-can.network
These are the contents of that new file:
[Match]
Name=can*
[CAN]
BitRate=250000
Then the system has to be enabled just like the "can0.service" above:
$ sudo systemctl daemon-reload
$ sudo systemctl enable systemd-networkd.service
And then I have to restart the fixgw once can0 is finally started (sometimes I have to unplug and re-plug it in before restarting the service???).
$ sudo systemctl restart systemd-networkd.service
$ sudo snap restart fixgateway.daemon
Configuring pyEFIS/FIX-GW
By default, pyEFIS (and the underlying messaging bridge called FiX-Gateway) will spew out a bunch of mock data that changes things on the screen. This is called demo mode.
FiX-GW is where the demo data (and whatever other type of data) comes from. To turn off demo mode, you need to edit a config file.
$ nano makerplane/fixgw/config/preferences.yaml.custom
Copy/Paste this text into the file (note that it must look EXACTLY like this - spaces matter in YAML files, so there are two spaces in front of each of the third through sixth lines and NO spaces before the first two lines):
# This section is used to turn things on or off
enabled:
AUTO_START: true
CANFIX: true
QUORUM: false
DEMO: false
The AUTO_START: true line tells fixgw to start automatically when the RPi restarts. The CANFIX: true line tell fixgw to listen to CANFIX messages. I'm not 100% sure what the QUORUM: false line does. DEMO: false is turning off the default demo mode.
Next, you'll need to edit the CAN connection configuration for fixgw.
$ cd
$ nano ~/makerplane/fixgw/config/connections/canfix.yaml
About line #7 it says:
channel: vcan0
Change that setting to use can0 instead of vcan0.
channel: can0
Remember ... spaces matter in yaml files, so make sure the same number of spaces (2) precede that line!
Press Ctrl+x, y, Enter to save your changes. Then reboot and you should be good to go.
$ sudo reboot