STM32 OGN Tracker

Prototypes are being tested: run on single 18650 Li-Ion cell, fit in a 100x60x25mm box.

Mini-Tracker.jpg Mini-Tracker-inside.jpg dyi-ogn-trackers.jpg

The design proposed here should be taken with flexibility and by no mean it should be considered a fixed design. For example almost any GPS module can work here. The only requirement is that it can be powered from the lithium battery and provides standard NMEA sentences on the TTL serial port. PPS signal is desired but probably with small software modifications it could work without it. External (onboard) aircraft GPS could be used as well.

The box, the battery, the antenna, the charging circuit, etc. are all elements which can be replaced by whatever is locally available. Most likely other CPU's from the STM32 family are able to run the software and steer the hardware.

List of core elements

The core elements required to construct DYI OGN tracker are:

element type where to buy it comments
main CPU STM32F103C8T6 development board e.g. vcc-gnd.taobao.com ebay aliexpress this STM32 board has low-drop voltage regulator and can run from a Li-Ion cell or USB 5V power. At 3V it still runs, at 2.7V the VK16u6 GPS gives up.
RF transceiver RFM69W or RFM69HW e.g. HOPERF ebay aliexpress make sure to get the 868MHz version, worth getting several on aliexpress with free shipping
SMA-female socket with pigtail SMA female socket e.g. aliexpress this one has a very hard coax, you might find a softer one. Beware of existence or reverse-polarity SMA (RP-SMA very popular and used for 2.4GHz wireless networks) - if you decide to go for reverse-polarity match your antenna to have the right connector too.
antenna with SMA-male connector SMA male plug e.g. ebay aliexpress any 1/4 wave or dipol (better but longer !) for 868MHz or 900MHz should do. Beware of reverse polarity SMA - see above. If you use 1/4 wave it is worth to install the correct counter-weight inside the tracker box made of e.g. a strip of copper foil
GPS VK16u6 e.g. from ebay aliexpress any GPS with TTL UART and PPS output should do, for example VK2828U7G5LF appears as good and takes less power
battery 18650 Li-Ion cell e.g. aliexpress or take apart an old laptop battery pack any other Li-Ion battery will do or run it off USB power. Beware of several fake offers for 18650 cells on the on-line sites: they claim capacity up to 10000mAh but don't often reach 100mAh. If you get a 2200mAh or 2600mAh battery it should last more than 20 hours as the tracker takes at most 90mAh.
battery holder for 18650 cell e.g. aliexpress you don't need it if you get a battery with soldering leads
charging circuit for single cell e.g. ebay or better ebay if you can get the one with undervoltage protection
plastic project box (black) 100x60x25mm e.g. this one or from ebay if you run it off external supply the box can be smaller
2 ferrite cores T50-26 13 x 7 x 5mm e.g. aliexpress not sure this is the best, any EMI core should do
1 LED diode blue, 5mm blue LEDs seem to take least current. one needs also 470ohm resistor in series
buzzer/speaker e.g. ebay this one is rather soft, thus you may find a louder one
1 ON/OFF switch Mini toggle SPDT e.g. ebay or any other switch that fits
adhesive copper foil tape e.g. ebay used to create antenna counter-weight inside the tracker box

All these can be purchased on e-bay or other online sites for total of $25

Note for the RF modules: RFM69W can go up to +13dBm, while RFM69HW up to +20dBm transmit power. The price difference being unimportant, it is probably better to stay with the RFM69HW as a preferred option. At this time they can not be auto-detected by the software and need slightly different programming, thus the choice is remembered in the Flash. Current software works with both RFM69W and RFM69HW with manual first-time-flash selection needed.

Auxiliary parts: not part of the tracker itself but very useful for programming, testing and development

