Giter Site home page Giter Site logo

lakrits's Introduction

#lakrits - a tiny communications protocol. Suitable for AVR and other microcontrollers with limited memory.

##Features

  • 16 bit addressing
  • 16 bit message type
  • LRC error checking
  • 64 byte payload per message

Example implementations are available for Arduino and Ruby.

##Specification

Several lakrits devices can be connected simultaneously over a wireless connection like XBee (Series 1 and 2). In theory the devices could be connected electrically, but more effort would have to go into avoiding data collision and better error handling since the XBee does a lot of this for you. The current implementation of the protocol assumes a star topology and can only send messages back and forth between the server and the devices.

A lakrits device send and receive messages. A message is transferred in the form of a packet. A packet consist of a header, a payload and a trailer. The header is divided into 8 bytes and contains the "start of transmission" byte, addressing, message type and payload length. The payload begins directly after the header and continues as defined by the payload length value. After the payload, the trailer follows with a LRC checksum that is calculated over all the bytes between STX and the end of [payload]. The LRC checksum is followed by a "end of transmission" byte.

[STX 0x02			]	Start of transmission.
[recipient id low	]	The low 8 bits of the receiving device id.
[recipient id high	]	The high 8 bits of the receiving device id.
[sender id low		]	The low 8 bits of the transmitting device id.
[sender id high		]	The high 8 bits of the transmitting device id.
[message type low	]	The low 8 bits of the message type.
[message type high	]	The high 8 bits of the message type.
[payload length		]	Indicates the number of bytes in the payload.
[payload			]	The payload can be up to 64 bytes long.	
...						
...
...
[LRC Checksum		]	
[ETX 0x03			]	End of transmission.

##Why?

I created lakrits to power my home automation system. I needed a reliable way of transmitting tiny messages between a server and a lot of sensors and actuators. At the time I needed to concentrate on the harder problem of designing the automation system and various ways of controlling it, so I decided to stick to the minimal requirements and create the messaging protocol myself.

I learnt a lot about serial communication while building this and the system has been running almost flawlessly for over a year, so I figured I'll make it available in case anyone is on the same journey as I was.

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.