Skip to content

Lightweight master-slave serial protocol for remote Arduino GPIO control from a Python host

License

Notifications You must be signed in to change notification settings

The90Frank/SimpleSerialProtocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleSerialProtocol

A lightweight master-slave serial communication framework for remote GPIO control of Arduino boards from a Python host. Implements a request-response paradigm where the Master delegates commands to Slave microcontrollers over serial.

TODO: add polling or multiplexing to use a single serial port for multiple Slaves.

Protocol

Request packet (4 bytes)

Command PinNumber PinValue CheckSum
R/W/r/w id of pin to use value to set (ignored on read) (Command XOR PinNumber) XOR PinValue

Response packet (3 bytes)

PinNumber PinValue CheckSum
id of pin used value set/read PinNumber XOR PinValue

Commands

Command Description
R Digital READ (returns 0 or 1)
W Digital WRITE (HIGH/LOW)
r Analog READ (returns 0-255, scaled from 10-bit ADC)
w Analog WRITE (PWM, 0-255)

Project structure

SimpleSerialProtocol/
├── SimpleSerialMaster.py        # Python master with interactive CLI
└── SimpleSerialSlave/
    └── SimpleSerialSlave.ino    # Arduino slave firmware

Usage

Upload SimpleSerialSlave.ino to an Arduino board, then run the master:

python SimpleSerialMaster.py

The interactive CLI prompts for command, pin number, and value. Communication runs at 9600 baud on /dev/ttyACM0.

Dependencies

  • Master: Python 3, pyserial, pyinputplus
  • Slave: Arduino IDE

License

Apache License 2.0 - see LICENSE for details.

About

Lightweight master-slave serial protocol for remote Arduino GPIO control from a Python host

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors