Go Down

Topic: Rf Communication with VirtualWire/Uno (Read 105 times) previous topic - next topic

andehlu

Mar 31, 2015, 12:23 am Last Edit: Mar 31, 2015, 12:27 am by andehlu
Hi all,

I am trying to get two Arduino UNO to talk using 315Mhz Rf transmitter/receivers. I am using VirtualWire lib and everything almost seems to be working. My transmitter says that messages are getting sent but I cant seem to receive them.

Code and pics of the setup below. Anyone have any thoughts?

Transmitter:

Code: [Select]

#include <VirtualWire.h>

const int transmit_pin = 12;

void setup(){
  Serial.begin(9600);
  vw_set_tx_pin(transmit_pin);
  vw_setup(2000);
}

void loop(){
  send("hello world");
  delay(1000);
}

void send (char *msg){
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  Serial.println(*msg);
}



Receiver:

Code: [Select]


#include <VirtualWire.h>

const int receive_pin = 11;

void setup(){
    Serial.begin(9600);
    Serial.println("setup");
    
    
    vw_set_ptt_inverted(true);
//    /vw_set_rx_pin(receive_pin);
    vw_setup(2000);
    vw_rx_start();    
}

void loop(){
  
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
    
    Serial.println("Got: ");

    if (vw_get_message(buf, &buflen)){

 
 
 for (int i = 0; i < buflen; i++){
    Serial.print(buf[i], HEX);
    Serial.print(' ');
 }

 Serial.println();
    }
    
    delay(1000);
}




And pics of the setup....

Qdeathstar

I would triple check your connections, I cant really tell based on the pictures... but I was having an impossible time getting a 433mhz radio to work, and it turned out I had the positive and negative wires swapped.

if you have a meter, check for continuity between the 5v pins, ground pins, and data pins.

jremington

#2
Mar 31, 2015, 04:52 am Last Edit: Mar 31, 2015, 04:53 am by jremington
The first thing to do is to get VirtualWire working without the radios. For that you need a "transmitter" Arduino, a "receiver" Arduino and a wire running from the TX pin on the transmitter Arduino to the RX pin on the receiver Arduino. Also connect the two Arduino grounds together.

Make sure that you know which pins are which and that they are correctly assigned in the software.

When that works, remove the wire and replace with the radio modules.

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up