At times, the desire arises to liberate data transmission from the confines of wires and allow it to traverse through the air. Astonishingly, achieving this isn't as complex as it may seem. With the aid of an affordable wireless transmitter-receiver pair, we can swiftly convert a conventional serial or software serial port into a wireless counterpart. These wireless modules are both economical and readily obtainable, offered in various frequencies and boasting effortless setup procedures. We'll leverage the code employed in the preceding guide, "Software Serial and UART between Arduinos," with the added twist of enabling serial communication over the airwaves. There is, however, a caveat to bear in mind: this approach exclusively permits unidirectional data transmission.
To prepare this dish, gather the following components:
- Two Arduinos
- Jumper cables
- A set containing one RF link transmitter and one RF link receiver.
Here are the steps to establish a wireless connection between two Arduino UNOs using Software Serial:
- For both Arduinos, designate pins 8 and 9 as RX and TX. Connect pin 9 on the master Arduino to the DATA pin on the transmitter module.
- Attach pin 8 on the slave Arduino to the DATA pin on the receiver module.
- Link the ground (GND) and 5V of the transmitter to the master Arduino.
- Likewise, link the ground (GND) and 5V of the receiver to the slave Arduino.
- Utilize the identical code as outlined in the previous recipe for Software Serial communication and UART interaction between the two Arduinos.
Arduino Wireless Serial Circuit Diagram
The following diagram illustrates a setup employing pins 8 and 9 for RX and TX, where the transmitter is connected to the master Arduino, and the receiver is connected to the slave Arduino:
How it works?Setting up and utilizing the RF Link Transmitter Receiver pair is straightforward and user-friendly. In essence, the transmitter emits a radio signal corresponding to the input received on the DATA pin. Similarly, the receiver transmits whatever it picks up. The baud rate is not a significant concern, as long as it remains sufficiently slow.
This type of wireless communication is particularly vulnerable to interference from noise. It is advisable to opt for very low baud rates—such as 9,600 or even 4,800—as suitable options. Additionally, the level of noise increases with greater distances. To counteract this issue, once again, reducing the baud rate can be an effective strategy.
There is an additional option available. By employing two sets of RF Links operating at distinct frequencies, we can establish a two-way system. Should the frequencies not differ, a complete interference will occur, causing both the master and slave Arduinos to simultaneously capture the transmissions from each other.