Data transmit for two communcation method

Hi all,

I am going to build a project of data transmission by using ultrasound and RF communication. Is it possible to use one arduino UNO to receive data by using ultrasound and transmit the same data through RF? Or it is necessary to separate into two arduino?

The arduino receive ultrasound data on pin D3 and possible to link the output D3 as input for RF transmtter in the same arduino? Can arduino make the RF transmitter sleep first and wake it up later without sleep the arduino? Any suggestion to make the transmitter sleep?

Thanks :slight_smile:

Are you saying that you have a successful working program that can receive data using ultrasound? If so please post the program.

And you have not given us any clue about what type of wireless transmission you have in mind.

...R
Simple nRF24L01+ Tutorial

Yes. I had received data using ultrasound.

Ultrasonic receiver Coding :
int pos = 0;
unsigned char CH = 0;
unsigned int bits1 = 0;
boolean capture = false;

void setup()
{
Serial.begin(115200);
pinMode(5,INPUT_PULLUP);
}

void loop()
{
if(digitalRead(5))
{
bits1 = 0;
unsigned long deltaT = millis();
while(millis()-deltaT <= 10) if(digitalRead(5)) bits1 ++;
//Serial.println(bits1);
if(capture)
{
boolean b = 0;
if(bits1 > 290 && bits1 < 600) b = 0;
if(bits1 > 20 && bits1 < 290) b = 1;
if(b) bitSet(CH,7-pos); else bitClear(CH,7-pos);
//Serial.print(b);
pos++;
if(pos == 8)
{
Serial.print((char)CH);
pos = 0;
capture = false;
}
}
if(bits1 > 600)
{
capture = true;
pos = 0;
}
}
}

I would like to have ultrasound data transmission first by using arduino then use the same arduino for RF data transmission which means that after the ultrasound data received, the data will be transmitted again by using RF transmission.

Simply replace this line, with one that sends the character to the radio:

Serial.print((char)CH);

RF transmitter Coding :

#include <VirtualWire.h>
void setup()
{
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
}
void loop()
{
send("Hello there");
delay(1000);
}
void send (char *message)
{
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx(); // Wait until the whole message is gone
}

This coding i got from a RF data transmission example in Internet. How i modify the coding with ultrasonic receiver to combine as one?

To use that code, you will need to put one or more characters into a C-string (zero terminated character array), and transmit it with send().

Example

char message[2];
message[0]='A'; //the letter A
message[1]=0; //terminate string
send(message);

Thanks for your responce :wink:

#include <VirtualWire.h>
int pos = 0;
unsigned char CH = 0;
unsigned int bits1 = 0;
boolean capture = false;

void setup() 
{
   Serial.begin(115200);
   pinMode(5,INPUT_PULLUP);
   vw_setup(2000); // Bits per sec
}

void loop() 
{
   if(digitalRead(5))
   {
      bits1 = 0;
      unsigned long deltaT = millis();
      while(millis()-deltaT <= 10) if(digitalRead(5)) bits1 ++;
      //Serial.println(bits1); 
      if(capture)
      {
         boolean b = 0;
         if(bits1 > 290 && bits1 < 600) b = 0;
         if(bits1 > 20 && bits1 < 290) b = 1;
         if(b) bitSet(CH,7-pos); else bitClear(CH,7-pos);
         //Serial.print(b);
         pos++;
         if(pos == 8)
         {
            Serial.print((char)CH);
            pos = 0;
            capture = false;
         }
      }
      if(bits1 > 600) 
      {
         capture = true;
         pos = 0;
      }
   }
   char message[50];
   message[0] = ((char)CH);
   message[49]= 0;
   send (message);
}
void send (char message)
{
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx(); // Wait until the whole message is gone
}

Is it something like this but i cannot get anything in RF receiver? How do I determine how many arrays in the message[50]?
The data received is
"This is an ultrasonic data communication\n"
"Hello World\n\n"

Why did you replace 2 with 50?

Get your radios working with the examples provided with the VirtualWire library before adding anything to your original code.

If you don't understand a programming concept, google it. There are many fine tutorials.