Full documentation at
The receiver circuit is shown in the picture. The RC circuit acts a low-pass filter on the power to surpress spike noise and improve receiver performance. The RC circuit should be close to the receiver. The range with a 100 ohm resistor is at least 3 meters with the transmitter roughly pointing at the receiver, and a packet loss of less then 0.1 percent. To manage burst length limitations there is a short pause between characters, and only 7-bit characters are sent, with two stop bits. The 7-bit limit means that you can send all of the printing characters on the US keyboard, but no extended ASCII. All data is therefore sent as printable strings, NOT as raw hexidecimal.
Packet Format and error codes
A packet consists of :
- A start character, which defaults to '#', but can be changed with a define directive.
No other character in the packet is allowed to match the start character.
- A one-character transmitter id number which the receiver will check against a number it expects, when using
The transmitter id should be in the ASCII character range '0' to 'z' (ASCII 0x30 to 0x7a, excluding the two start/stop characters).
ir_rec_packetroutine will return error code 3 if the id does not match.
ir_rec_any_packetdoes not check the transmitter id, but returns the transmitter id (>=0x30) if the packet is valid and an error code if it is not valid.
- An arbitrary length, printable string (ASCII codes 0x20 to 0x7f, excluding the two start/stop characters), which of course, must fit into the size of the defined transmit/receive buffers.
- A one character checksum, which is calculated as the bitwise XOR of all the characters in the packet payload. The checksum is actually transmitted as two 4-bit values in the low 4 bits, ORed with 0x10 to form two 7-bit characters. This seemingly roundabout encoding was necessary to avoid burst length problems. A checksum mismatch will result in error code 4.
- An end character, which defaults to '%', but can be changed with a define directive.
No other character in the packet is allowed to match the end character.
- The receiving functions do not block, but just grab what is asynchronously built in the receive buffer.
An inconplete or missing packet at the time the receive function is called will result in error code 1.
- A buffer overrun will result in error code 2.
Loopback and point-to-point code is given on the page above.