ESP32 OGN DIY-Tracker


A new series of modules appeared on the market, which are very suitable to make an OGN-Tracker.
The module contains ESP32 chipset and the sx1276 RF chip which is same chip as in the RFM95 RF modules.
You can find the modules by searching for "ESP32" and "sx1276". Most of them contain an 128x64pixel OLED display.

To make a functional OGN tracker it is enough to attach (almost) any GPS, and all the rest is software.
If you can, get a GPS which has a PPS output, this simplifies the exact timing acquisition.


Attractive features of the ESP32 chipset is Bluetooth and WiFi.
It is thus possible to connect the ESP32 Tracker to flight software like XCsoar or LK8000
and do things like automatic log upload after landing.
It is all up to the software, however, up to this date, such software does not exist yet.

Such a tiny tracker can also easily be installed in a drone: just connect the 5V power and the MAVlink port (two wires).
The first tests has been done and the tracker transmits the position of the drone and can alert the drone of the presence of other drones or aircrafts carrying the OGN-Tracker.


There are already few variants of the ESP32 modules suitable for our purpose.
Some of them are under label "HELTEC LoRa 32", some under label "TTGO".
When you get one, make sure you have the 868/915MHz version, not the 433MHz one.

All modules contain the sx1276 RF chip which is same as in the RFM95 modules.

All modules have the charging circuit for a single cell Li-Ion which can be very useful, if the tracker is to be run on its own batteries.

Some TTGO modules are with, some are without the OLED display.

All modules contain Bluetooth and WiFi interfaces.

I found here an interesting comparison between HELTEC and TTGO, which includes some RF measurements.

From my experience: I was surprised to find the reception range of the HELTEC module to be significantly better than the RFM69 or RFM95 modules. This would point to a rather good RF coupling circuit.

The conclusion from all this could be the following: we need to check the range and in particular watch the antennas.


The pinout of TTGO and HELTEC is almost identical: the only difference is the LED on the board: on HELTEC modules it is connected to GPIO25 and on the TTGO to GPIO2.

Several pins are already assigned like the SPI for the RF chip or the I2C for the OLED display. Nethertheless the SPI and I2C can be re-used.


Hardware particularities

All the modules I have seen (or know about) the RF crystal offset by 20 to 40ppm, thus about 20 or 40kHz frequency offset at 868MHz.
This needs correction, which needs to be performed once, and then it is stored in the NVS (Non-Volatile Storage) of the ESP32.
To make the correction by -20kHz send the command to the console:


Ideally, measure the frequency offset with an OGN receiver, it should be less than +/-10kHz.
If you don't have access to the OGN receiver setup the -20kHz correction and once you are in range check the frequency offset
or ask OGN support.

There is one hardware difference I have noticed between HELTEC and TTGO: the LED on the PCB is on GPIO25 (HELTEC) or on GPIO2 (TTGO). The GPIO25 is otherwise DAC2 output, thus on the TTGO it is easier to use the DAC output for sound generation. Nevertheless it is still possible on HELTEC.

GPS module

GPS module should be with TTL UART data interface. There are some (rare) with UART RS232 and I2C, these are not directly supported.
Almost any NMEA GPS should work with the tracker. GPS which understands UBX or MTK commands to switch the serial port baudrate is preferred, as baud rate higher than 9600bps speeds up the position transmission effectively by one second.
When an UBX GPS is being used it is additionally switched to "airborne" navigation mode.

"Enable" control line to the GPS can be useful, although the software does not make yet any use of it.
Features like software power off can then be easily implemented.

GPS module: VK2828U

used in original DIY-Tracker, works fine, only the "enable" control line not clear to work yet.

GPS module: GN-801

this appears to be a good and cheap GNSS receiver, but beware of two particularities:


Here is a TTGO module (this one without OLED display) with GN-801 GPS and a BMP280 pressure sensor.
The enable (white) wire is not connected yet, as the resistor on the GPS module needs to be undone first.


Option for using MAVlink telemetry port instead of a GPS is being tested. This way the tracker can be connected to a drone autopilot which sends telemetry using MAVlink protocol. This feature is now being tested with ArduPilot APM 2.6

ESP32 toolchain

To program the ESP32 chipset you need a software toolchain, which can be installed either on Windows or Linux, including the Raspberry PI.
Official instructions are here.

Note: Toolchain is designed for linux, on Windows you may install e.g. MSYS2 which will give you linux-style programming environment.

Raspberry PI:

sudo apt-get update
sudo apt-get install git wget make libncurses-dev flex bison gperf python python-serial

git clone
git clone --recursive
cd esp-idf
git submodule update --init


sudo apt-get update
sudo apt-get install git wget make libncurses-dev flex bison gperf python python-serial

ESP32 toolchain for Linux is available for download from Espressif website:

Download the file, then extract it into ~/esp directory:

mkdir -p ~/esp
cd ~/esp
tar -xzf ~/Downloads/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz

The toolchain will be extracted into ~/esp/xtensa-esp32-elf/ directory.

Install the ESP_IDF:

cd ~/esp

git clone --recursive
cd esp-idf
git submodule update --init

RPI & UBUNTU ENV settings:

Note: To use it, you will need to update your PATH environment variable in ~/.profile file. To make xtensa-esp32-elf available for all terminal sessions, add the following line to your ~/.profile file

export PATH=$PATH:~/xtensa-esp32-elf-raspberry/xtensa-esp32-elf/bin
export IDF_PATH=~/esp-idf

If you want to run the toolchain from an UBUNTU VM this Vagrantfile might be useful.

Communication with the ESP32 module

Communication and powering/charging the ESP32 is done through the USB.
The USB port emulates the CP210x serial port and thus the system sees it as one of the serial ports.
There can be several ESP32 connected to a single computer and then they can be flashed or monitored at same time.
You don't need a separate programmer to upload the software or files to the ESP32.

You need to know the name of the serial port where your ESP32 is connected.
Check the list of serial ports before and after connecting the device: on Linux type:

ls /dev/tty*

or check the system log files, on Linux:
dmesg | tail -n 30

Make note of the device name eg. ttyUSB1


make menuconfig

In the "Espressif IoT Development Framework Configuration" application go to
menuconfig —> Serial Flasher config find (/dev/ttyUSB0) change to your port.When you put the ESP32 module into a box it is certainly worth to leave the USB accessible,
as then uploading a new software or changing the configuration or powering/charging is non-problematic.


Getting from github

git clone
cd esp32-ogn-tracker

Configuring the project

You need to tell it which serial port is your ESP32 connected to, type:

make menuconfig

The ESP32-DIY tracker uses the function: uxTaskGetSystemState() so we need to request on the menuconfig the following option:
menuconfig —> components —> FreeRTOS —> Enable Free RTOS trace Facility

Choosing options, changing pin-out

edit files:

  • main/hal.h for general options
  • main/hal.cpp for exact pinout

ESP32 is fairly flexible about the pin assignment, for peripherals likes UART, SPI or I2C almost any pin can be chosen.
If you have good reasons you may relocate for example the GPS pins: data Rx/Tx, PPS and Enable.
Pins for the RF chip and the OLED display are fixed by the module construction.


type (in the project directory):


or to speed it up:
make -j2

Make will take long time at the first compile or when you change any options in the menuconfig.
Otherwise it would only recompile the project files you have changed since the most recent make.

Uploading to ESP32


make partition_table-flash
make flash

Configuring the Tracker

Open a serial terminal, on Linux: minicom
and configure it for 115200bps, 8bit, no parity, no hardware flow control

sudo minicom -D /dev/ttyUSB0 -b 115200 -8

or Monitor
To see the ESP32 DIY tracker application is indeed running, type make monitor. This command is launching IDF Monitor application:

$ make monitor

--- idf_monitor on /dev/ttyUSB0 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

configsip: 0, SPIWP:0xee
mode:DIO, clock div:2
entry 0x40078d38
I (127) cpu_start: Pro cpu up.
I (127) cpu_start: Single core mode
I (128) heap_init: Initializing. RAM available for dynamic allocation:
I (131) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (137) heap_init: At 3FFC3260 len 0001CDA0 (115 KiB): DRAM
I (144) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (150) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (156) heap_init: At 40089AF4 len 0001650C (89 KiB): IRAM
I (163) cpu_start: Pro cpu start user code
I (181) cpu_start: Starting scheduler on PRO CPU.
TaskRF: v12
TaskGPS: 9600bps
TaskGPS: 19200bps
TaskGPS: 38400bps
TaskGPS: 57600bps

You should see a stream of NMEA messages.
Type a command like:


Type Ctrl-C on the terminal and check if there is a response

1:3:8A0749 RFM95/+14dBm -20.0kHz CON:115200bps
GPS: 57600bps,1.00s,NMEA,UBX,BaudOK,ModeOK
Task            Pr. Stack, 216.180kB free
main            01 3356
IDLE            00 536
GPS             04 1392
PROC            03 1284
RF              04 1256
Tmr Svc         01 1656
ipc0            24 624
esp_timer       22 4220
SPIFFS: 0kB used, 875kB total
Address      = 0x8A0749; # [24-bit]
AddrType     = 0x3; #  [2-bit]
AcftType     = 0x1; #  [4-bit]
Console      = 115200; #  [  bps]
TxPower      = +14; #  [  dBm]
FreqCorr     = -20.0; #  [  kHz]
TempCorr     = +0; #  [ degC]
PressCorr    = +0.0; #  [   Pa]
TimeCorr     = +0; #  [    s]
GeoidSepar   = +47.0; #  [    m]
Pilot        = Pawel #  [char]
Manuf        =  #  [char]
Model        =  #  [char]
Reg          =  #  [char]
Base         =  #  [char]
ICE          =  #  [char]

Aircraft Type

The default is "glider" (1), but you can change it. In particular for flight log to see the towing aircrafts correctly it is recommended to set trackers in the towing planes to "tow-plane" (2)

Address type

The default is OGN (3) but you can change to be ICAO address type (1)

ICAO address

If you want your tracker transmit the ICAO address of your aircraft

RF frequency correction

The ESP32 modules appear to have cheap crystals which need correcting. This far all the modules I have seen required -20kHz and one -40kHz correction.


Arduino code
UART example
SPI example
I2C example
OLED driver
OLED datasheet
OLED example
OLED article
GPS GN-801 pic
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License