part type where to buy it comments
ST-Link V2 - e.g. ebay optional for quick STM32 programming, but can be done without through the serial port. Beware, that there are several variants of ST-Link available and they look the same but have different pinout (!) thus don't simply copy the wiring from another model, but check the pin description on the device. Beware of 3.3V and 5V issue - always choose 3.3V, never 5V !
USB-TTL UART CP2102, FT232 e.g. ebay optional for programming the STM32, talking to the tracker on the console port, test the GPS. Avoid the PL2303: the Windows driver is very unstable, although it works fine with Linux
Logic analyzer - e.g. ebay for experts: debugging, watching the timing
Jumper wire e.g. ebay for quick test wiring. ST-Link and USB-UART may have this included, but if not, you are going to need this

I recommend getting both the ST-Link programmer and the USB-UART. Especially if you are a programmer, the cycle: change the code, reload, see the effect is much quicker when you work with the ST-Link. Otherwise you need to start/stop the serial terminal, switch the jumpers for every cycle.

STM32F103C8T6_RFM69W_VK16U6.jpg Box_Battery_Antena_etc.jpg old-thinkpad-t42-bat-pack.jpg

Left: Core tracker element: STM32F103C8T6 CPU, RFM69W radio transceiver and VK16U6 GPS
Center: remaining elements: plastic box, battery with its holder, SMA socket, antenna, power switch, etc.
Right: old recycled laptop battery (in this example 9-cell, taken from an old Thinkpad T42)

Assembly instruction

Word of caution: keep in mind that this is mostly 3.3V electronics and some elements may not tolerate 5V.
In particular the RF module is specified for max. 3.6V thus be careful not to accidentally connect 5V from the USB-UART, logic analyzer or 4V from the battery. The RF module is supplied through the STM32 board low-drop voltage regulator. Only apply 4 or 5V to the 5V input on the STM32 board.

Initial test

To make sure your parts are working, you can quickly test them.

GPS: connect it to the USB-UART, then observe what comes out with PUTTY, GPS port is 9600bps by default.
Even simpler GPS test: apply power (red and black wire) and expose the GPS to (a piece of) open sky - after a minute or two the green LED starts blinking (PPS)

STM32 CPU: power it up through its USB and then red LED should come up, while blue LED starts blinking slowly.

1. Wire the RF69(H)W radio transceiver to the STM32 CPU

Wire the RF module, use short pieces of cables to connect to STM32:

STM32 pin RFM69(H)W pin function signal direction
3.3V 3.3V power LDO -> RF chip
G GND common ground
A4 NSS SPI select CPU -> RF chip
A5 SCK SPI clock CPU -> RF chip
A6 MISO SPI MISO RF chip -> CPU
A7 MOSI SPI MOSI CPU-> RF chip
B5 RESET chip reset CPU -> RF chip
B4 DIO0 interrupt request RF chip -> CPU
B3 DIO4 aux. status RF chip -> CPU
RF-wiring-cables.JPG
Preparation of the cables
RF_wiring.png CPU_RF.jpg CPU_RF_joined.jpg

Left: Wiring diagram for the RF module
Center: CPU board and RF module just before wiring them together
Right: RF module wired to the CPU board

RF-wiring-cables2.JPG
Assembly and soldering

Possibly the most difficult part, because of the fine pitch of the RF module. Use short wires and fine soldering iron. STM32 and RFM69(H)W pins are clearly marked on each board.

2. Prepare the box

  • Drill the holes for the power switch, LED and antenna SMA connector.
  • Cut the hole for the USB charger connector.
  • Make the antenna counter-weight from a band of copper foil.
  • Wire the charger board to the power switch, make battery wires ready
  • Glue the GPS and the charger board with fast epoxy or with Hot melt adhesive(HMA), put a ferrite core onto the GPS cables.
  • Attach the SMA socket, put a ferrite core onto the coax
Box_RFgnd.jpg Box_equipped.jpg LED_with_resistor.JPG

Left: Box with holes drilled and the antenna counter-weight (copper foil)
Center: Box with GPS and charger board glued, SMA connector, power switch and status LED installed
Right: LED with the soldered resistor

3. Wire the GPS with the STM32 CPU

Wire the GPS to the CPU+RF according to the following list:

STM32 pin GPS wire Function Comments
5V red VCC - power for the GPS Battery connects here too
G black GND - common ground
A3 blue RxD - serial data GPS -> CPU
A2 green TxD - serial data: CPU -> GPS
A1 white PPS - timing pulse: GPS -> CPU
A0 yellow enable/shutdown the GPS (to save power) not used at this time
GPS_wiring.png GPS_wired.jpg

Left: GPS wiring points (RF module not shown for clarity): colors correspond to VK16U6 GPS module standard wires
Right: wired GPS connections

At this point, when you flash in the OGN code you should see the blue LED send short flashes - this means GPS is sending valid NMEA sentences - this is good indication CPU and GPS works. Once the GPS acquires lock there will be two longer flashes every second (one longer flash for PPS and other for GPS lock). Green light on the GPS will blink - this is the PPS.

If you watch the console output, at startup the tracker sends out the RF chip version - if it is 0x27 then you are in business - good indication the SPI and power to the RF chip is wired correctly.

4. Wire battery, power switch, LED

Other_wiring.png

Remaining wires to be connected to the STM32 CPU. Just the battery or other supply is essential, the rest is optional

You can supply the system through the USB connector (on the bottom on the above picture) - then you don't even need a battery and the containing box can be much smaller. With enough programming knowledge you can likely program the CPU tu emulate a serial port on this USB connector.

The pins of the STM32 CPU board are listed on to of the main.cpp file - please consult this description for crosscheck and when you have doubts what the functions of the pins are.

5. Wire the SMA connector with pigtail

Connect the pigtail of the SMA connector to the GND (screen) and ANT (center conductor) of the RF module.

Software for DIY tracker

Once hardware is created, you will need to install OGN DYI tracker firmware on it.

The DYI tracker's firmware source code is available in our GIT repository. The binary version (ready for uploading to the tracker's chip) will be available in the downloads section shortly.

Binary can be uploaded through the serial port (you need to play a bit with the yellow jumpers) or quicker with the ST-Link v2 programmer/debugger.
To compile the software: GNU ARM GCC compiler
To download the code with the ST-Link: ST-Link utility software

If you have trouble compiling, here are the .bin or .hex files to download to the STM32:

RF module binary file hex file comment
RFM69W diy-tracker_W.bin diy-tracker_W.hex +13dB tx power
RFM69HW diy-tracker_HW.bin diy-tracker_HW.hex +14dB tx power

Beta release of a major rewrite

New features:

  • read barometric sensor: BMP180 (temperature and pressure)
  • calculate standard pressure altitude, climb rate
  • produce vario sound
  • correlate altiude from GPS with air pressure and produce more precise altitude
  • output as NMEA sentence: temperature, pressure, standard altitude, climb rate, radio noise, positions of other trackers received on radio
  • FatFS implemented onto microSD cards
  • log all NMEA sentences (and whatever else you want) onto an ASCII log file
  • Buzzer driving amplitude twice as high: you need to connect the buzzer between PB8 and PB9 for this to work
  • Ctrl-C on the console prints FreeRTOS task status

To get the source code:

git clone https://github.com/glidernet/diy-tracker

then enter the diy-tracker directory, check options in the makefile and type make.

Additional modules

Bluetooth module

HC-06.jpg

HC-06 bluetooth module (costs $3-4) can be easily connected to the tracker console (STM32 UART1) serial port for wireless access. No change in the code, just configure the Bluetooth module with few simple AT commands !

Configuration

You need to make sure at least for the serial bit rate the device is preset for. You can check it by connecting the bluetooth module to a USB-UART port and typing "AT" on the terminal: simplest one is the PuTTY for Windows or minicom for Linux. If you see the module response "OK" - you are at the right speed, if not you need to find the right speed by trial and error. Try first 9600 and 115200.

When you find the right speed and it is not 115200, then issue the following command:

AT+BAUD8

no need for a return or anything, but take care to type all in uppercase.
Now your bluetooth module is configured for 115200bps on the serial port - same as the console serial port on the STM32

