Awesome Open Source
Awesome Open Source

Robust Arduino Serial Protocol

Robust Arduino Serial is a simple and robust serial communication protocol. It was designed to make two Arduinos communicate, but can also be useful when you want a computer (e.g. a Raspberry Pi) to communicate with an Arduino.

Please read the Medium Article to have an overview of this protocol.

Implementations are available in various programming languages:

Examples are provided in each repository.

To clone all the repositories at once, tou need to use the --recursive command:

git clone https://github.com/araffin/arduino-robust-serial.git --recursive

Table of Contents

Provided Functions

Please check examples in the different repos to have the parameters details for each programming language.

  • read_order(): Read one byte from a file/serial port and convert it to an order (equivalent to read_i8)
  • read_i8(): Read one byte from a file/serial port and convert it to a 8 bits int
  • read_i16(): Read one byte from a file/serial port and convert it to a 16 bits int
  • read_i32(): Read one byte from a file/serial port and convert it to a 32 bits int
  • write_order(): Write an order to a file/serial port. (equivalent to write_i8)
  • write_i8(): Write one byte int to a file/serial port.
  • write_i16(): Write two bytes (16-bits) int to a file/serial port.
  • write_i32(): Write four bytes (32-bits) int to a file/serial port.

Arduino Implementation

1. Using Arduino IDE

Open arduino-board/slave/slave.ino in your Arduino IDE.

2. Using Arduino Makefile (Recommended)

This method only works with Linux/Mac Os systems: https://github.com/sudar/Arduino-Makefile

Install Arduino Makefile.

sudo apt-get install arduino-mk

Compile and upload the code to the Arduino (please check the board name in the Makefile):

cd arduino-board/
make
make upload

Python Implementation

Build Status

Python repository: https://github.com/araffin/python-arduino-serial

C++ Implementation

Build Status

C++ repository: https://github.com/araffin/cpp-arduino-serial

Rust Implementation

Build Status Build status

Rust repository: https://github.com/araffin/rust-arduino-serial

Real Life Example

This protocol was used on the Racing Robot: https://github.com/sergionr2/RacingRobot

The racing robot

Acknowledgments

I would like to thanks Dara Ly for the original idea of communicating with the Arduino via a command parser, and Xuan Zhang for fixing Arduino limited buffer issue.


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
python (50,901
c-plus-plus (17,662
c (14,530
rust (4,316
cpp (1,249
arduino (707
raspberry-pi (609
protocol (186
bluetooth (174
communication (81
serial (57
sockets (35

Find Open Source By Browsing 7,000 Topics Across 59 Categories