Char erros

Hello everyone! I am using RF communication and I get the following error:

/Users/RonaldAguilera/Documents/Arduino/transmitter_test/transmitter_test.ino: In function ‘void loop()’:
/Users/RonaldAguilera/Documents/Arduino/transmitter_test/transmitter_test.ino:51:37: warning: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
static char *msg = str_out.c_str();
^

The communication works fine but I don’t understand what the error means.

#include "HX711.h"
#include <RH_ASK.h>
#include <SPI.h> 

// RF Transmitter - pin D12
// HX711.DOUT    - pin #A0
// HX711.PD_SCK  - pin #A1

#define DOUT  A0
#define CLK  A1
#define calibration_factor 30321 //Calibration factor

float counter;

String str_weight;
String str_counter;
String str_out;

RH_ASK rf_driver;

HX711 scale(DOUT, CLK);

void setup (){
//    Serial.begin(9600);
    rf_driver.init();

    scale.set_scale(calibration_factor);
    scale.tare(1);
    
}

void loop(){
    
    float weight=scale.get_units(10);

//    Serial.print("Reading: ");
//    Serial.println(weight);
   
    str_weight=String(weight);
    str_counter=String(counter);
    
    str_out = str_weight + "," + str_counter;

    static char *msg = str_out.c_str();

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

Did you notice that the word "error" didn't appear in your "error message"?

Neither in the title. :slight_smile:
"Char erros"

Just did! My bad! thanks

Make the *msg static is useless.You can pass str_out.c_str() directly in parameter.

rjaguilera1993:
/Users/RonaldAguilera/Documents/Arduino/transmitter_test/transmitter_test.ino:51:37: warning: invalid conversion from 'const char*' to 'char*' [-fpermissive]
static char *msg = str_out.c_str();
^
The communication works fine but I don't understand what the error means.

It means "str_out.c_str()" is returning a "const char *" (a read-only character pointer) and you are storing that address in a "char *" (read/write character pointer). This make it easy to (accidentally) write into the memory that was originally markes as read-only. This is not illegal (not an error) but it is a common mistake that can be easily fixed (so a warning is provided).
To eliminate the warning, promise not to write through the pointer:

static const char *msg = str_out.c_str();