

The following table illustrates the protocol we’re going to use: Validation gives us assurance that the data we receive is not corrupted (sometimes by unknown causes we might have data corruption, for example: a bit value changes by electromagnetic effects in the transmission line, the color might change dramatically by this cause). Every package we send/receive will have a length of 5 bytes.

We also require a header to identify the protocol, and optional but extremely suggested is the use of a checksum byte as a validation method, this gives us a protocol with a fixed value of 5. Our protocol needs to implement a minimum of 3 bytes (1 byte equals 8 bits) to contain color data in RGB format.

So… the RGB format defines a 24 bit color. First we need to understand the Red Green Blue color format, for each component we have a possible value between 0 – 255, meaning that each component has a resolution of 8 bits. Let’s create a protocol to send color information to a microcontroller in RGB format, with the goal of controlling a RGB Led. Creating one it’s not complicated, the easiest protocol is just a fixed length data sequence that provides a known header. It becomes clear that if we want to transmit complex data, we have to conform with a protocol or create one. For example, the TCP protocol is defined as: Some protocols define fixed data length, others more complicated are designed for variable data length. We can’t just send data bytes and hope someone understand them. We have by example TCP and UDP protocols, which are the basis of internet data exchange.Ī communication protocol consists of a well designed data pattern. Sending and receiving multiple bytes of information efficiently between microcontrollers, sensors or computers requires the design of a communication protocol.
