{"id":20280002,"url":"https://github.com/yesbotics/simple-serial-protocol-arduino","last_synced_at":"2026-01-04T17:49:14.378Z","repository":{"id":75142271,"uuid":"580471423","full_name":"yesbotics/simple-serial-protocol-arduino","owner":"yesbotics","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-23T11:07:52.000Z","size":136,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-29T04:41:26.636Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yesbotics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-20T16:37:13.000Z","updated_at":"2024-09-09T03:37:39.000Z","dependencies_parsed_at":"2024-05-11T21:26:41.056Z","dependency_job_id":"d8578f9e-841a-45d0-846a-9fd1e42526f1","html_url":"https://github.com/yesbotics/simple-serial-protocol-arduino","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-arduino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-arduino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-arduino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-arduino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yesbotics","download_url":"https://codeload.github.com/yesbotics/simple-serial-protocol-arduino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245168899,"owners_count":20571804,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T13:34:03.561Z","updated_at":"2026-01-04T17:49:14.350Z","avatar_url":"https://github.com/yesbotics.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Serial Protocol for Arduino\nProvides easy and robust general purpose serial communication between PC side applications and \nArduino(-compatible) devices. This lib is the Arduino implementation of [Simple Serial Protocol].\n\n## Requirements\nArduino 1.5+ Environment\n* Use the [Arduino-IDE]\n* or enjoy advantage of using Arduino via command-line interface: [Arduino-CLI (arduino-cli)]\n\n## Install this Arduino library\n### Via Arduino IDE's built-in Library Manager \n`Menu -\u003e Tools -\u003e Manage Libraries... -\u003e search for: SimpleSerialProtocol -\u003e choose latest version -\u003e install`\n### Via Arduino CLI's lib command\n`arduino-cli lib install SimpleSerialProtocol`\n### Manual method (Arduino IDE and Arduino CLI)\nCopy this repo folder into your arduino libraries location, and rename it to `SimpleSerialProtocol`. \nYour Arduino libraries folder depends on your operating system (and maybe custom path settings). Default path is:\n#### Windows 7/8/10:\n`C:\\Users\\\u003cusername\u003e\\Documents\\Arduino\\libraries\\`\n#### Linux\n`/home/\u003cusername\u003e/Arduino/libraries/`\n#### macOS\n`/Users/\u003cusername\u003e/Documents/Arduino/libraries/`\n\n## Usage example (echo_example sketch)\nThis example receives values of each supported datatype and sends them back immediately. \n\n```c++\n#include \u003cSimpleSerialProtocol.h\u003e\n\n// declare callbacks (this is boilerplate code but needed for proper compilation of the sketch)\nvoid onError(uint8_t errorNum);\nvoid onReceivedValues();\n\n// inintialize hardware constants\nconst long BAUDRATE = 9600; // speed of serial connection\nconst long CHARACTER_TIMEOUT = 500; // wait max 500 ms between single chars to be received\n\n// initialize command constants\nconst byte COMMAND_ID_RECEIVE = 'r';\nconst byte COMMAND_ID_SEND = 's';\n\n// Create instance. Pass Serial instance. Define command-id-range within Simple Serial Protocol is listening (here: a - z)\nSimpleSerialProtocol ssp(Serial, BAUDRATE, CHARACTER_TIMEOUT, onError, 'a', 'z'); // ASCII: 'a' - 'z' (26 byes of RAM is reserved)\n\n// Aternatively you can create an instance of SoftwareSerial\n// https://www.arduino.cc/en/Reference/SoftwareSerial\n// #include \u003cSoftwareSerial.h\u003e\n// SoftwareSerial swSerial(2, 3); // RX, TX\n// SimpleSerialProtocol ssp(swSerial, BAUDRATE, CHARACTER_TIMEOUT, onError, 'a', 'z');\n\nvoid setup() {\n    // prepare LED and set it off\n    pinMode(LED_BUILTIN, OUTPUT);\n    digitalWrite(LED_BUILTIN, LOW);\n\n    // init ssp. ssp is calling 'Serial.begin(9600)' behind the scenes\n    ssp.init();\n    // if message command with 'r' is received, the given callback will be called\n    ssp.registerCommand(COMMAND_ID_RECEIVE, onReceivedValues);\n}\n\nvoid loop() {\n    // polling for available bytes\n    ssp.loop();\n}\n\n// callbacks implementation\nvoid onReceivedValues() {\n\n    //\n    // Receive Data\n    //\n    byte byteValue = ssp.readByte(); // Arduino's byte: https://www.arduino.cc/reference/en/language/variables/data-types/byte/\n    bool booleanValue = ssp.readBool();\n    int8_t tinySignedInt = ssp.readInt8();\n    uint8_t tinyUnsignedInt = ssp.readUnsignedInt8();\n    int16_t smallSignedInt = ssp.readInt16();\n    uint16_t smallUnsignedInt = ssp.readUnsignedInt16();\n    int32_t signedInt = ssp.readInt32();\n    uint32_t unsignedInt = ssp.readUnsignedInt32();\n    int64_t bigSignedInt = ssp.readInt64();\n    uint64_t bigUnsignedInt = ssp.readUnsignedInt64();\n    float floatValue = ssp.readFloat();\n    char charValue = ssp.readChar();\n\n    // string is special, because of its variable length (overall maximum size is 255, means 254 characters text length)\n    // performance note: in this example 50 bytes of Arduino's RAM is used - each time you read a string\n\n    // max. 49 chars length, 1 byte is reserved for end of string byte\n    const uint8_t stringBufferSize = 50;\n\n    // you can interpret strings as\n    // Arduino's String Object https://www.arduino.cc/reference/en/language/variables/data-types/stringobject/\n    String text1 = ssp.readString(stringBufferSize);\n\n    // or as a plain char array / c-string\n    char text2[stringBufferSize]; // create buffer char array\n    ssp.readCString(text2, stringBufferSize); // read chars from stream, fill buffer\n\n    // again an Arduino String Object\n    // this time without custom maximum length\n    // max. 254 chars length, 1 byte is reserved for end of string byte\n    String text3 = ssp.readString();\n\n    ssp.readEot(); // read and expect the end-of-transmission byte. important, don't forget!\n\n    //\n    // Immediately send back all received and interpreted values\n    //\n    ssp.writeCommand(COMMAND_ID_SEND); // start command with command id\n\n    ssp.writeByte(byteValue);\n    ssp.writeBool(booleanValue);\n    ssp.writeInt8(tinySignedInt);\n    ssp.writeUnsignedInt8(tinyUnsignedInt);\n    ssp.writeInt16(smallSignedInt);\n    ssp.writeUnsignedInt16(smallUnsignedInt);\n    ssp.writeInt32(signedInt);\n    ssp.writeUnsignedInt32(unsignedInt);\n    ssp.writeInt64(bigSignedInt);\n    ssp.writeUnsignedInt64(bigUnsignedInt);\n    ssp.writeFloat(floatValue);\n    ssp.writeChar(charValue);\n    ssp.writeString(text1);\n    ssp.writeCString(text2);\n    ssp.writeString(text3);\n\n    ssp.writeEot(); // end command with end-of-transmission byte. important, don't forget!\n}\n\nvoid onError(uint8_t errorNum) {\n    digitalWrite(LED_BUILTIN, HIGH);\n}\n```\n\nIn this example, the text buffer is limited to 50 chars: `const int maxStringLength = 50;`.\nMeans **49** chars maximum text length. \nAmount of 49 characters should not be exceeded because \n1 byte is reserved for end-of-string byte.\n\nThis example can be found as Arduino sketch within the `simple-serial-protocol-arduino/examples/echo_example` folder.\nIt corresponds with Node.js echo example at [Simple Serial Protocol for Node.js].\n\n## HardwareSerial and SoftwareSerial support\nJust use [Serial (HardwareSerial)] (recommended) or [SoftwareSerial Library].\nBoth libs are based on [Arduino's Stream implementation].\n\n## Arduino-CLI (arduino-cli) support \nWe primarily compile and upload our Arduino sketches with [Arduino-CLI (arduino-cli)].\nThat project is great stuff. Fresh stuff.\n\n## Limitations\nArduino device's memory is low.\nReceiving long strings needs memory (1 byte per char) because of buffering every single character. \nKeep this in mind.\nFlagships like Arduino Uno or Arduino Nano are powered by the [ATmega328P]), \nwhich are restricted to 2,048kB of internal memory. \n\n## Links\n[Simple Serial Protocol]:https://github.com/yesbotics/simple-serial-protocol-docs\n[Simple Serial Protocol for Node.js]:https://github.com/yesbotics/simple-serial-protocol-node\n[Serial (HardwareSerial)]:https://www.arduino.cc/reference/en/language/functions/communication/serial/\n[SoftwareSerial Library]:https://www.arduino.cc/en/Reference/SoftwareSerial\n[Arduino's Stream implementation]:https://www.arduino.cc/reference/en/language/functions/communication/stream/\n[Arduino-IDE]:https://www.arduino.cc/en/main/software\n[Arduino-CLI (arduino-cli)]:https://github.com/arduino/arduino-cli\n[ATmega328P]:https://www.microchip.com/wwwproducts/en/ATmega328p\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyesbotics%2Fsimple-serial-protocol-arduino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyesbotics%2Fsimple-serial-protocol-arduino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyesbotics%2Fsimple-serial-protocol-arduino/lists"}