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()

void loop()
  String voice;
  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) 

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*)'

enter image description here

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


2 Answers 2


[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:


If that fails then try this:

char* tempBuffer = malloc(sizeof(char) * (voice.length() + 1));
if (tempBuffer)
    strncpy(tempBuffer, voice.c_str(), (voice.length() + 1));
    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.

  • thanking you. It worked very well the first one send((char*)voice.c_str()); But after that I got another error in transmission. Once I send a string of length 15 characters then after that if I send 16 or more than 15 characters string , it is receiving only up to 15 character in same way the string length is getting fixed and unable to send more length string than previous one.In such a way the length of string receiving is getting reduced. Can you suggest me any solution for this problem? Dec 9, 2016 at 9:18

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

The compiler is telling you about the issue. You can access the String as a character vector (C string) with the member function c_str(), e.g. send(voice.c_str());

You might need to check that it is not too long for the payload in the VirtualWire library.


  • I had done what you said then it returned with following error > - exit status 1 invalid conversion from 'const char*' to 'char*' [-fpermissive] Dec 9, 2016 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.