Precise, concise installation instructions

I ended up doing a complete reinstall from scratch to upgrade Zoe to my new Pi-Zero-W, so here’s my latest set of installation instructions.  I recommend printing these off so you can refer to them easily as you do the installation.

These work for any version of Raspberry Pi running the latest Raspian Jessie Lite.

I can confirm that the Pi-Zero-W inbuilt WiFi does support WAP / soft-AP.

Annoyingly, I messed up soldering the GPIO connection onto the Pi-Zero-W, so I have another one on the way.

Hermione’s and Zoe’s powerware

All of Hermione and Zoes’ powerware – battery, ESCs, motors and props come from a single supplier: Paul Maddock who runs based in Chester, UK where I used to live until 2010.  Over the years, he’s provided a great service, including a couple of specials for me, and so is definitely worth a mention.

Here’s the list of Hermione’s parts I have from him:

This is probably the best set of powerware possible, to match Hermione’s best frame possible.

I also got Zoe’s powerware and frame from there too, though annoyingly, her motors are no longer available:

Once more, THBAPSA.

Hermione’s frame

If you want a super strong X8 compatible frame that’s large enough for every possible sensor, there’s only one out there that fits the bill.  And it fits it well, and then some.  It’s designed and hand-made in Poland at by Jakub Jewula.

Hermione's frame

Hermione’s frame

The frame is carbon fiber throughout.  The arms are hinged to allow them to fold for transport, but lock into place amazingly sturdily for flight.  The kit comes complete with a simple but well designed power distribution tower, outer-plates for 5V power, WiFi and GPS as shown (or whatever you want to add) and various shelves for flight controllers, LiPo’s etc.  I love the way all the wiring for motors, power, GPS and WiFi can be fed down their tubes to protect them from blades during flight.

The standard legs aren’t strong enough for some of the catastrophic falls Hermione has had during her development, so I use these instead.

Hermione's closeup

Hermione’s closeup

I have a few bits of build advice:

  • Don’t be scared to tighten the bolts as hard as possible for brackets attached to the CF tubes
  • Don’t bother with the bolt to join the CF arm to the shoulder socket joint, just use epoxy resin glue; it gives a better distributed, stronger connection, and hence significantly reduces the chance of damage on impacts by ensuring forces are passed through to the frame itself.
  • Apply a little grease to the shoulder joints so they can’t lock up if you over-tighten them.
  • Wrap some duct-tape at the ends of each arm where the motor bracket joins to prevent hard side impact pushing the motors down the arms.
  • Add these foam rubber balls to the end of the legs to try to absorb some of any impact landings.
  • If you want a cover, this salad bowl is a perfect fit, shown in a previous revision of her frame build:

    Salad bowl

    Salad bowl


Note that I was not paid for this advert and I paid full price for the frame.  I’ve written this post because the frame is simply the best DIY fold-able CF X8 frame available, period.

UnWAPping Hermione

Occasionally, Hermione needs new software installed or updated.   In this case, it’s the GPS code.  To install that, she needs internet access to be reinstated.  Here’s how:

  1. in /etc/hosts, remove the .local trailer to hermione, so she joins the home network.
  2. in /etc/hostname, remove the .local trailer from hermione again
  3. in /etc/network/interface, comment out the static IP config for wlan0 and swap back to the wpa_supplicant variant so it looks like this:
    # auto wlan0
    # iface wlan0 inet static
    # address
    # netmask
    allow-hotplug wlan0
    iface wlan0 inet manual
        wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    iface default inet dhcp
  4. in /etc/default/udhcpd, uncomment “DHCP_ENABLED=”no”
  5. in /etc/default/hostapd, comment out “DAEMON_CONF=”/etc/hostapd/hostapd.conf”

A reboot then should give access to the internet for updates etc.


Raspian Jessie Lite installation instructions

Here’s the installation steps I took to install Hermione from scratch today. February 2017 Jessie Lite image is the last that works due to I2C enhancements which the Garmin LiDAR-Lite V3 do not support

The latest up to date installation instructions are now here on GitHub.

