Giter VIP home page Giter VIP logo

embed / arduino-serial-messaging Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeroendoggen/arduino-serial-messaging

0.0 1.0 0.0 1.46 MB

Library to exchange short messages (sensordata, commands) between an Arduino and a software application running on a PC. (Linux, embedded Linux, Windows, OS X)

License: GNU General Public License v2.0

C# 20.76% C++ 13.46% Ruby 2.16% Processing 1.91% Shell 5.35% Python 52.53% C 0.54% Arduino 3.29%

arduino-serial-messaging's Introduction

Library to exchange short messages (sensordata, commands) between an Arduino and a software application running on a PC. (Linux, embedded Linux, Windows, OS X) (clients currently under development)

Both sides are able send and receive a range of "standardised" messages over the serial port. All communication is done by sending short human readable ASCII messages. We define several standard command and data packet IDs to provide interoperability between different applications.

The protocol was designed to be relatively easy to comprehend and process by both human and computer.

  • A standardised message structure (more info below)
  • All fields in a message are separated by delimiters (just a letter indicating what the next field will be)
  • All communication is in HEX ASCII values (to allow human and computer to understand the packets)
  • Invalid messages are detected by calculating the parity (XOR all serial bytes)

The Message Types

The library support seven basic packet types.

  • "Command": start motor, blink LED, go to sleep mode,...
  • "Command Reply": e.g. motor started, LED blinking, going to sleep mode now,...
  • "8-bit Data": (standard Arduino Byte type): e.g. temperature is 25 C, distance is 50 cm, humidity is 56%
  • "16-bit Data": (standard Arduino int type): e.g. temperature is -25 C, distance is 310 cm, time is 16200 seconds, ...
  • "Data array": send multiple sensor measurements in one burst (useful when sampling very rapidly)
  • "Data request": e.g. send me the temperature, distance, humidity, ...
  • "Data array request": e.g. send me a burst of measurements

More info in defines.h

Standard Messages

Data messages are used when we want to send sensor data from the Arduino to applications running on a PC. More info

Command messages are used when we want to send instructions from one application to the Arduino module. More info

We define several standard command and data message IDs. The actual meaning of the payload of these messages is standardised to provide interoperability between different applications (00h -> 7Fh). Half of the packet IDs are undefined (80h -> FFh). These IDs can be chosen based on the needs of your own application.

Example Messages

Command message T01N00I12PFFQ21 : "set motor speed of 'Arduino zero' to +100%:

  • T01: Type 01: Command message
  • N00: Number 00: Node number 00 (is the destination)
  • I12: CommandID 12: Set motor speed
  • PFF: Payload FF: full speed (range: 0 (reverse) -> 80 (stopped) -> FF (forward))
  • Q21: Quality 21: parity byte is 21

Data message T12N00I10P08Q0A : "temperature of 'Arduino zero' is 8 degrees"

  • T12: Type 12: Data message (1 byte payload)
  • N00: Number 00: Node number 00 (is the source)
  • I10: SensorID 10: Temperature
  • P08: Payload 08: 8 degrees
  • Q0A: Quality 0A: parity byte is 0A

Sending Messages from Arduino Code

  • sendCommand(commandID,payload)

  • sendCommandReply(commandID,payload)

  • sendData(sensorID,payload)

  • sendDataRequest(sensorID,payload)

  • sendDataArray(sensorID,payload)

  • sendDataArrayRequest(sensorID,payload)

Example sketch: SendPackets.ino

PC Clients

arduino-serial-messaging's People

Contributors

jeroendoggen avatar krmaxwell avatar timdams avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.