Error: invalid conversion from 'const char*' to 'char*' [-fpermissive]

error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
static char msg = str_msg.c_str();
~~~~~~~~~~~~~^~
exit status 1
invalid conversion from 'const char
' to 'char*' [-fpermissive]

I get the above error in the following code when I compile:

void sendMsg() {

  str_msg = colour + address;
  
 static char *msg = str_msg.c_str();

  rf_driver.send((uint8_t *)msg, strlen(msg));
  rf_driver.waitPacketSent();

  
}

both colour and address are strings

I've tried what I can think of, but I'm still relatively new to arduino. I've been following this tutorial on yt: Using Inexpensive 433 MHz RF Modules with Arduino - YouTube

Sorry if this something really silly and simple

thx

Try promising not to change the characters inside the String:

  const char *msg = str_msg.c_str();

  rf_driver.send((const uint8_t *)msg, strlen(msg));
1 Like

Thank you very much, that's solved the problem!!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.