Rf Transmitter/Receiver

Hi, I have a problem about my receiver, it can't receive any data from my transmitter. My transmitter has been transmitting data but my receiver can't received it.
Thank you...

You obviously have a problem with the bits you didn't tell us about. Hope that helps.

//Transmitter codes

#include <VirtualWire.h>
#include <VirtualWire_Config.h>

int lighton = 8;

void setup() {

Serial.begin(9600);
vw_setup(2000);
vw_set_tx_pin(1);

pinMode(lighton,INPUT);

digitalWrite(lighton,HIGH);

}

void loop() {
char *msg2;

if(digitalRead(lighton) == LOW)
{

*msg2 = ‘1’;//send 1 to the receiver

digitalWrite(13, HIGH);
vw_send((uint8_t *)msg2, strlen(msg2));
Serial.print(*msg2);
vw_wait_tx();
digitalWrite(13, LOW);
delay(500);
}
}

//Receiver codes
#include <VirtualWire.h>

void setup()
{
Serial.begin(9600);

vw_setup(2000);
vw_set_rx_pin(11);
pinMode(4,OUTPUT);

vw_rx_start();
}

void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

if(vw_get_message(buf, &buflen)){
for (int i = 0; i < buflen; i++)
{
if(buf == ‘1’){

  • digitalWrite(4, HIGH);*
  • }*
  • else{*
  • digitalWrite(4,LOW);*
  • }*
  • }*
  • }*

}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

general:
Hi, I have a problem about my receiver, it can't receive any data from my transmitter. My transmitter has been transmitting data but my receiver can't received it.
Thank you...

  1. Do you have proof the TX is actually working?
  2. What is the distance between RX and TX? Are they too close or too far apart?
  3. you haven't provided information about how its wired up at each end.
  4. When getting a TX/RX setup working without RF test equipment you are working in
    the dark - its hard. You cannot know whether its the TX side or RX side that is failing.

However there are some little tricks that can help.

You can monitor the current taken by the TX unit - this should increase when its transmitting, and
is a fairly reliable indication that its doing something.

You can get a RF sniffer (a small antenna and detector module) to sniff for RF near the TX antenna.

Without an RF signal generator its hard to test an RX by itself.

 *msg2 = '1';

Compiler complains about that for some board selections. It may not do what you think.

...and even if the compiler doesn't complain, it's a dumb thing to do.

Well arguably its the strlen(msg2) that's foolish as msg2 is a pointer to character, not a C-string.

A C-string is not just char*.

It is a pointer to a zero (null) terminated array of char. Without the null termination you don't have a string,
you have an array of char. You shouldn't be passing char* about to string functions like strlen unless you
obey this rule.

MarkT:
You can monitor the current taken by the TX unit - this should increase when its transmitting, and
is a fairly reliable indication that its doing something.

Not as certain, but I have sometimes used a LED circuit with a TX just to make sure the software at least, is transmitting packets.