Phill edited this page May 12, 2018 · 258 revisions

PJON wiki

PJON (Padded Jittering Operative Network) is an Arduino compatible, multi-master, multi-media communications bus system. It proposes a Standard, it is designed as a framework to ease digital communication and it implements a totally software emulated network protocol stack. Its more common applications are in the field of automation, internet of things and industry 4.0. Extended tests proved its effectiveness on different media like electricity, radio and light. See the video introduction to have a brief overview.

Join the chat at https://gitter.im/gioblu/PJON Donate

PJON (Padded Jittering Operative Network) Protocol specification

Compliant tools

Why PJON?

PJON is a tool created to simplify communication between devices and network engineering. Choose the medium you prefer, build your own network of devices and make it work with few lines of code. There are 7 strategies available to communicate data with PJON on various media:

SoftwareBitBang | Medium: Wire | Pins used: 1 or 2

SoftwareBitBang is based on micros and delayMicroseconds, needs 1 or optionally 2 wires and no additional hardware to handle one or many to many communication on a single channel or bus. It can be run on cheap and low performance microcontrollers. Bus maximum length is mostly limited by the resistance of the common conductive element used. It has been tested with up to 50m long insulated wires, results demonstrate the same high performance achieved with shorter lengths. It complies with PJDL v2.0 data link layer specification. Take a look at the video introduction for a brief showcase of its features.

AnalogSampling | Medium: Light | Pins used: 1 (analog) or 2 (analog + digital)

AnalogSampling complies with PJDLS v2.0, it is designed to communicate data wirelessly using light impulses and its sampling technique based on analog readings. It is optimized to use a single LED for both data transmission and reception, enabling bidirectional half-duplex communication with a single LED per device (ir, visible, uv) or with any sort of emitter and receiver pair.

EthernetTCP | Medium: Ethernet port, wired or WiFi

With the EthernetTCP PJON strategy, multiple devices with Ethernet ports can use PJON to communicate with each other on a LAN, WAN or across the Internet.

LocalUDP | Medium: Ethernet port, wired or WiFi

With the LocalUDP PJON strategy, multiple devices with Ethernet ports can use PJON to communicate with each other on a local subnet, wired or over WiFi or both.

GlobalUDP | Medium: Ethernet port, wired or WiFi

With the GlobalUDP PJON strategy, multiple devices with Ethernet ports can use PJON to communicate with each other on a LAN, WAN or across the internet.

OverSampling | Medium: Radio, Wire | Pins used: 1 or 2

Oversampling strategy comes from the PJON_ASK repository, its procedure has been specified to obtain long range and high reliability using FSK/ASK/OOK 315/433MHz radio transceivers available on the market. It complies with PJDLR v2.0 specification. Take a look at the video introduction for a brief showcase of its features.

ThroughSerial | Medium: Hardware Serial port | Pins used: 2

With ThroughSerial data link layer strategy, PJON can run through a software emulated or hardware Serial port. Thanks to this choice it is possible to leverage of virtually all the arduino compatible serial transceivers, like RS485, radio or infrared modules, still having PJON unchanged on top.

Practical test

After selecting the medium to be used you can start to build your personal bus (that can be made by only two devices for testing):

 Arduino UNO        Arduino UNO
  _________   wire   _________
 | ||   |_||___     |         |
 ||       ||   |    ||       ||
 ||       ||   |    ||       ||
 ||       ||   |____||       ||
 |_________|        |_|_|__||_|
                      

A simple entry level test can be to setup a couple of Arduino Duemilanove / Uno boards connected together with one single wire on both pins 12 as described in the illustration above (also sharing commong ground). When the devices are wired it is possible to test their connectivity sending a packet from device 1 to device 2 and see if device 2 receives it blinking a LED:

#include <PJON.h>
PJON<SoftwareBitBang> bus(1); // <Strategy name> bus(selected device id)

void setup() {
  bus.strategy.set_pin(12);
  bus.begin();
  bus.send_repeatedly(2, "B", 1, 1000000); // Send B to device 2 every second
}

void loop() {
  bus.update();
};

As you can see the code above, device 1 is simply sending a "B" every second to the device id 2.

#include <PJON.h>
PJON<SoftwareBitBang> bus(2); // <Strategy name> bus(selected device id)

void setup() {
  pinModeFast(13, OUTPUT);
  digitalWriteFast(13, LOW); // Initialize LED 13 to be off
  bus.strategy.set_pin(12);
  bus.begin();
  bus.set_receiver(receiver_function);
};

void receiver_function(
  uint8_t *payload, 
  uint16_t length, 
  const PJON_Packet_Info &packet_info
) {
  if(payload[0] == 'B') {
    digitalWrite(13, HIGH);
    delay(30);
    digitalWrite(13, LOW);
  }
}

void loop() {
  bus.receive(1000);
};

On the receiver side is declared a receiver function that is called when a packet for the device is received. In this case, the function checks if the received character is "B" and if so, blinks the LED connected to pin 13. You should see the receiver device blinking every second.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.