Go Down

Topic: Wireless ultrasonic sensor using RF link (Read 2922 times) previous topic - next topic

iiKoe

Hello,

this is my first post on the arduino forum, and i hope I placed it in the right category.


I'm working on making my ultrasonic sensor  wireless using RF link modules from sparkfun and the Virtual wire library.

But it isn't working that wel. not at all actually. I am only getting zeros.

i am only a beginnen with the arduino, can somebody point out my mistakes, and help me fix them.

hire are the codes.

Transmitter:

Code: [Select]
#include <Ultrasonic.h>

// RF Link using VirtualWire to Transmit messages
// simplex (one-way) receiver with a 315MHz RF Link Transmitter module
// tx pin 3 on Duemilanova (arduino)


#include <VirtualWire.h>

#undef int
#undef abs
#undef double
#undef float
#undef round
int distance;
char Istr[0];

Ultrasonic ultrasonic( 12, 13 ); // the ultrasonic pins


void setup()
{
 
 

    // Initialise the IO and ISR
   vw_set_ptt_inverted(true); // Required for RF Link module
   vw_setup(2000);                 // Bits per sec
   vw_set_tx_pin(3);                // pin 3 is used as the transmit data out into the TX Link module, change this to suit your needs.
}

void loop()
{
  distance = ( ultrasonic.Ranging(CM) );

   
  Istr[0]= distance;
   
       
vw_send((uint8_t *)Istr, strlen(Istr));


  vw_wait_tx();                                          

  delay(200);
}




recever:

Code: [Select]
#include <VirtualWire.h>


int distance;

void setup()
{
   Serial.begin(9600);    // Debugging only
   Serial.println("setup");

   // Initialise the IO and ISR
   vw_set_ptt_inverted(true); // Required for DR3100
   vw_setup(2000);     // Bits per sec

   vw_rx_start();       // Start the receiver PLL running
   
}

void loop()
{
 
   int test;
   int msg[VW_MAX_MESSAGE_LEN];
   uint8_t buf[VW_MAX_MESSAGE_LEN];
   uint8_t buflen = VW_MAX_MESSAGE_LEN;
   (distance = vw_have_message() );
   {
   
     

     
     Serial.println(distance, DEC);
   }
}





greets iikoe

PaulS

Quote
I'm working on making my ultrasonic sensor  wireless

So, the first step is to make sure that it works in a wired mode. Then, it is just a matter of sending the data that is returned by the sensor out via the radio.

Does your code and sensor work in a wired mode?
The art of getting good answers lies in asking good questions.

iiKoe

#2
Sep 23, 2010, 09:27 pm Last Edit: Sep 23, 2010, 09:28 pm by iiKoe Reason: 1
yes ,it works well if its just on the arduino and directly hooked up to the PC.

but I can't manage it to send the readings to the other arduino witch is hooked up to the PC

Go Up