Everything below is left in case someone references it but is not maintained.  Instead use the links above.

  • Use Etcher to write the SD card with the latest Raspian Jessie Lite image
  • In windows in the root directory of the SD card, create an SSH file to enable it
    echo hello > ssh
  • Boot up your RPi with SD card, keyboard, mouse, monitor and WAP / soft AP supporting WiFi dongle installed (no WiFi dongle needed for 3B and Zero-W)
  • raspi-config to set hostname, GPU memory (128MB), enable I2C, overclock to 1GHz, disable overscan, disable serial UART, enable camera support and SSH server. Do this incrementally to make sure each change takes effect in /boot/config.txt
  • Set up a WiFi internet connection from the CLI as per
  • sudo apt-get update
  • sudo apt-get dist-upgrade
  • sudo apt-get install i2c-tools python-smbus python-dev python-setuptools python-picamera python-gps python-serial git ftp udhcpd hostapd serial minimalmodbus
  • edit /boot/config.txt adding
  • while in /boot/config.txt, disable pointless functions thus
  • If you are using a Pi3 or Zero-W, you may want to disable Bluetooth in /etc/modprobe.d/raspi-blacklist.conf thus:
    # WiFi
    # blacklist brcmfmac
    # blacklist brcmutil
    # Bluetooth
    blacklist btbcm
    blacklist hci_uart

    Likewise if you’re using an WiFi USB dongle, you can disable the internal one by removing the ‘#’s for that pair of lines.

  • If you are using a B2 V1.2, it can be overclocked to 1.2GHz thus in /boot/config.txt
  • If you are using USB GPS and / or Scanse Sweep, it’s worth linking the USB tty to a unique name for each. In /etc/udev/rules.d add a file such as ’99-usb-serial.rules containing something like this:
    SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", ATTRS{serial}=="DO004VY5", SYMLINK+="ttySWEEP"
    SUBSYSTEM=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", SYMLINK+="ttyGPS"

    The details of what to fill in come from /var/log/messages as a USB UART is plugged in. Also /etc/default/gpsd and to reference these tty* names instead of ttyUSB*

  • git clone
  • cd minimalmodbus
  • sudo python ./setup install
  • cd ~
  • git clone -b v2
  • cd RPIO
  • check mailbox.c code present in source/c_pwm/mailbox.c)
  • sudo python ./ install
  • cd ~
  • git clone
  • cp Quadcopter/ .
  • cp Quadcopter/fp.csv .
  • cp Quadcopter/ .
  • sudo python ./
    • –tc 1 -h 1150
    • -f fp.csv

Finally, to make her a WAP:

  • Disable the new style network tools:
    sudo apt-get remove dhcpcd5 raspberrypi-net-mods
  • Configure hostapd by creating /etc/hostapd/hostapd.conf “sudo vi /etc/hostapd/hostapd.conf” and add the following:
  • Enable hostapd by editing /etc/default/hostapd thus, adding
  • We next need to configure dhcp for the clients accessing the network to provide their IP addresses – edit /etc/udhcpd.conf adding:
    start # This is the range of IPs that the hostspot will give to client devices.
    interface wlan0 # The device uDHCP listens on.
    opt domain local
    # opt dns # The DNS servers client devices will use.
    opt subnet
    opt router # The Pi's IP address on wlan0 which we have set up.
    opt lease 864000 # 10 day DHCP lease time in seconds
  • Enable dhcp by editing /etc/default/udhcpd thus to comment out the line
  • Now to configure the WAP static IP address – “sudo vi /etc/network/interfaces”, adding the static IP address for wlan0 and commenting out anything related to the dynamic address.
    auto wlan0
    iface wlan0 inet static
    #allow-hotplug wlan0
    #iface wlan0 inet manual
    #    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    #iface default inet dhcp
  • Edit /etc/hostname to ensure the domain name is included – in my case, the domain is called local, and the hostname is wappi, so /etc/hosts reads
  • Next assign static IP address for the server in /etc/hosts wappi.local wappi.local wappi
  • Check, double check, and triple check that you’ve done all the above steps, and then finally
     sudo reboot


sudo reboot

* All crossed out instructions relate to LEDDAR installation requirements which I’m not going to continue to support.

Random bits and bobs

Cotswold Jam and Cambridge Robot Wars

Unless I manage to break Phoebe before December, I intend to take her to the Cotswold Jam in September (where I’m one of the founders / organisers) and the Cambridge PiWars in December.

The code I’ll be running there will most like what I uploaded to GitHub yesterday.

Until then?

Over the next couple of months, I’ll probably just enjoy flying Phoebe and Chloe, and perhaps treat them to some new batteries – primarily so the colours match the rest of their frames!

I might add an angular (rather than motion) control version so I can show the difference in behaviours at the Jams.

