Custom board wiring
What this example shows
Using the library when the receiver is not wired the way it is on this board: a different hardware UART, different GPIO pins, or no RESET line at all. All four constructor parameters are optional and independent, so you override only the ones that differ from your wiring.
On this board you do not need this. The receiver is wired to UART1 with IO17,
IO18 and IO21, which are the library's defaults, so ADSBReceiver adsb; is
enough, 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 7_CustomBoardWiring.ino from the pinned library, without the file's
header comment. The sketch body is exactly as shipped. Its example wiring is UART2
on IO4 and IO5 with no RESET pin.
#include "ADSB-Receiver-SOLDERED.h"
// Constructor parameters, in order:
// uartNum - which ESP32 hardware UART peripheral to use (avoid 0, that's usually the USB/console UART)
// rxPin - ESP32 GPIO wired to the module's TX pin
// txPin - ESP32 GPIO wired to the module's RX pin
// resetPin - ESP32 GPIO wired to the module's RESET pin, or -1 if not connected
//
// Example: module on UART2, using IO4/IO5, with no RESET pin wired at all.
ADSBReceiver adsb(2, 4, 5, -1);
// Called once per decoded aircraft update.
void onAircraft(const AdsbAircraft &ac)
{
Serial.print("ICAO ");
Serial.println(ac.icao);
}
void setup()
{
Serial.begin(115200);
// Open the UART link using the pins given to the constructor above.
adsb.begin(115200);
// Register the function to call whenever a decoded aircraft report arrives.
adsb.onAircraft(onAircraft);
}
void loop()
{
adsb.poll();
}
On this board the receiver is wired to IO17 and IO18, so the sketch as shipped
(IO4 and IO5) listens on pins the receiver does not use and prints nothing.
Change the constructor to match your wiring, or use ADSBReceiver adsb; for
this board.
Expected result
Open Tools → Serial Monitor, set the baud rate to 115200 and reset the
board. With the receiver connected to the pins you passed to the constructor and
an aircraft in range, the sketch 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.
Functions used
ADSBReceiver(uint8_t uartNum, int8_t rxPin, int8_t txPin, int8_t resetPin)returns NoneCreates the receiver object and tells it which UART and pins to use. Every parameter is optional; the defaults are the wiring of this board. The library only builds for the ESP32 family, because it drives one of the chip's hardware UARTs directly.
ReturnsConstructor; no return value.
Parameters
| Type | Name | Description |
|---|---|---|
uint8_t | uartNum | ESP32 hardware UART to use. Optional, default 1. Avoid 0, which is usually the USB console. |
int8_t | rxPin | ESP32 GPIO wired to the module's TX pin. Optional, default 17. |
int8_t | txPin | ESP32 GPIO wired to the module's RX pin. Optional, default 18. |
int8_t | resetPin | ESP32 GPIO wired to the module's RESET pin. Optional, default 21. Pass -1 if it is not connected, which also disables hardwareReset(). |
begin(uint32_t initialBaud, size_t rxBufferSize)returns voidOpens the UART link on the pins given to the constructor. Call it once in setup().
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
uint32_t | initialBaud | Baud rate to start at. Optional, default 115200. |
size_t | rxBufferSize | Size of the UART receive buffer in bytes. Optional, default 4096. |
onAircraft(AircraftCallback cb)returns voidRegisters the function that is called for every decoded aircraft report the receiver sends in CSV format.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
void (*)(const AdsbAircraft &ac) | cb | The function to call. ac.icao is the aircraft's ICAO address as a hex string. Fields the receiver had no data for stay at their defaults, with the matching has... flag false. |
poll()returns voidReads every byte that has arrived, parses the complete lines and fires the registered callbacks. It does not block, so call it on every pass of loop().
ReturnsNothing.
Putting it together
Only the constructor line changes when your wiring differs. Everything after it,
begin(), 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.