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
- Provided Functions
- Arduino Implementation
- Python Implementation
- C Implementation
- Rust Implementation
- Real Life Example
- Acknowledgments
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 intread_i16()
: Read one byte from a file/serial port and convert it to a 16 bits intread_i32()
: Read one byte from a file/serial port and convert it to a 32 bits intwrite_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.
Open arduino-board/slave/slave.ino
in your Arduino IDE.
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 repository: https://github.com/araffin/python-arduino-serial
C++ repository: https://github.com/araffin/cpp-arduino-serial
Rust repository: https://github.com/araffin/rust-arduino-serial
This protocol was used on the Racing Robot: https://github.com/sergionr2/RacingRobot
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.