Go Down

Topic: Strange behavior of rf 433mhz modules in simple transmitter Receiver circuit (Read 479 times) previous topic - next topic

I am using this http://www.seeedstudio.com/depot/433mhz-rf-link-kit-p-127.html to send a message over RF.

I am using Virtual Wire library and simple transmitter and receiver codes.
The strange thing is sometimes it is working absolutely fine. But sometimes the receiver is not receiving anything as per the serial monitor.

What I am doing is I am just sending a ADC value from the transmitter and receiving it in the receiver circuit and showing it in the serial monitor.

Here is my transmitter code :

#include <VirtualWire.h>  
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
   Serial.begin(9600);  
 // Initialise the IO and ISR
   vw_set_ptt_inverted(true);
   vw_setup(2000);            
   vw_set_tx_pin(5);                
}

void loop()
{
 int s = analogRead(A0);  
 Serial.println(s);
  char msg[24] ;
  sprintf(msg, "%i", s);
  vw_send((uint8_t *)msg, strlen(msg));      

  vw_wait_tx();                                          
  delay(2000);
}

and here is my receiver code :

#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
 Serial.begin(9600);    
 vw_set_ptt_inverted(true);    
 vw_setup(2000);              
 vw_set_rx_pin(5);          
 vw_rx_start();                      
 pinMode (9,OUTPUT);
}

void loop()
{
 
 int j[20];
 double temp = 0;
 float k;
 uint8_t buf[VW_MAX_MESSAGE_LEN];
 uint8_t buflen = VW_MAX_MESSAGE_LEN;

 if (vw_get_message(buf, &buflen))
 {
   int i = 0;
   
   Serial.print("length ");
   Serial.println(buflen);
   for (i = 0; i < buflen; i++)
   {
    Serial.println(buf);  
     j = buf - '0' ;

     Serial.println(j);    
     temp = pow(10, ( buflen - i - 1)) * j + temp;
     Serial.println(temp);  
}
     k = temp ;
     long val = ((long)k);
     Serial.println(val);
   
 }
}



Please help me out, I am stuck at my project while it is working fine at times :(

betomax

Hi

i Think this  RF ask-modulation tranceivers are not the best  choice for me to transfer data @t hi speed, if using it is a must,  you may try @t lower bps,  i.e. 1400 or even 1200bps.


@Betomax

Still its not working. I tried at 1200 bps but the receiver dint receive any data. :(

Please help me out.

KenshinPT


@Betomax

Still its not working. I tried at 1200 bps but the receiver dint receive any data. :(

Please help me out.


Are the modules very far away from each other? Try again with the modules very close.

After confirming they are communicating, slowly move them away.

Also, don't forget to solder an antenna on both modules.

I also recommend to develop an CRC algorithm because I experienced lots of missing and corrupt data.

mauried

How far apart are the modules?
The 433.92 Mhz band is highly congested, and can easily be interfered by other devices also using the
same frequency.
Its best to send your data multiple times to make sure that some of it is received.

Go Up