Introduction
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.
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.
Hardware
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.
Pinout
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:
$POGN,FreqCorr=-20
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:
- power/ground wires are reversed in colour ! To make sure check the connection between the red and the (metal) ground on the module
- in order to use the "enable" control line, you need to remove a tine SMD resistor - a fairly delicate job https://ae01.alicdn.com/kf/HTB1TQFZnnTI8KJjSsphq6AFppXat.jpg
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.
MAVlink
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
External Screens
Model ili9341 320x240
Pinout with Heltec WiFi LoRa 32 (V2)
Touch option and SD Card reader not used
SDO (MISO) - ( none )
LED 12
SCK 5
SDI (MOSI) 27
D/C 17
RESET RESET
CS 23
GND GND
VCC +3,3
—
Model ST7789 240x240
Pinout with TTGO T-Beam v1.0
GND GND
VCC 3.3V
SDA 14
SCL 13
RES 33
DC 2
BLK 32
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.
Linux 2020 Procedure with Heltec WiFi LoRa 32 (V2)
This procedure works with…
- Raspberry PI 3 & 4 Raspbian Buster - April 2020
- Ubuntu 19.10 AMD64 - April 2020
- Debian Buster X AMD64 - April 2020
With a raspberry from the scratch, write on a SD card the Raspbian Buster Little … https://www.raspberrypi.org/downloads/raspbian/
Install Ubuntu 19.10 for AMD64 on a Computer
Install Debian Buster on a Computer
On the raspberry; login as pi user ( password raspberry ), use raspi-config to configure the keyboard, language, ssh acces if you need, exit and may be ask to reboot. Also you can use a desktop version to do all, but here is on console, withouth graphical environment; fast and secure.
From here the steps for the Ubuntu and Debian are the same
First of all, use a shell as root, and then update the distro and install some packages …
sudo bash
apt-get update ; apt-get upgrade -y
apt-get install git wget make libncurses-dev flex bison gperf python3 python3-serial python3-pip mc minicom
Set python3 as default and then check you´re ok on version
update-alternatives --install /usr/bin/python python /usr/bin/python3 2
update-alternatives --install /usr/bin/python python /usr/bin/python2 1
python --version
( Then reboot the pi. And enter again as root. ) you can do or not
Instal a requirement on python
pip3 install --upgrade virtualenv==16.7.9
Change to root home, set the path, clone the source, start to compile, and set the path vaiables …
cd
export IDF_PATH=~/esp-idf
git clone -b v4.0 --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
./install.sh
. ./export.sh
After that, check thay you path environment is ok
echo $PATH
The response should be …
PATH=/root/esp-idf/components/esptool_py/esptool:/root/esp-idf/components/espcoredump:/root/esp-idf/components/partition_table/:
/root/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin:/root/.espressif/python_env/idf4.0_py3.7_env/bin:
/root/esp-idf/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Go to root and clone the source of the ogn-tracker.
cd
git clone https://github.com/pjalocha/esp32-ogn-tracker.git
cd esp32-ogn-tracker
Clone the screen source required for Heltec V2 board.
mkdir components
cd components
git clone https://github.com/olikraus/u8g2.git
cd ..
Copy the board config as default and overwrite the config.h ( type y and enter if you prompted )
cp HELTEC_v2.cfg main/config.h
If you wish you can check or modify the config with … ( is not necesary )
make menuconfig
And at the end, compile the project …
make -j2
After some warnings at the end said …
" To flash all build output, run 'make flash' or:
python /root/esp-idf/components/esptool_py/esptool/esptool.py —chip esp32 —port /dev/ttyUSB0 —baud 921600
—before default_reset —after hard_reset write_flash -z —flash_mode dio —flash_freq 40m —flash_size detect 0x1000
/root/esp32-ogn-tracker/build/bootloader/bootloader.bin 0x10000 /root/esp32-ogn-tracker/build/app-template.bin
0x8000 /root/esp32-ogn-tracker/build/partitions.bin"
Plug your board to the raspberry; should be on /dev/ttyUSB0 … to check
If you have several devices on ttyUSB(0,1,2, … ), I recommend you to left only one pluged and be sure than is the ttyUSB0, to avoid flashing mistakes;
you can compile the driver to flash on ttyUSB1, ttyUSB2, but is a little trouble with devices. The best option is always be the 0.
dmesg |grep usb
usb 1-1.3: new full-speed USB device number 3 using xhci_hcd
usb 1-1.3: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00
usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.3: Product: CP2102 USB to UART Bridge Controller
usb 1-1.3: Manufacturer: Silicon Labs
usb 1-1.3: SerialNumber: 0001
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial support registered for generic
usbcore: registered new interface driver cp210x
usbserial: USB Serial support registered for cp210x
usb 1-1.3: cp210x converter now attached to ttyUSB0
Here is cp210x as ttyUSB0
And then to write on board …
make flash
Toolchain path: /root/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: esp-2019r2
Compiler version: 8.2.0
Python requirements from /root/esp-idf/requirements.txt are satisfied.
/root/esp-idf/make/project.mk:626: warning: undefined variable 'IDF_SKIP_CHECK_SUBMODULES'
App "app-template" version: 5e4badf-dirty
Flashing binaries to serial port /dev/ttyUSB0 (app at offset 0x10000)...
esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting......
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
( ... )
Leaving...
Hard resetting via RTS pin...
Wait for reset the board, shows info on screen, … and That´s all.
A resume of the steps to compile another board and flash with the environment already working.
Turn on the pi
Login as pi user and then sudo bash
cd
export IDF_PATH=~/esp-idf
cd esp-idf
. ./export.sh
cd
git clone https://github.com/pjalocha/esp32-ogn-tracker.git
cd esp32-ogn-tracker
mkdir components
cd components
git clone https://github.com/olikraus/u8g2.git
cd ..
cp your_board_config.cfg main/config.h
make -j2
make flash
The steps to flash another board with the environment already working and a flash compiled.
Turn on the pi
Login as pi user and then sudo bash
cd
export IDF_PATH=~/esp-idf
cd esp-idf
. ./export.sh
cd
cd esp32-ogn-tracker
make flash
Configuring some options on the Tracker
Open a serial terminal, with program minicom and configure it for 115200bps, 8bit, no parity, no flow control; to enter on setup ( -s parameter )
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
On Setup only for the firs time ( if you save the settings at exit ); you need to configure several parameters as show.
First enter on Serial port Setup Section.
+-----[configuration]------+
| Filenames and paths |
| File transfer protocols |
>>| Serial port setup |<<
| Modem and dialing |
| Screen and keyboard |
| Save setup as dfl |
| Save setup as.. |
| Exit |
| Exit from Minicom |
+--------------------------+
You need to put the Serial Device as show ( /dev/ttyX change to /dev/ttyUSB0 ) type letter A for it. Disable Flow Control; left with No the F and G option ( type the letters to change Yes/No )
+-----------------------------------------------------------------------+
| A - Serial Device : /dev/ttyUSB0 |
| B - Lockfile Location : /var/lock |
| C - Callin Program : |
| D - Callout Program : |
| E - Bps/Par/Bits : 115200 8N1 |
| F - Hardware Flow Control : No |
| G - Software Flow Control : No |
| |
| Change which setting? |
+-----------------------------------------------------------------------+
If the E option is not ok as show ( 115200 8N1 ) you have to modify as showing, on next menu with E key … Type D and Q and then exit with Enter.
If the config is ok exit from the Serial Device Menu with ESC or Enter to Main Menu.
+-----------------+---------[Comm Parameters]----------+----------------+
| A - Serial De| | |
| B - Lockfile Loc| Current: 115200 8N1 | |
| C - Callin Pro| Speed Parity Data | |
| D - Callout Pro| A: <next> L: None S: 5 | |
| E - Bps/Par/B| B: <prev> M: Even T: 6 | |
| F - Hardware Flo| C: 9600 N: Odd U: 7 | |
| G - Software Flo| D: 38400 O: Mark V: 8 | |
| | E: 115200 P: Space | |
| Change which | | |
+-----------------| Stopbits |----------------+
| Screen a| W: 1 Q: 8-N-1 |
| Save set| X: 2 R: 7-E-1 |
| Save set| |
| Exit | |
| Exit fro| Choice, or <Enter> to exit? |
+---------+------------------------------------+
On configuration Main Menu select the option Save setup as dfl and hit enter …
+-----[configuration]------+
| Filenames and paths |
| File transfer protocols |
| Serial port setup |
| Modem and dialing |
| Screen and keyboard |
>>| Save setup as dfl | <<
| Save setup as.. |
| Exit |
| Exit from Minicom |
+--------------------------+
And you see a msg …
+-----------------------+
| |
| Configuration saved |
| |
+-----------------------+
After that, select Exit and you should see data info from the tracker.
Exit ( CTRL+A X ) from Minicom and enter again on the program, withouth the -s parameter … and you´re already on terminal.
minicom
If you have an error such " minicom: cannot open /dev/ttyUSB0: No such file or directory "… maybe the device is unpluged.
An error opening the port you can specify on prompt if its different, or it opens other device.
minicom -D /dev/ttyUSB0
—
When you enter on minicom, you will see the intro screen and a continuos flow of text from the usb device … It´s a stream of NMEA messages.
Welcome to minicom 2.7.1
OPTIONS: I18n
Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyUSB0, 23:26:51
Press CTRL-A Z for help on special keys
$GNRMC,,V,,,,,,,,,,N*4D
$GNGGA,,,,,,0,00,99.99,,,,,,*56
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E
$POGNR,0,0,,-102.5,1954,+31,,*61
$GNRMC,,V,,,,,,,,,,N*4D
$GNGGA,,,,,,0,00,99.99,,,,,,*56
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E
$POGNR,0,0,,-102.5,1956,+31,,*63
You can also use Monitor
To see the ESP32 DIY tracker application is indeed running, type make monitor. This command is launching IDF Monitor application:
$ make monitor
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
rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4548
load:0x40078000,len:0
load:0x40078000,len:13176
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.
$POGNR,0,0,,+0.0,0,+0,,*6A
TaskGPS:
TaskRF: v12
$POGNR,0,0,,-112.0,0,+27,,*5B
$POGNR,0,0,,-112.0,2,+28,,*56
TaskGPS: 9600bps
$POGNR,0,0,,-112.0,4,+27,,*5F
$POGNR,0,0,,-112.0,6,+28,,*52
TaskGPS: 19200bps
$POGNR,0,0,,-112.0,8,+28,,*5C
$POGNR,0,0,,-112.0,10,+28,,*65
TaskGPS: 38400bps
$POGNR,0,0,,-112.0,12,+27,,*68
$POGNR,0,0,,-112.0,14,+28,,*61
TaskGPS: 57600bps
$POGNR,0,0,,-112.0,16,+28,,*63
$GPRMC,,V,,,,,,,,,,N*53
$GPGGA,,,,,,0,00,99.99,,,,,,*48
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
...
You should see a stream of NMEA messages.
Type a command like ( no spaces, only letters, numbers and dash ) on scroll text to set several variables:
$POGNS,Pilot=Pawel,FreqCorr=-20,Reg=EC-AC9,Model=JANUS
With Heltec V2 Board the parameter FreqCorr by default is ok ( 0 ), do not change.
$POGNS,Pilot=JLuis,Reg=UF-666,Model=MQUFO,Manuf=EPB,
The FreqCorr parameter wrong, may make unavailable.
Type Ctrl-C on the terminal and check if there is a response
$GPGGA,104308.00,,,,,0,00,99.99,,,,,,*68
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]
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
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)
Here is the list of aircrafts
UNKNOWN(0), GLIDER(1), TOW_PLANE(2), HELICOPTER_ROTORCRAFT(3), PARACHUTE(4), DROP_PLANE(5), HANG_GLIDER(6), PARA_GLIDER(7), POWERED_AIRCRAFT(8),
JET_AIRCRAFT(9), UFO(0xa), BALLOON(0xb), AIRSHIP(0xc), UAV(0xd), STATIC_OBJECT(0xe)
To set as Airship …
$POGNS,AcftType=0xc,
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.