Home Code A 433Mhz transmitter and receiver module for an Arduino

A 433Mhz transmitter and receiver module for an Arduino

by shedboy71

In this article we look at a pair of modules that can be used for communication between 2 Arduino's. These are a 433Mhz transmitter and receiver module

The kit includes one pair of transmitter and receiver modules and one pair of spring antennas for increasing the communication distance. And the frequency is 433MHz. It is very popular for remote control systems, such as wireless doorbell, remote control rolling gates, smart car, smart home, etc.

In the image below you can see the 2 modules in question, you simply need to supply these with VCC, Gnd and a signal pin.

About the transmitter module

– Compatible with Arduino
– Working voltage: 4 – 12VDC
– Working current: 40mA
– Transmit power: 27dBm@12V (large power)
– Working frequency: 433MHz
– Transfer rate: 4.8kbps (max)
– Transmission distance: When supply power is 5V, the open area transmission distance can be increased to 150 meters.
– Antenna: Onboard 433MHz dedicated PCB Antenna.

About the receiver module (rectangle shape):

– Compatible with Arduino
– Operating voltage: 2 – 5.5VDC
– Working frequency: 433MHz
– Working Current: 2mA
– Sensitivity: -110db
– Antenna: Onboard 433MHz dedicated PCB Antenna

Parts

You will need 2 Arduino's – one for the transmitter and one to be the receiver. I used 2 Arduino Uno's in testing

Name Link
Arduino UNO Arduino UNO R3
433mhz modules Long Range 433MHz RF Wireless Transceiver Kit with Antenna
Connecting area Cable Dupont Jumper Wire Dupont 30CM

Code

The code needs the virtualwire library to be installed, we have this in the download below

VirtualWire

Here is the receiver part of the code

[codesyntax lang=”cpp”]

#include <VirtualWire.h>

int RF_RX_PIN = 11;//connect the sent module to D11 to use
//you can change it to the idle port you want.

void setup()
{
Serial.begin(9600);
Serial.println(“setup”);
vw_set_rx_pin(RF_RX_PIN); // Setup receive pin.
vw_setup(2000); // Transmission speed in bits per second.
vw_rx_start(); // Start the PLL receiver.
}

void loop()
{
String comdata = “”;
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if(vw_get_message(buf, &buflen)) // non-blocking I/O
{
int i;
// Message with a good checksum received, dump HEX
Serial.print(“Got: “);

for(i = 0; i < buflen; ++i)
{
comdata += (char)buf[i];
//Serial.print(” “);
//Serial.print(buf[i]);
}
Serial.print(comdata);
Serial.println(“”);
}
}

[/codesyntax]

 

And now for the transmit test example

[codesyntax lang=”cpp”]

#include <VirtualWire.h>

int RF_TX_PIN = 12;//connect the transmit module to D12

void setup()
{
Serial.begin(19200);
vw_set_tx_pin(RF_TX_PIN); // Setup transmit pin
vw_setup(2000); // Transmission speed in bits per second.
}
unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0; // counter for buffer array

void loop()
{
if (Serial.available()) // if date is comming from softwareserial port ==> data is comming from gprs shield
{
while(Serial.available()) // reading data into char array
{
buffer[count++]=Serial.read(); // writing data into array
if(count == 64)break;
}
vw_send(buffer, count); // Send ‘hello' every 400ms.
clearBufferArray(); // call clearBufferArray function to clear the storaged data from the array
count = 0;

}

// const char *msg = “hello”;
// vw_send((uint8_t *)msg, strlen(msg)); // Send ‘hello' every 400ms.
delay(400);

}
void clearBufferArray() // function to clear buffer array
{
for (int i=0; i<count;i++)
{ buffer[i]=NULL;} // clear all index of array with command NULL
}

[/codesyntax]

Share

You may also like

Leave a Comment