2017-06-26

This program comes with ABSOLUTELY NO WARRANTY.This is free software, and you are welcome to redistribute itunder certain conditions; GPLv3.

This is a proof of concept 433MHz ASK baseband decoder for messages sent byremote controls, weather stations, car keys and so on. It is written for Arduino,but the algorithm can run on anything that has GPIO IN with interrupt and amicrosecond time function.

You need a 433Mhz receiver. There are plenty of cheap receivers on the market [1].A good, compact antenna that I recommend is the DIY coil loaded antenna [2].

Connect the data out from the 433MHz receiver to digital 2 on Arduino. Uploadthis program using the Arduino IDE. Open a serial terminal set to 115200 bpsto start message reception. The output format is similar to homeduino [3],with a list of microsecond intervals followed by the message which consistsof indexes referencing the list.

Without an ongoing transmission, the receiver will pick up noise. We wantto ignore noise and only detect proper messages. A proper message consistsof a sequence of high/low signal pairs. The signals varies between 1 to Nperiods in length. A period is around 300 to 600 microseconds.

1_ _0_ | |_. = 11

1_ _0_ | |_._. = 12

1_ _._0_ | |_._._. = 23

...and so on.

A low signal that is longer than N periods is a sync. The high signal setsthe period time for the message. A sync is sent before and after a message.The sync signal can be shared by two adjacent messages, which means it marksboth the end of the first message and the start of the next.

1_ _0_ | |_._._._._._._._._._._._._._._._._._._._._._. = sync

When a sync signal is detected the message recording starts. As long as no signalhas a shorter duration than half a period, the reception continues until a new syncsignal is detected. There is a minimum length for a proper message and there isalso a minimum period time. This lowers the risk of interpreting noise as proper messages.

Incoming messages are written to a circular buffer by the interrupt routine. Ifthe reception buffer becomes full, the message being received is discarded. Whena complete message has been received the writer index is advanced to the positionafter the message and the main loop can start to consume the message using the readerindex. The first datum in the buffer is the period time in microseconds. The followingdata is the number of periods for all signals. The main loop transmits the message overthe serial port until (reader == writer) or until the number of periods of a datum islarger than N, which means that a new message starts.