Saturday, July 13, 2019

433Mhz RF Communications using HT-12D/HT-12E

Introduction

I recently purchase several pairs of the 433Mhz RF Transmitter/Receiver modules from a vendor on ebay. They are very inexpensive and they use the Amplitude Ship Keying (ASK) protocol, which allows the developer to transfer data between the two devices wirelessly using RF. But very early on I realized that the communications I required for my project would be very simple, just a notification to turn a device on and off. During my research I found that the HT-12D/HT-12E encoder/decoder devices allow the transfer of 4 bits of data without one having to deal with the ASK protocol.

rf-pair

I created two boards, one for the encoder and one for the decoder so that I could test them and when done could mount them directly in my projects with minimal effort.

rf-pair

Both devices have an 8-bit address bus that can be set so that the devices don't interfere with existing devices, I set both device address lines low as they will be the only RF devices in the immediate area where they will be used.

It is very important that the resistor value for the encoder (HT-12E) be 1M and the decoder (HT-12D) be 51K on the oscillator lines. I struggled for a while on this because depending on which site you went to the tutorial said the value was critical but the values where different, so I had to try several before I found the value that corresponded to the device I had.

Listed below is a simple application to test the communications between devices. As I was debugging I used an oscilloscope and checked that the DOUT line on the encoder had a data burst and than moved to the decoder and made sure the burst showed up. As I was getting a burst at both ends I knew the data was getting through the RF devices and that my decoder wasn't working correctly. this is how I found out that I had the wrong resistor value on the decoder.

        
#define F_CPU 16000000UL

#include 
#include 

/* Replace with your library code */
int main()
{
    DDRC = 0x1f;
    PORTC = 0x10;

    volatile uint8_t mask = 1;

    while(1)
    {
        PORTC = mask;
        _delay_ms(500);
        PORTC |= (1 << PC4);

        mask = (mask << 1);

        if (mask == 0x10)
            mask = 1;
    }
}
        
    
Top ^