[Solved] Issue in String to Char array conversion

Hi guys. I’m working in a project that i need to send strings trhough RF. But, to be able to do this I have to convert the string that I want to a char array, becouse of the library.

So, partialy the code that I’m using is this

#include <Wire.h>
#include <math.h>
#include <Adafruit_MCP4725.h>
#include <PID_v1.h>
#include <RH_ASK.h>
#include <SPI.h>

RH_ASK driver;

char RF_msg[30];
String msg;

Adafruit_MCP4725 dac; // constructor

#define ThermistorPIN1 0   // Analog Pin 0
#define ThermistorPIN2 1

double temp1, temp2;
double Volts = 0, Power = 0, dac_volts;
float temp_media[10];

//Def PID variables and parameters
double Setpoint, Input, Output;
//kp=80, ki=7, kd=9
double Kp = 188.7093, Ki = 14.5407, Kd = 363.5954;

PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);

void setup() {


 //turn the PID on
 myPID.SetOutputLimits(574, 4095);



void loop() {

  temp1 = Thermistor(analogRead(ThermistorPIN1));
  temp2 = Thermistor(analogRead(ThermistorPIN2));

  double in = analogRead(2);
  Volts = (in*5/1023)/0.204;

  Power = (Volts*Volts)/10;

  Setpoint = temp2;

  Input = temp1;


  dac.setVoltage(Output, false);

  dac_volts = (5.0/4095.0)*Output;



void pre_set(){

  Setpoint = 40;

  long int t0 = millis();

    temp1 = Thermistor(analogRead(ThermistorPIN1));

    //Serial.print(" ");

    Input = temp1;

    dac.setVoltage(Output, false);    

    if (millis()-t0 >= 300000){


void Send_RF_Msg(){


  msg.toCharArray(RF_msg, sizeof(msg)+1);

 driver.send((uint8_t *)RF_msg, strlen(RF_msg));

 msg = "";

But, I’m not geting in the Serial output the whole message, just the first part. For example, the complety string is: “48.17-48.52-4.87-1023.00”, and the code just prints “48.17-”.

Any clues?

Ps: When i try to print the string in the variable msg, the arduino prints the whole message.

Please post your code

OK, I edited the post, there is just a second archive that contains the resistence/temperature conversion.

What string type is used for msg?

I edited it to use a c string function, include <stdio.h>, try this and see if it works.

  sprintf(RF_msg, "%f.2-%f.2-%f.2-%f.2", temp1, temp2, Power, Output);

sizeof(msg) - it may surprise you.

May surprise Obrazi that %f isn't supported on Arduino.

What a shame, thanks AWOL. I was just using the sizeof() in a wrong way, I just replaced it for msg.lenght() and it worked.

Delta_G: May surprise Obrazi that %f isn't supported on Arduino.

It did.