Computing stuff tied to the physical world

Wireless at 433 MHz

In AVR, Hardware on Nov 29, 2008 at 01:03

This was an experiment to learn about low-power / low-range wireless communication using a 433 Mhz transmitter / receiver set from Conrad. The transmitter was tied to an RBBB board and accessed via an FTDI-USB cable:

22545025-0C64-4DBE-9519-A1CC31BB8891.jpg

The receiver was mounted on a proto shield with breadboard, on top of a standard Arduino:

F5812B9B-C1D7-41EF-AD8F-E66AC4BE54A1.jpg

The software for this requires some attention due to the crude communication system.

Basically, the transmitter is turned on and off by a serial bit stream, i.e. this is not FM or even AM, just the presence and absence of a signal. To make this work properly and get say 20 bytes of data across, you have to go through the following sequence:

  • turn on the signal for a few milliseconds so the receiver adjust its AFC (assuming it has one)
  • send a unique bit pattern so the receiver can synchronize to receive data as individual bytes
  • send the data bytes, i.e. the “payload”
  • send a 2-byte CRC so the receiver can verify proper reception
  • turn off the signal for at least a few dozen milliseconds to avoid hogging the radio channel
  • re-send the whole packet one or more times to deal with interference and collisions

Even then, correct reception is not guaranteed – that would require a transceiver setup with two-way acknowledgement.

Data is sent using Manchester code, a phase change trick which keeps the on and off times equal, on average. The signalling rate is only 1000 baud (i.e. 1 millisecond per bit) and even then the error rate is quite substantial.

The CRC is calculated via standard code from the avr-libc library. A little trick is used to simplify the code: when the two CRC bytes are appended in little-endian format, the receiver can calculate its CRC including these bytes and verify that the result is zero.

The C test code is in the download area – for both the transmission and the reception version. It uses busy loops for (rough) timing. An interrupt-driven version using one of the 168’s hardware counters would have been preferable, to generate a jitter-free signal and to be able to handle other tasks during reception.

The results indicate that the transmitter really needs an external antenna wire to cross more than a meter (!) or so of air. With antenna, the signal barely makes it through one (reinforced) concrete wall in the house, which is insufficient for my purposes, but an 868 MHz version will probably overcome this limitation.