-
Notifications
You must be signed in to change notification settings - Fork 239
Home
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 13 strategies available to communicate data with PJON on various media:
Strategy | Physical layer | Protocol |
---|---|---|
AS AnalogSampling | Light pulses over air or optic fiber | PJDLS |
OS OverSampling | Electrical/radio impulses over wire/air | PJDLR |
SB SoftwareBitBang | Electrical impulses over conductive element | PJDL |
TS ThroughSerial | Electrical/radio impulses over wire/air | TSDL |
TS ThroughSerialAsync | Electrical/radio impulses over wire/air | TSDL |
ET EthernetTCP | Electrical/radio impulses over wire/air | TCP |
LU LocalUDP | Electrical/radio impulses over wire/air | UDP |
GU GlobalUDP | Electrical/radio impulses over wire/air | UDP |
DU DualUDP | Electrical/radio impulses over wire/air | UDP |
TL ThroughLoRa | Radio impulses over air | LoRa |
EN ESPNOW | Radio impulses over air | ESPNOW |
LF LocalFile | Shared file system in memory | None |
Any | Virtual inheritance, any of the above | Any of the above |
Device | AS | OS | SB | TS | ET | LU | GU | DU | TL |
---|---|---|---|---|---|---|---|---|---|
Arduino Duemilanove | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Arduino Nano | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Arduino Uno | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Arduino Leonardo | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Arduino Micro | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Arduino Mega | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Arduino Zero | ❌ | ❌ | ✔️ | ✔️ | ❌ | ❌ | ❌ | ❌ | ❌ |
Arduino Due | ❌ | ❌ | ❌ | ✔️ | ❌ | ❌ | ❌ | ❌ | ❌ |
ATMega1284P | ❌ | ❌ | ✔️ | ✔️ | ❌ | ❌ | ❌ | ❌ | ❌ |
ATtiny84/84A | ❌ | ❌ | ✔️ | ✔️ | ❌ | ❌ | ❌ | ❌ | ❌ |
ATtiny85 | ❌ | ❌ | ✔️ | ✔️ | ❌ | ❌ | ❌ | ❌ | ❌ |
ESP8266 | ❌ | ❌ | ✔️ | ✔️ | ❌ | ❌ | ✔️ | ✔️ | ❌ |
ESP32 | ❌ | ❌ | ✔️ | ✔️ | ❌ | ✔️ | ✔️ | ✔️ | ❌ |
STM32F103 | ❌ | ❌ | ✔️ | ✔️ | ❌ | ❌ | ❌ | ❌ | ✔️ |
Nucleo L053R8 | ❌ | ❌ | ❌ | ✔️ | ❌ | ❌ | ❌ | ❌ | ❌ |
Nucleo F401RE | ❌ | ❌ | ❌ | ✔️ | ❌ | ❌ | ❌ | ❌ | ❌ |
Teensy 3.1 | ❌ | ❌ | ✔️ | ✔️ | ❌ | ❌ | ❌ | ❌ | ❌ |
Raspberry Pi | ❌ | ❌ | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ❌ |
Windows X86 | ❌ | ❌ | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ❌ |
Linux | ❌ | ❌ | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ❌ |
Mac | ❌ | ❌ | ❌ | ✔️ | ❌ | ✔️ | ✔️ | ❌ | ❌ |
✔️ compatible - ❌ not compatible
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.
- Update PJON 12.x to 13.0
- Addressing
- Configuration
- Data reception
- Data transmission
- Error handling
- IO pins setup
- Routing
- ATtiny interfacing
- ESP8266 interfacing
- Nucleo interfacing
- Raspberry Pi interfacing
- WINX86 interfacing
- Troubleshooting