Tracker

Our tracker can capture information about its surroundings, for example GPS coordinates, altitude, temperature and so fourth. This guide will walk you through how to setup a Raspberry Pi tracker, identical to the one that we are using. We will start from a basic tracker and work our way up so that this guide will be helpful to you even if you only wish to build a tracker with reduced functionality.

 

The full list of parts:

1)      Raspberry Pi Model A+ (For the actual flight since it consumes less power and is lighter when compared to other models)

2)      Raspberry Pi 40 pin stacker header X2 (i.e the headers with the extra long 9.7mm pins)

3)      Pi In the Sky kit (http://www.pi-in-the-sky.com/)

4)      LoRa module (whichever configuration you like and whichever frequency you prefer) (https://store.uputronics.com/index.php?route=product/product&product_id=68&search=lora)

5)      434MHz stubby antenna for the Pi In the Sky (PITS) (recommended but not compulsory since the kit comes with a pigtail but that is not as good)

6)      Any necessary stubby antennae for the LoRa module (make sure they are for the right frequency(s) that your LoRa supports)

7)      Raspberry Pi Camera

8)      TSL2561 Light Sensor

9)      MPL3115A2 Altimeter/Barometer/Thermometer

10)   LSM303DLHC Accelerometer/Compass/Magnetometer/Thermometer

11)   Any 5V, 2A micro-USB charger (or the official Pi charger)

12)   Energizer Lithium AA Batteries X4 (or other AA lithium batteries. DO NOT use standard alkaline batteries as they are likely to fail at high altitudes due to low temperature)

13)   Any 40 Pin GPIO breakout which allow connections to breadboards(we recommend the Adafruit T-Cobbler Plus or similar)

14)   Breadboards to affix sensors to (we recommend solderless breadboards for testing and normal breadboards for flight to ensure all components are secure with solder)

15)   Relevant solid-core wires to wire up breakout to sensors x12 minimum

16)   Micro SD card (we recommend large ones such as 32GB and above as well as Class 10 cards)

17)   Micro SD card reader/adapter (optional if your computer has one built in)

18)   Small OLED display (LCD ones will malfunction at low temperatures so don’t get those)

You will also need a computer, monitor with HDMI port, HDMI cable and keyboard. What follows are 2 different options. Either get 19 and 20 (recommended) or 21 and 22

19)   Raspberry Pi Model B+ (or similar with Ethernet capabilities, 4 USB ports and 40 GPIO pins such as the newer V2 and V3) (OPTIONAL but will make your life easier)

20)   Ethernet cable

21)   Powered USB hub (at least 4 ports and a MUST to be powered or you will run into problems)

22)   USB 2.0/3.0 WiFi dongle

 

Basic Tracker

To start with, let’s build a basic tracker. You will need:

1)      Micro SD card (we recommend large ones such as 32GB and above as well as Class 10 cards)

2)      Micro SD card reader/adapter (optional if your computer has one built in)

3)      Any 5V, 2A micro-USB charger (or the official Pi charger)

4)      434MHz stubby antenna for the Pi In the Sky (PITS) (recommended but not compulsory since the kit comes with a pigtail but that is not as good)

5)      Raspberry Pi 40 pin stacker header X1 (i.e the headers with the extra long 9.7mm pins)

6)      Pi In the Sky kit (http://www.pi-in-the-sky.com/)

7)      Raspberry Pi Camera (optional if you do not wish to take pictures)

AND

1)      Raspberry Pi Model B+ (or similar with Ethernet capabilities, 4 USB ports and 40 GPIO pins such as the newer V2 and V3) (OPTIONAL but will make your life easier)

2)      Ethernet cable

OR

3)      Raspberry Pi Model A+ (For the actual flight since it consumes less power

4)      Powered USB hub (at least 4 ports and a MUST to be powered or you will run into problems)

5)      USB 2.0/3.0 WiFi dongle

 

Step 1) We will want to get Raspbian Lite on the Raspberry Pi. The reason for this being that the Lite version takes up way less space than regular Raspbian. As of the time of writing, our tracker is tested to run with the Raspbian version called Jessie Lite.

The guide for getting Jessie Lite on your SD card can be found here (choose the option for the OS you have): https://www.raspberrypi.org/documentation/installation/installing-images/README.md

