RF communication between Arduinos

From ESE205 Wiki
Revision as of 03:11, 11 December 2017 by Nb275 (talk | contribs)
Jump to navigation Jump to search

Overview

Many people have sent communications between an arduino and another computer using a serial connection, perhaps in a course like CSE 132. Most people, though, do not have experience communicating wirelessly between arduinos using Radio Frequency technology. Let's dig in.

Materials

You will need:
-2 arduinos (most types will work, uno and mega definitely will)
-virtualWire library download (http://www.resistorpark.com/arduino-virtualwire-library-download/)
-RF Link Receiver (https://www.sparkfun.com/products/10532)
-RF Link Transmitter (https://www.sparkfun.com/products/10534)
-A breadboard
-Around 15 wires
-1 7V-12V power supply for arduino
-1 Serial connection for arduino

Setting up the transmitter

-connect the top pin on the transmitter to GND on arduino ('top' pin is the one farthest away from the 'ant' pin)
-connect second from top pin on transmitter to digital pin 12 on arduino
-connect third pin from top on transmitter to 5V power supply on arduino

Upload the following code to the arduino connected to the transmitter:

#include <VirtualWire.h>

char *controller;
void setup() {
pinMode(13,OUTPUT);
vw_set_ptt_inverted(true);
vw_set_tx_pin(12);
vw_setup(2400);// speed of data transfer Kbps }

void loop(){
controller="1" ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13,1);
delay(2000);
controller="0" ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13,0);
delay(2000);

}

Transmitterr.jpeg

Setting up the receiver

-connect GND on arduino to black command strip
-connect 5V on arduino to red command strip
-connect second pin from top on receiver to black command strip (top refers to where the receiver antenna is)
-connect third pin from top on receiver to black command strip
-connect fourth pin from top on receiver to red command strip

-connect fourth pin from bottom on receiver to red command strip
-connect second pin from bottom on receiver to digital pin 12 on arduino
-connect bottom pin on receiver to black command strip