Other useful configuration commands are:

command function
AT+PINxxxx set pin: for pairing with this device
AT+NAMExxx set name to xxx: for identifying this device

Connections

STM32 pin HC-06 pin function
PA10 TXD serial data: Bluetooth -> STM32
PA9 RXD serial data: STM32 -> Bluetooth
G GND common ground
3.3 VCC power supply 3.3V

Usage

Connect to the bluetooth module from your smartphone, tablet or laptop. Default pin is 1234, but can be easily changed by an AT+PINxxxx command. Treat the device as a virtual serial port or like bluetooth GPS (as it already sends the NMEA sentences from the GPS).

Issues

This particular Bluetooth module takes 8 mA when connected to your smartphone but can take as much as 30mA when not connected. It is thus advised no to connect it unless it is really being used. You can either phisically disconnect this module or make a slide switch that disconnects the power when you don't actually want or need to use the bluetooth connection.

More info

Details on the configuration can be found here, here and here

(Micro)SD card slot

microSD.jpg

yes, you can connect an microSD card to the STM32, using the SPI interface. This has been done, and more details is to come soon. Software exists already to read and write files on the FAT16/32 file system. I used a 2GB microSD, microSDHC should work but has not been tried yet.

Connections

STM32 pin SD adapter pin function
PB14 MISO serial data: STM32 <- SD
PB15 MOSI serial data: STM32 -> SD
PB13 CLK serial clock: STM32 -> SD
PB12 CS select signal: STM32 -> SD
G GND common ground
3.3 VCC power supply 3.3V

BMP180 pressure sensor

BMP180.jpg

is done and reading pressure and temperature works.

Connections

STM32 pin SD adapter pin function
PB7 SDA serial data: STM32 <-> BMP180 10K pull-up to +3.3V
PB6 SCL serial clock: STM32 <-> BMP180 10K pull-up to +3.3V
G GND common ground
3.3 VCC power supply 3.3V

Potentiometer

initially it was meant to control the buzzer volume, but as its position can be read by the CPU, it could be used for any software-controlled function, like setup, mode switching, etc.
At same time it integrates the power switch, thus no extra space is needed in the box.

Tracker-with-knob.jpg

Connection:

The potentiometer is connected to the ADC channel #8, thus PB0.

Usage

at this moment software reads the potentiometer position and produces 4-bit position code, thus it functions as 16-level positional encoder. Histeresis is applied to avoid spurious data and short beep is made with a rising pitch every time the encoder output changes to let the operator get the feel as it turns the knob.

Schematics with the above additional parts

DIY-Tracker-schematics.png DIY-Tracker-PCB.png
DIY-Tracker-PCB-front.jpg DIY-Tracker-PCB-back1.jpg DIY-Tracker-PCB-back2.jpg
and a very simple PCB which helps to assemble all the parts.

Room to expand

additional hardware on board

The DIY is not closed in the sense it can be expanded with more hardware. Pressure and inertial sensors are one of the natural choices. There is no software for it but it can all be done by the community. One particular item is combined pressure, accelerometer, gyroscope and magnetic compass, can be bought on aliexpress. What if we make a barometric vario compensated and expanded with inertial sensors ? We all know that thermals can be sensed by our "bottom", right ? What if we make an instrument for exactly this purpose ?

additional features

  • simplified configuration

Currently the "aircraft type" (Glider, Paraglider, Plane…) is set in the software, so changing it requires the tracker to be connected to the PC, the updated firmware must be recompiled and re-uploaded to the device.
Since tracker is portable, this should be much easier - user should be able to set the type, using one or two buttons/switches on the tracker itself.
The type set (0..15) could be confirmed e.g. by the beeper and be allowed to be set on the ground only (velocity=0) ?

However! One can already set the associated type in the OGN ddb - this one overwrites the type sent in the OGN tracker's packets, so changing the display type in live.glidernet is possible without having to do any "complicated" tracker's software update.

  • e-vario (with beeper and volume regulator) - that would be very useful for para-glider pilots ?
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License