The download page for Jessie Lite can be found here: https://www.raspberrypi.org/downloads/raspbian/

 

Step 2) Once you have done that, insert the SD card into your Pi (the B+ if you have gone for that option, A+ otherwise). Go to step 2a if you have the B+ and 2b if you haven’t.

Step 2a) If you have the B+:

Connect the Ethernet cable, keyboard and HDMI cable to Pi before plugging in charger. Pi should boot into terminal immediately. If not, format the SD card and do the previous step again

The default login details for the Pi are:

Login: pi

Password: raspberry

The Pi should be automatically connected to your network. Test this with ifconfig and check that you are indeed receiving and sending packets with no errors on your Ethernet port. If this is not the case, reboot the pi with sudo reboot. If you still experience issues, use your computer and configure your router to turn on DHCP. The steps for this are specific to every router but in general it involves finding out the IP address of your router (with ipconfig/all on windows terminal for example) and entering that IP address into a web browser’s URL bar. Log on if required and look around for the setting to turn on DHCP.

If you are using a corporate network then do contact your IT team for any specific steps you may require to connect to it.

Step 2b) If you are using the A+

Connect the keyboard and WiFi dongle to the USB hub. Connect USB hub, HDMI cable to Pi before plugging in charger. Pi should boot into terminal immediately. If not, format the SD card and do the previous step again.

The default login details for the Pi are:

Login: pi

Password: raspberry

To setup WiFi on Pi : https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

With a home network or a mobile hotspot, these methods are generally enough to get you connected. Test your connection with ifconfig and check that you are indeed receiving and sending packets with no errors. If not, reboot the Pi with sudo reboot.

If you still have problems try this : http://www.howtogeek.com/167425/how-to-setup-wi-fi-on-your-raspberry-pi-via-the-command-line/

Or this: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/setting-up-wifi-with-occidentalis

If you are running on a corporate network, then do contact your IT team for any specific steps you may require to connect to it.

If you are an Imperial student and wish to connect to Imperial-WPA, then do contact the IT helpdesk for steps on how to set up a connection on the Pi because Imperial-WPA requires some very special settings.

 

Step 3) Install the Raspberry Pi camera. Skip this if you do not wish to have a camera on your tracker.

https://www.raspberrypi.org/documentation/usage/camera/README.md

 

Step 4) Once your internet connection is up and running, install Pi In the Sky (PITS) software using this guide: http://www.pi-in-the-sky.com/index.php?id=sd-card-image-from-scratch

Physical assembly of PITS: http://www.pi-in-the-sky.com/index.php?id=physical-assembly

Do note a few discrepancies however, in that when installing the PITS board, use the stacker headers instead of the ones provided in the PITS kit if you wish to add extra sensors and/or LoRa board. If not, just use the standard ones provided.

 If you are installing a camera, ensure that the camera is threaded through the PITS board and securely fastened on the Raspberry Pi before securing the PITS board with the provided screws.

If that one doesn’t work, here’s an older version of the guide which we used and found to work anyway: http://www.pi-in-the-sky.com/data/uploads/pits-manual.pdf

To configure the settings for your PITS, enter sudo nano /boot/pisky.txt in the Raspberry Pi terminal. What you will want to change is the payload name to something unique to yourself. This allows you and anyone else tracking your balloon to easily identify it. You may wish to change the frequency to a range between 434.000MHz and 435.000MHz. Ensure that Camera=Y if you’re using the Pi camera.

 

Step 5) (Optional and just to make sure your Pi is sending sensible data)

Refer to our excellent guide on how to setup your computer to receive RTTY transmissions from the Pi.

You may also wish to see it on your terminal, as the self-bootup of the tracker does not print any results to the screen. To do so, run the following commands:

sudo cd ~/pits/tracker (navigate to the appropriate folder)

sudo killall tracker (kills the tracker)

sudo ./tracker (runs the tracker but now you can see what it is doing on screen)

If the tracker is working, what you should see are messages beginning with RTTY: *yourpayloadname* and a long string of numbers. The format of the numbers are:

Message number, timestamp, latitude, longitude, altitude, battery voltage, temperature from external sensor (which we do not have), temperature from another external sensor (again, do not have), checksum

 

At this point, we have completed the basic tracker! If this is all you wish to build, skip ahead to our launch notes section to prepare your tracker for the actual launch.

 

