RF Transceiver using ASK module and Arduino
A Transceiver is a device that can both transmit and receive messages in half-duplex or full-duplex communication mode. In a half-duplex device, it can only either transmit or receive the data at a time whereas a full-duplex can transmit in both directions at the same time.
A single pair of transmitter and receiver can work as a simplex communication that can only send data in one direction. By using another pair of the same Tx and Rx modules in a simplex communication it can be converted to a half-duplex communication.
In a simplex communication, unit A has a transmitter (Tx) and B has a receiver (Rx). In half-duplex both A and B has transmitter and receiver circuit. Now the two transceiver units can transmit and receive the message in either one of the directions at a time.
Here in the circuit, a 433mhz RF ASK (Amplitude shift keying) module is used for RF communication. The data pin of the transmitter and receiver module is connected to the digital pin 12(Tx) and 11(Rx) of the Arduino respectively.
Refer ASK module RF Transmitter and Receiver for ASK module interfacing with Arduino, library installation, simplex Tx & Rx Arduino code.
The code uses serial communication to Read and write the message. Upload the same code in both transceiver units to send and receive the data wirelessly between serial terminals of two separate computers.
Code
#include <RH_ASK.h> #include <SPI.h> RH_ASK driver; char msgstring[32]; 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'); } if (Serial.available() > 0) { delay(50); memset(msgstring, 0, sizeof(msgstring)); int j = 0; while (Serial.available() > 0) { msgstring[j] = Serial.read(); j++; } char *msg = msgstring; driver.send((uint8_t *)msg, strlen(msg)); driver.waitPacketSent(); delay(200); } }
Separate serial terminals in the same PC can be used for testing purpose. For that additional serial terminal like putty, hyper terminal, termite, etc can be used to send data from one port and receive at another port.