Otherwise I’ll try to keep my tinkering to PID tuning unless the A2 appears leaving me enough spare CPU’s to play more with threading (, Kitty and Kitty++.

What I won’t be doing

I won’t be adding a human into the feedback loop – no remote control – sorry to those of you who have nagged me to do this.

I also won’t be blogging as much as I’ll have less to blog about, other than flight videos.  Also it’s clear from the blog stats people are starting to get bored…

Blog bandwidth usage

The underlying decline actually started in February but hidden behind the Build Your Own Automomous Quadcopter – Bill of Materials, Assembly and Testing (BYOAQ-BAT) articles in February, and the fact PC World included me in their 10 insanely innovative, incredibly cool Raspberry Pi projects article in March.

Blog bandwidth

Blog bandwidth

So I think for a while it’s TTFN but no doubt I’ll be back.

BYOAQ-BAT X: Test Flight

If you haven’t already, please read the previous BYOAQ-BAT articles first – just search for the BYOAQ-BAT tag.

HoG’s test flight from Andy Baker on Vimeo.

Not the first test flight, but the first I managed to capture on video. Yes, she flew too high, and yes, she drifted towards me, but that was to be expected. The zero-gravity calibration does still shift with temperature, and I’d calibrated at about 20°C, and flown at 10°C, so 10.5mg offset from calibration which equates to 1% error in gravity. She also needs some vertical velocity PID tuning as she’s relying on the integral too much. She also probably needs PID tuning on the pitch rotation rate to help with the drift towards me. And I’d like to experiment with the independent gyro and accelerometer dlpf settings. But regardless, this was at least equal, if not better than anything Phoebe, Chloë or Zoë ever flew.

The exact code for this flight is up on GitHub now.

And that, my friends, is the end of the BYOAQ-BAT articles.  Donations willingly and gratefully received.

BYOAQ-BAT IX: Testing and tuning

If you haven’t already, please read the previous BYOAQ-BAT articles first – just search for the BYOAQ-BAT tag.

Only one very simple test is required before HoG takes to the air.  With your quad on the ground, and motors and HoG powered up, simply type

sudo python ./ --tc 1 -h 200

Each blade props should spin in turn in the order of front left, front right, back left and back right.  The front left and back right props should spin anti- / counter-clockwise, the front right and back left props clockwise.  If the props don’t spin, increase -h slowly (in tens) until they do.  If any of the props spin the wrong way, swap any pair of the three wires driving the ESC.  If each props is rotating in the right direction, check that each prop is producing a down-draft, not an up-draft.  If there’s an up-draft, then swap the props.

For PID tuning, I’m not going into the details of how to do it from scratch, but here are some guidelines of how you can take my PID gains and tweak them to fit your quad.

First, only the inner PIDs which control stability need proper tuning specific to your quad.  The are the pitch, roll and yaw rate PIDs.  The rest are almost certainly fine for any quad.

In the code, look in CheckCLI at the various i_am_phoebe, i_am_chloe, i_am_zoe and i_am_hog settings:

  • cli_hover_target is not strictly necessary – it’s just used to slowly spin up the motors to roughly hover speed before takeoff.  I general have it set to 500 for 12″ props, 550 for 11″ props and 600 for 10″ props.  This value is the size of the PWM pulse width from the HoG to ESCs in microseconds
  • cli_pr*_gain, cli_rr*_gain and cli_yr*_gain vary with length of arms and power of motors, and the weight distribution of the quad.  The ratio of 2:1:0 for P:I:D seems to work well.  Phoebe has short arms and small props, Zoe had larger props, and HoG has long arms and large props – compare the setting for each to see the effect.  In addition, all my batteries face front to back, so it takes more power to pitch rather than roll, hence the difference between cli_pr*_gains and cli_rr*_gains.
  • finally, cli_vv*_gains are for vertical acceleration, but if you compare Phoebe to Zoe and HoG, you’ll see the setting is inconsistent.  Because of gravity, the only real tuning required is “enough” power; hence small props have larger PID values.

BYOAQ-BAT VIII: Calibration

If you haven’t already, please read the previous BYOAQ-BAT articles first – just search for the BYOAQ-BAT tag.

Calibration used to warrant a vast article, needed special equipment and electronics and took at least an hour as HoG had to be separate from her frame.  With the discovery of 0g offsets the other day, calibration is quick, requires only a flat vertical wall and horizontal floor, and assuming your quad frame is sturdy and the PCB is horizontal, the calibration can take place with the HoG in place in her frame.

HoG sits on the most horizontal surface available.  Use a spirit level if possible, otherwise use a hard floor or kitchen worktop (not a wobbly table and not carpet). Run

sudo python ./ -g

Do this a few times, and then look in There are 3 columns representing acceleration in the X, Y, and Z directions respectively. What we’re interesting in are the zero-gravity offsets: with HoG sitting on the floor, with her Z axis aligned with gravity, the values in the first two columns are the X and Y zero-gravity offsets. Change the code to use these values.  Here’s what I got for HoG in her test on the floor after averaging several readings.

 self.ax_offset = 1166.28
 self.ay_offset = 654.5
 self.az_offset = 0.0

Next do the same, but with HoG held against a wall – i.e. a vertical surface where the Z axis is in a 0g environment. Update the offsets above with the Z axis offset:

 self.ax_offset = 1166.28
 self.ay_offset = 654.5
 self.az_offset = -2688.76

That’s it, job done. These values are specific to each IMU – do not use these values for your quad – all hell will break loose!