LoRa add-on

We can now proceed to build a tracker with LoRa on it. If you wish to build a Pi without LoRa but with the extra sensors, you may skip the next bit and ignore all steps associated with LoRa.

You will need (in addition to what we already used previously):

1)      LoRa module

2)      Raspberry Pi 40 pin stacker header X1

3)      Any necessary stubby antennas for the LoRa module

 

In the latest version (as of 30th May 2016), the LoRa software comes with the PITS software that you have previously installed, so please ignore any instructions for installing LoRa software that you may find on http://www.pi-in-the-sky.com/index.php?id=making-a-lora-tracker

 

Step 6) Before attaching the LoRa set, go to sudo nano /boot/pisky.txt and uncomment all the relevant LoRa lines:

#LORA_Frequency_0=434.450

#LORA_Payload_0=CHANGEME

#LORA_Mode_0=0

#LORA_low_width_0=640

#LORA_low_height_0=480

#LORA_high_width_0=1280

#LORA_high_height_0=960

#LORA_image_period_0=30

LORA_image_packets_0=20

 

If you have bought a LoRa board with 2 modules, go ahead and uncomment:

#LORA_Frequency_1=434.450

#LORA_Payload_1=CHANGEME

#LORA_Mode_1=1

 

Change the LoRa payload(s) to ones which are distinct from each other and the normal RTTY payload. Change the frequencies to ones which match the modules you bought. If you bought it from the store we linked in the items list, then a chip with the label RF96 corresponds to 868MHz and RF98 corresponds to 434MHz.

If you are using a camera, set the lora modes to 1. If not, set it to 0. Leave everything else unchanged.

Shutdown the Pi with the command sudo shutdown –h now. Once the screen goes blank, unplug the charger, HDMI cable and all USB devices before installing the LoRa board.

Physical installation of the LoRa board is similar to that of the PITS board (see Step 4), and as before, use stacker headers instead of the regular ones if you wish to add extra sensors to the tracker. If not, use the regular ones which came with the PITS kit.

Reconnect everything you unplugged (with the charger being plugged in last). To ensure that your tracker is working, do the same thing as you did for the tracker:

sudo cd ~/pits/tracker (navigate to the appropriate folder)

sudo killall tracker (kills the tracker)

sudo ./tracker (runs the tracker but now you can see what it is doing on screen)

In addition to RTTY messages, you should now be seeing LoRa messages with your LoRa payload(s) name on them.

If it doesn’t work and you are running 2 LoRa modules, disable one of them and reboot. Ensure that your frequencies are set correctly for the corresponding modules. The LoRa modules can be temperamental when settings are changed and usually a simple reboot will solve the problem. If it still does not work, disable RTTY in pisky.txt by setting disable_RTTY=Y and reboot.

We now have a working tracker that transmits via LoRa!

 

Sensors add-on

We can now proceed to add on our sensors. The idea is that these sensors will be interfaced via a single script that we can execute via terminal. The script will write to a text file which can then be read by the tracker script (with a few minor modifications). This is the simplest way to get external sensor data and send it through our tracker. An alternative method is to interface all of them in C and modify the tracker C files to do this. This is more complex but has the extra benefit of having more control over what the tracker is doing at any one time as well as eliminating any possible read/write clashes (although we have not run into any with the first method and neither has the creator of PITS).

The easiest way of interfacing external sensors is via the I2C bus rather than serial. To do this, we require the 40 pin GPIO breakout which we connect to the 40 male pin on the Raspberry Pi (or the stacker headers on top of the PITS/LoRa board). The following tutorials are specific to each sensor model, so skip any one which you will not be using.

