title: Arduino RF Data Transmission
body: <p>I have 3 ultrasonic sensor connected to 1 Arduino Uno device. I want to send their data to another Arduino Uno with RF transmitter. I want to send the sensor's id number (1,2,3) and the data (0 or 1). </p>
  
  <p>I want to transmit the data from printDistance method but the message that transmitter sends is char *msg. Do I have to send only char values? </p>
  
  <pre><code>#include &lt;VirtualWire.h&gt;  
  
  #undef int
  #undef abs
  #undef double
  #undef float
  #undef round
  
  //Sonar 1
  int echoPin1 =2;
  int initPin1 =3;
  int distance1 =0;
  
  //Sonar 2
  int echoPin2 =6;
  int initPin2 =7;
  int distance2 =0;
  
  //Sonar 3
  //int echoPin3 =8;
  //int initPin3 =9;
  //int distance3 =0;
  
  
  
  void setup() {
  
          // Initialise the IO and ISR
      vw_set_ptt_inverted(true); // Required for RF Link module
      vw_setup(2000);                 
      vw_set_tx_pin(8);                
  
  
    pinMode(initPin1, OUTPUT);
    pinMode(echoPin1, INPUT);
    pinMode(initPin2, OUTPUT);
    pinMode(echoPin2, INPUT);
   // pinMode(initPin3, OUTPUT);
   // pinMode(echoPin3, INPUT);
  //  pinMode(initPin4, OUTPUT);
   // pinMode(echoPin4, INPUT);
    delay(2000);
    Serial.begin(9600);
    Serial.println(" ");
  }
  
  void loop() {
  
       const char *msg;    // this is your message to send
  
     vw_send((uint8_t *)msg, strlen(msg));
     vw_wait_tx();                                          // Wait for message to finish
     delay(200);
  
  
  
    distance1 = getDistance(initPin1, echoPin1);
    printDistance(1, distance2);
    delay(10);
  
    distance2 = getDistance(initPin2, echoPin2);
    printDistance(2, distance2);
    delay(10);
  
    //distance3 = getDistance(initPin3, echoPin3);
    //printDistance(3, distance3);
    //delay(10);
  
   // distance4 = getDistance(initPin4, echoPin4);s
   // printDistance(4, distance4);
  
    Serial.println(" ");  
    delay(5000);
  //  Serial.println(" ");
  }
  
  int getDistance (int initPin, int echoPin){
  
   digitalWrite(initPin, HIGH);
   delayMicroseconds(10); 
   digitalWrite(initPin, LOW); 
   delayMicroseconds(5);
   unsigned long pulseTime = pulseIn(echoPin, HIGH); 
   int distance = pulseTime/58;
   return distance;
  
  }
  
   void printDistance(int id, int dist){
  
       Serial.print('&lt;');  
  
       Serial.print( id );
         Serial.print( '&gt;' );
  
      if (dist &gt;= 30 || dist &lt;= 0 ){
        Serial.print("0");
      }else {
      Serial.print("1");
      }
  
       Serial.print('&lt;');
  
       Serial.print( '/' );
  
       Serial.print( id );
         Serial.print( '&gt;' );
  
    //   Serial.println(" ");
  
  
   }
  </code></pre>