esp32.diy

PJON: Multi-Master Networking Protocol for ESP32 Builds

Oct 11, 2026 · 5 min read

Intermediate 2.8k stars 241 forks C++ NOASSERTION Updated 2025-11-21
TL;DR PJON is a software-defined, multi-master network protocol that connects ESP32 and other microcontrollers over a single wire, radio link, or existing IP infrastructure. It handles addressing, error detection, and acknowledgement with a footprint as small as 4.2 kB, making it practical for resource-constrained IoT builds.
What you need
  • ESP32
  • ESP8266
  • ATtiny
  • ATmega
  • SAMD
  • STM32
  • Teensy
  • Raspberry Pi
Protocol versionPJON 13.1
LanguageC++
Program footprint4.2–8.2 kB
Max devices (PJDL wire)255 per bus
Wire range (PJDL)Up to 2000 m
LicenseApache 2.0

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):

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:

Physical media (choose one to start):

No extra networking hardware is required for the wired or ESPNOW strategies — just the boards and a wire.

Typical use cases

Multi-Room Sensor Bus

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.

Actuator Control Over RS485

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.

LoRa Sensor Network

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.

Mixed-MCU Prototyping

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:

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:

  1. Clone or download the PJON repository from github.com/gioblu/PJON and place it in your Arduino libraries folder, or add it via PlatformIO's library manager.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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:

Limitations to keep in mind:

Verdict

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 & README

Facts 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.