Sometimes created projects require a wireless connection. One of the simplest and budget solutions for the organization of simplex (one-way) communication is the use of radio modules with a frequency of 433 MHz. In this article, we will analyze a simple example of their use in conjunction with Arduino.
To implement the project from this article, we need the following components:
- Arduino Nano V3
- 433Mhz receiver and transmitter kit
- Jumper wires kit
For these modules to work, you need to solder an antenna to each of them, the recommended length is 17 cm. The operating voltage is up to 12 volts, but the 5-volt Arduino output is enough.
The range of work is directly dependent on the magnitude of the voltage.
It is worth noting that in cities, the communication range can be reduced due to the clogged frequency of 433 MHz – some signaling systems, radios, etc. work on this frequency.
Also, when using these modules with Arduino, there is one unpleasant moment – the impossibility of working with servo drives through the “Servo” library. The problem is solved using the library “ServoTimer2“.
So, the antenna is soldered, proceed to connect the modules. VCC of both modules is connected to 5v, GND to the Arduino terminal of the same name. You can power them from an external high-voltage power supply to increase the range.
To the 12th output of the transmitting board, we connect the DATA terminal of the transmitter, to the 11th output of the receiving board – either of the two DATA outputs of the receiver.
Next, we need to download the VirtualWire library:
CODE FOR 433 MHz TRANSMITTER
After that we connect the transmitting board to the computer and load the following sketch into it:
int number = 123;
char symbol = ‘c’;
String strMsg = “z “;
strMsg += symbol;
strMsg += ” “;
strMsg += number;
strMsg += ” “;
vw_send((uint8_t *)msg, strlen(msg));
A little bit about what this sketch is doing. We will send an strMsg variable of type String with the vw_send command. It is easier to work with this type, but before sending it you need to convert it to an array of characters with the toCharArray command.
All modules operate in the same range, so the receiver will receive data from all transmitters. To prevent receiving extra information, at the beginning of the transmitted message will record a prefix, for example, “z”.
The next part of the message is to send the “c” symbol, which can symbolize the end of the execution of any operation or a signal to the command execution by the receiver, and the number “123”, symbolizing its parameter.
CODE FOR 433 MHz RECEIVER
It is the turn of the receiver. Load the following sketch:
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))
if (buf != ‘z’)
char command = buf;
i = 4;
int number = 0;
while (buf[i] != ‘ ‘)
number *= 10;
number += buf[i] – ‘0’;
First, Arduino reads the message in the buf buffer. Secondly, it will check the presence of the prefix “z”, in its absence the message will not be parsed. Third, it considers the “c” command and converts the character set to the number “123”. Fourth, Arduino will output the received information to the serial port. For more understanding in the sketch there are comments.
With the help of these sketches, you can only check the work of the radio modules. But they are not difficult to modify to transmit useful data, for example, the organization of remote control.