ASK 433Mhz RF Transmitter and Receiver using Arduino

A 433MHz RF Transmitter (FS1000A) and Receiver (XY-MK-5V) module is a simple low-cost RF module that is very useful for short-distance wireless communication, remote controls, etc. It can transmit up to a range of around 100 meters with proper transmitter and receiver antennas.

The FS1000A / XY-MK-5V RF module works by Amplitude shift keying which is a digital modulation technique that represents serial binary data as variations in the amplitude of a carrier wave. That is, it simply turns ON and OFF a carrier wave of the constant frequency with respect to the binary input state 1 and 0.

Various libraries are available for serial communication using the ASK RF 433MHZ module and Arduino. Here we use a library called Radiohead which is one of the most widely used Arduino libraries for Rf 433MHZ.

Download the library  https://github.com/PaulStoffregen/RadioHead or https://www.airspayce.com/mikem/arduino/RadioHead and install it, Sketch > Include Library > Add .ZIP Library.

Both Tx and Rx modules work with 5V supply. Connect the Vcc of the modules to +5V and the GND to the GND of the arduino.

Transmitter

The data pin of the transmitter (FS1000A) needs to be connected to the digital pin 12 of the Arduino.

ask-FS1000A-433mhz-arduino-transmitter

Here in the below transmitter code, the message repeatedly sends as long as the circuit is powered ON.

Code

#include <RH_ASK.h>
#include <SPI.h>

RH_ASK driver;

void setup()
{
 driver.init();
}

void loop()
{
    const char *msg = "hello";
    driver.send((uint8_t *)msg, strlen(msg));
    driver.waitPacketSent();
    delay(200);
}

The below circuit and code are the same as the above, but modified with an additional switch so as to make the circuit to send the message only when the push switch is pressed.

ask rf 433mhz transmitter switch control

Code – Transmitter with switch control

#include <RH_ASK.h>
#include <SPI.h>

const int push_switch = 3;
int state = 0;
RH_ASK driver;

void setup()
{
  driver.init(); 
  pinMode(push_switch, INPUT);
}

void loop()
{
  if (digitalRead(push_switch) == HIGH && state == 1) {
    const char *msg = "hello";
    driver.send((uint8_t *)msg, strlen(msg));
    driver.waitPacketSent();
    delay(200);
    state = 0;
  }
  else if (digitalRead(push_switch) == LOW) {
    state = 1;
  }
}

Receiver

In the circuit, the data pin of the receiver module (XY-MK-5V RF) needs to be connected to the digital pin 11 of the Arduino.

XY-MK-5V RF receiver module ASK 433mhz

The received message can be displayed at the serial terminal at the respective communication port.

Code

#include <RH_ASK.h>
#include <SPI.h>

RH_ASK driver;

void setup()
{
  Serial.begin(9600);
  driver.init();
}

void loop()
{
  uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
  uint8_t buflen = sizeof(buf);

  if (driver.recv(buf, &buflen))
  {
    for (int i = 0; i < buflen; i++) {
      Serial.write(buf[i]);
    }
    Serial.write('\n');
  }
}

The exact code required to operate successfully varies with the library and its versions, refer to the example code given in the installed library.

2 Responses

  1. JORGE CHACON says:

    could you share the fritzing libraries you used?

Leave a Reply

Your email address will not be published. Required fields are marked *