PJON: Multi-Master Networking Protocol for ESP32 Builds
- ESP32
- ESP8266
- ATtiny
- ATmega
- SAMD
- STM32
- Teensy
- Raspberry Pi
What You Will Build and Why It Matters
This guide walks you through setting up PJON (Padded Jittering Operative Network) to create a reliable communication layer between ESP32 boards and other microcontrollers in your projects. Rather than tacking on a cloud broker or relying on vendor-specific radio stacks, PJON gives you a self-contained, software-defined network that runs on your own hardware.
The practical result is a group of microcontrollers — ESP32s, ATtiny nodes, Raspberry Pis, or a mix — that can exchange messages over whatever physical medium you already have: a single GPIO wire, RS485 cable, LoRa radio, ESPNOW, MQTT, or a direct TCP/UDP link. PJON adds multi-master addressing, CRC8 and CRC32 error detection, optional acknowledgement, and hot-swap support (you can add or replace a device without resetting the bus).
Typical applications include sensor networks spread across a building, actuator buses for home automation, and multi-node robotics where each subsystem needs to talk to the others without a central server.
What You Need
Supported boards (any combination works on one bus):
- ESP32 or ESP8266
- ATtiny or ATmega (Arduino Uno, Nano, etc.)
- SAMD-based boards
- STM32 or Teensy
- Raspberry Pi (Linux)
You need at least two nodes to test communication. Start with two ESP32 development boards if you are new to PJON — they are the easiest to set up with the ESPNOW or SoftwareBitBang strategies.
Software:
- Arduino IDE or PlatformIO
- PJON library — available from the PJON GitHub repository
- The appropriate board support package for your target (ESP32 Arduino core, etc.)
Physical media (choose one to start):
- A single wire between two GPIO pins for PJDL (SoftwareBitBang strategy)
- A pair of ASK/FSK radio modules for PJDLR (OverSampling strategy)
- LEDs or laser diodes for PJDLS (AnalogSampling, optical strategy)
- An existing RS485 cable, USB serial link, LoRa module, or your LAN for IP-based strategies
No extra networking hardware is required for the wired or ESPNOW strategies — just the boards and a wire.
Typical use cases
Daisy-chain temperature, humidity, and motion sensors on a single PJDL wire across rooms. Each node has its own device ID and reports to a central ESP32 without any cloud dependency.
Drive relays, motors, or valves from a host controller over an existing RS485 cable. PJON's multi-master support means any node can initiate a command, not just the host.
Place remote sensor nodes kilometres apart and bridge their readings back to a base station using the ThroughLoRa strategy, keeping everything inside the PJON addressing scheme.
Prototype a system where an ESP32 handles Wi-Fi reporting, an ATtiny manages power-sensitive sensing, and a Raspberry Pi runs data logging — all on the same PJON bus.
How PJON Works
PJON is structured as a stack of two layers:
Strategy (data link layer): This is the physical transport. You pick one strategy per bus. The most commonly used strategies are:
- SoftwareBitBang / PJDL — single wire, up to 2000 m, up to 255 devices sharing the same conductor.
- OverSampling / PJDLR — works with standard ASK, FSK, and OOK radio modules.
- AnalogSampling / PJDLS — optical communication using off-the-shelf LEDs or laser diodes (wear eye protection).
- ThroughSerial / ThroughLoRa — uses existing Serial or LoRa hardware.
- LocalUDP / GlobalUDP / TCP / MQTT / ESPNOW — routes PJON packets over your existing IP infrastructure or ESP-NOW radio.
Packet format: PJON packets are modular — they include only the fields that the chosen configuration actually needs. Overhead ranges from 5 bytes (minimal local addressing) to 35 bytes (full shared-bus addressing with MAC and CRC32). Each device has a local ID (1–255) and can optionally be part of a named bus identified by a 4-byte bus ID.
Error detection uses modern CRC8 and CRC32 polynomials. Optional acknowledgement lets the sender confirm delivery. Hot-swap is built in — there is no need for a system reset when you add or remove a node.
Build and Flash Steps
The PJON repository does not include a single install command in its README, so follow these steps using the project's own documentation:
-
Clone or download the PJON repository from github.com/gioblu/PJON and place it in your Arduino
librariesfolder, or add it via PlatformIO's library manager. -
Choose your strategy. For a first test with two ESP32 boards, the SoftwareBitBang strategy (PJDL) needs only one wire connecting a GPIO pin on each board (plus a shared ground). For a wireless first test, ESPNOW needs no extra hardware at all — both boards use their built-in Wi-Fi radios.
-
Assign device IDs. Every node on a PJON bus needs a unique ID between 1 and 255. Decide which board is device 1 and which is device 2 before writing your sketches.
-
Write sender and receiver sketches based on the examples in the
examples/folder of the repository. Each example is named after its strategy, so navigate to the folder matching your chosen medium. -
Compile and flash each board using Arduino IDE or PlatformIO as you would for any Arduino-compatible sketch. PJON builds out of the box on all supported targets with no extra build flags required for basic use.
-
Open the Serial Monitor on the receiver to confirm packets are arriving. PJON's error callback will report CRC failures or missed acknowledgements, giving you immediate feedback if wiring or radio conditions need attention.
For full API reference, configuration options, and strategy-specific wiring notes, read the documentation and the protocol specification included in the repository.
Safety note from the project: When working with SoftwareBitBang buses, follow the interference-mitigation and protective-circuitry guidelines in the PJON wiki. When using AnalogSampling (optical), wear safety glasses. Before transmitting on LoRa or other radio strategies, verify that your frequency, power level, and hardware comply with local regulations. Never connect a PJON bus to the internet if it controls anything that could cause fire, flood, or data loss if compromised.
Extending the Project and Known Limitations
Ideas to extend your build:
- Bridge strategies: Run a gateway node that listens on a wired PJDL bus and forwards packets over MQTT or UDP to nodes on a different subnet or a cloud broker.
- Mixed hardware buses: Connect an ESP32, an ATmega node, and a Raspberry Pi on the same RS485 cable. PJON's cross-compilation support means all three can share the same protocol without modification.
- ModuleInterface: The compliant tool ModuleInterface (by Fred Larsen, listed in the PJON repo) adds configuration synchronisation and value exchange between IoT modules built on top of PJON.
- Python integration: PJON-python lets a PC or Raspberry Pi participate as a bus node from a Python script, useful for logging, dashboards, or control interfaces.
- gRPC gateway: PJON-gRPC wraps a PJON bus behind a gRPC server for integration with modern service architectures.
Limitations to keep in mind:
- PJON is explicitly described as experimental. It is distributed as-is, without warranty, and the 60 open issues on GitHub reflect areas still under active development.
- The latest release (13.1) is from February 2022, though the repository still receives commits. Evaluate stability for your use case before deploying in production.
- Strategy selection is fixed at compile time per node. Bridging two different media requires a dedicated gateway node running both strategies.
- Optical (AnalogSampling) and radio (OverSampling) strategies require careful hardware selection and environmental testing; performance varies significantly with conditions.
PJON is a mature, well-documented protocol library for makers who need reliable device-to-device communication without committing to a specific radio standard or cloud platform. Its small footprint, broad board support, and choice of strategies make it genuinely versatile, though its experimental status and the age of the last formal release mean you should test thoroughly before any safety-critical deployment. If you are building a multi-node ESP32 project and want full control over the network layer, PJON is one of the most capable open-source options available.
Sources
github.comgioblu/PJON — repository & READMEFacts in this article come from the project's public README and GitHub metadata at the time of writing. Images belong to their respective owners and link back to the original source.