Step 7) Since we are using the I2C bus for all sensors, do the following first (ensure that you have an internet connection) (taken from: http://ciaduck.blogspot.co.uk/2014/12/mpl3115a2-sensor-with-raspberry-pi.html):

sudo apt-get install python-smbus

sudo apt-get install i2c-tools

Enable the modules by adding them to /etc/modules

sudo nano /etc/modules

and add the following two lines:

i2c-bcm2708

i2c-dev

Remove the modules from the blacklist by commenting them out "add # to the front"

sudo nano /etc/modprobe.d/raspi-blacklist.conf

Make sure the spi and i2c lines are commented out:

#blacklist spi-bcm2708
#blacklist i2c-bcm2708

If these lines do not exist, then ignore this step and close the file with ctrl+Z

 

For all our sensors, the wirings are identical:

(From Pi breakout to chip)

3V3 (3.3V) to Vin

GND to GND

SDA to SDA

SCL to SCL

 

Light Sensor TSL2561

Using a computer, get the libraries here: https://github.com/sim0nx/tsl2561 and store them to a USB drive in a folder (with no spaces or special characters excluding – and _ in the folder name). You will also require the Adafruit_I2C.py library from: https://github.com/strahlex/halanduino/tree/master/libraries/Accelerometer

Alternatively, if you are using Linux, store them directly to the SD card with Raspbian on it via an SD card on it. The directory you will want is /home/pi. Within this, create your own folder.

If you are not using Linux, to mount the USB drive and copy it to a directory on the Pi:

Create a directory in your main directory using:

cd

mkdir nameofyourdirectory

Mount USB:

sudo mkdir /mnt/usb

sudo mount /dev/sda1 /mnt/usb

If the 2nd line doesn’t work, look for your USB device using ls -l /dev/disk/by-uuid/ and replace sda1 with the id of your device (ignore anything with labels beginning with mmcblk; those are usually your SD card)

Once mounted, go to your USB drive:

cd /mnt/usb

Copy folder to Raspberry Pi:

cp –avr usbfoldername /home/pi/nameofyourdirectory

 

Accelerometer/Compass/Thermometer/Magnetometer LSM303DLHC

On your computer, get the library here: https://github.com/strahlex/halanduino/tree/master/libraries/Accelerometer

Follow the instructions outlined in the Light sensor portion to get the code onto the Pi.

 

Altimeter/Barometer/Thermometer MPL3115A2

On your computer, get the library here: https://gist.github.com/pepijndevos/c3646ef6652e0f0342dd

And the test code here (copy and paste code to a .py file):

http://ciaduck.blogspot.co.uk/2014/12/mpl3115a2-sensor-with-raspberry-pi.html

Follow the instructions outlined in the Light sensor portion to get the code onto the Pi.

Note that this particular sensor has an odd quirk. If the Raspberry Pi has been reboot since it was last used or if the sensor is being used for the first time, the user must do the following before running any script to obtain sensor data:

sudo su -
echo -n 1 > /sys/module/i2c_bcm2708/parameters/combined
exit

We have tried to place that into a script that runs on login, however the system was not happy as the echo command requires root access.

 

For all sensors

Preferably, all sensor files should be placed in the same folder once they have all been tested individually. At this stage, you should try to incorporate all sensors into 1 single Python file. We will be including a sample Python2.7 file soon. 

To have the tracker send the sensor data which is stored in the CSV file, there needs to be minor modifications performed on the tracker C code. We will be providing the C code that we have written once we upload it to Github, so stay tuned for that.

 

Preparation for launch

If you are running the basic tracker or the LoRa tracker, then simply connect all the necessary antennae and then connect the battery pack last. The PITS kit should have come with the necessary battery adapter. Simply insert 4 fresh AA lithium batteries into the adapter and connect it. The Pi and PITS should automatically boot with all your configured files and you should see the LEDs on the Pi immediately turn on and the on the PITS after about 10 seconds. To conserve battery, it is recommended you power the tracker on only right before you seal the payload up.

If you are running sensors, then you will wish to set up the Pi with an AC adapter, monitor and keyboard first. Login and run the necessary Python script (or any other format script that you may have chosen to use instead). Make sure you DO NOT kill the tracker whilst getting the Python script to run. After ensuring that everything runs, connect the battery pack that came with the PITS kit. Ensure that the battery pack has 4 fresh AA lithium batteries. Following that, disconnect the AC adapter and check that everything is still running properly on the monitor. Disconnect the monitor and keyboard. The tracker is now ready to be sealed into the payload.

 

Still to come: OLED tutorial and Github code

I will get on the OLED tutorial once it arrives and we have figured out how to make it work reliably. The Github code should be up by this weekend and then I'll write a proper conclusion for the sensors portion. Until then, readers who are apt with Python can figure out how to write a script that will write to a CSV file which is what the tracker will accept.

 I will also endeavour to get pictures on the launch day so you guys can see our final setup!

 

- Wei