user24255: I want to receive text from Bluetooth from an android phone to Arduino Mega. Then I want to send that text to other Arduino UNO through RF 434MHz.
Here is my code for Transmitter.
#include <VirtualWire.h>
void setup()
{
  Serial.begin(9600);
  vw_setup(2000); 
}

void loop()
{
  String voice;
  digitalWrite(8,HIGH);
  while (Serial.available())
  {                 //Check if there is an available byte to read
    delay(10); //Delay added to make thing stable 
    char c = Serial.read(); //Conduct a serial read
    if (c == '#') {break;} //Exit the loop when the # is detected after the word
    voice += c; //Shorthand for voice = voice + c
  }  
  if (voice.length() > 0) 
  {
    Serial.println(voice);  
  }
  send(voice);
  delay(1000);
}

void send (char *message)
{
  vw_send((uint8_t *)message, strlen(message));
  vw_wait_tx(); // Wait until the whole message is gone
}

after compiling, I am getting an error as

exit status 1
  cannot convert 'String' to 'char*' for argument '1' to 'void send(char*)'


Please anyone tell me a way for solving this.
Problem is at transmitter part only. So I posted only about it.

user10394: [This should be a comment, but its too long]

•exit status 1 invalid conversion from 'const char*' to 'char*'
  [-fpermissive]

This means that the function you are calling wants a char* as a parameter, but you are passing it a char* that can't be modified.  The chances are that the send function doesn't modify the value in the parameter, so you might be OK just casting it, but you might get a runtime error if send does modify the value (a segmentation fault most likely, or just an ugly crash).  If you do you will need to allocate a temporary buffer that is big enough (str.length() + 1) and then copy it into that buffer and pass that to send.  
So, try this first:
send((char*)voice.c_str());

If that fails then try this:
char* tempBuffer = malloc(sizeof(char) * (voice.length() + 1));
if (tempBuffer)
{
    strncpy(tempBuffer, voice.c_str(), (voice.length() + 1));
    send(tempBuffer);
    free(tempBuffer);
    tempBuffer = 0;
}

Of course if the data is always a fixed length then you can allocate an array on the stack instead of mallocing a buffer onto the heap.

24255: <p>I want to receive text from Bluetooth from an android phone to Arduino Mega. Then I want to send that text to other Arduino UNO through RF 434MHz.<br>
Here is my code for Transmitter.</p>

<pre><code>#include &lt;VirtualWire.h&gt;
void setup()
{
  Serial.begin(9600);
  vw_setup(2000); 
}

void loop()
{
  String voice;
  digitalWrite(8,HIGH);
  while (Serial.available())
  {                 //Check if there is an available byte to read
    delay(10); //Delay added to make thing stable 
    char c = Serial.read(); //Conduct a serial read
    if (c == '#') {break;} //Exit the loop when the # is detected after the word
    voice += c; //Shorthand for voice = voice + c
  }  
  if (voice.length() &gt; 0) 
  {
    Serial.println(voice);  
  }
  send(voice);
  delay(1000);
}

void send (char *message)
{
  vw_send((uint8_t *)message, strlen(message));
  vw_wait_tx(); // Wait until the whole message is gone
}
</code></pre>

<p>after compiling, I am getting an error as</p>

<blockquote>
  <p>exit status 1<br>
  cannot convert 'String' to 'char*' for argument '1' to 'void send(char*)'</p>
</blockquote>

<p><a href="https://i.stack.imgur.com/1lJso.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1lJso.png" alt="enter image description here"></a></p>

<p>Please anyone tell me a way for solving this.<br>
Problem is at transmitter part only. So I posted only about it.</p>
 10394: <p>[This should be a comment, but its too long]</p>

<blockquote>
  <p>•exit status 1 invalid conversion from 'const char*' to 'char*'
  [-fpermissive]</p>
</blockquote>

<p>This means that the function you are calling wants a char* as a parameter, but you are passing it a char* that can't be modified.  The chances are that the send function doesn't modify the value in the parameter, so you <em>might</em> be OK just casting it, but you might get a runtime error if send does modify the value (a segmentation fault most likely, or just an ugly crash).  If you do you will need to allocate a temporary buffer that is big enough (str.length() + 1) and then copy it into that buffer and pass that to send.  </p>

<p>So, try this first:</p>

<pre><code>send((char*)voice.c_str());
</code></pre>

<p>If that fails then try this:</p>

<pre><code>char* tempBuffer = malloc(sizeof(char) * (voice.length() + 1));
if (tempBuffer)
{
    strncpy(tempBuffer, voice.c_str(), (voice.length() + 1));
    send(tempBuffer);
    free(tempBuffer);
    tempBuffer = 0;
}
</code></pre>

<p>Of course if the data is always a fixed length then you can allocate an array on the stack instead of mallocing a buffer onto the heap.</p>
