Skip to content

A simple and robust serial communication protocol. It was designed for Arduino but can be used for other purposes (e.g. bluetooth, sockets). Implementation in C Arduino, C++, Python and Rust.

License

Notifications You must be signed in to change notification settings

araffin/arduino-robust-serial

Folders and files

NameName
Last commit message
Last commit date
Jun 8, 2019
Apr 7, 2018
Apr 10, 2023
Apr 23, 2018
Apr 10, 2023
Apr 6, 2018
Apr 5, 2018
May 27, 2018
Jun 10, 2018

Repository files navigation

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.

About

A simple and robust serial communication protocol. It was designed for Arduino but can be used for other purposes (e.g. bluetooth, sockets). Implementation in C Arduino, C++, Python and Rust.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published