Skip to main content

Custom board wiring

What this example shows​

Using the module when the receiver is not wired the way it is on this board: a different UART, different GPIO pins, or no RESET line at all. You build the UART yourself and hand it to the module, so you override only what differs.

On this board you do not need this. The receiver is wired to UART1 with IO17, IO18 and IO21, as in Read aircraft reports. Use this page when you wire a Soldered receiver module into your own ESP32 design.

The example code​

This is Examples/ADSBReceiver-customBoardWiring.py from the pinned module, without the file's header comment. The script body is exactly as shipped. Its example wiring is UART2 on IO4 and IO5 with no RESET pin.

from machine import UART
from ADSBReceiver import ADSBReceiver

# Example: module on UART2, using IO4/IO5, with no RESET pin wired at all.
uart = UART(2, baudrate=115200, rx=4, tx=5, rxbuf=4096)
adsb = ADSBReceiver(uart, reset_pin=None)


# Called once per decoded aircraft update.
def onAircraft(ac):
print("ICAO {}".format(ac.icao))


# Register the function to call whenever a decoded aircraft report arrives.
adsb.onAircraft(onAircraft)

while True:
adsb.poll()

On this board the receiver is wired to IO17 and IO18, so the script as shipped (IO4 and IO5) listens on pins the receiver does not use and prints nothing. Change the UART line to match your wiring, or use the wiring from Read aircraft reports for this board.

Expected result​

With the receiver connected to the pins you gave the UART and an aircraft in range, the script prints one line per decoded aircraft update: ICAO followed by the aircraft's 24-bit address in hex. The addresses depend on which aircraft are in range. The script loops forever.

Functions used​

ADSBReceiver(uart, reset_pin=None)returns ADSBReceiver

Creates the receiver object on a UART you have already opened. If you give a reset pin, the module makes it a high-impedance input, so the pin is only driven during hardwareReset().

ReturnsA receiver object ready for the other functions.

Parameters

TypeNameDescription
machine.UARTuartAn open UART connected to the receiver. Size its receive buffer when you create it, as the example does with rxbuf=4096: dense traffic can overflow the default buffer and corrupt lines.
int or Nonereset_pinGPIO wired to the receiver's RESET pin. Optional, default None, which disables hardwareReset().
onAircraft(cb)returns None

Registers the function that is called for every decoded aircraft report the receiver sends in CSV format.

ReturnsNothing.

Parameters

TypeNameDescription
functioncbThe function to call, given an AdsbAircraft object. ac.icao is the aircraft's ICAO address as a hex string. Fields the receiver had no data for keep their defaults, with the matching has... attribute False.
poll()returns None

Reads every byte that has arrived, parses the complete lines and calls the registered functions. It does not block, so call it on every pass of your loop.

ReturnsNothing.

Putting it together​

Only the UART(...) line and the reset_pin argument change when your wiring differs. Everything after them, onAircraft() and poll(), works the same as on this board. The receiver still has to be set up for CSV output, which is its default according to the receiver's datasheet for receiver firmware v2.89.28. The firmware on your receiver was not checked against it.