Invalid conversion from 'volatile char*' to 'const char*' [-fpermissive]

Hello forum,

I have a Pro mini 5v/16Mhz which I hooked up to a SIM808 GSM modem as data logger. I use Minicore for my Pro mini's. This board is one of three connected by I2C which makes up a complete system that switches water valves. One of the boards sends voltage and pressure data by I2C to this Pro mini which compiles this received data and uploads it to my server.

In setup I have this to trigger receiveWire() whenever data comes in.

    Wire.begin(2); 
    Wire.onReceive(receiveWire);

receiveWire() inserts the received data into char array RX. Then I extract the data from RX to get the numerical value and convert it to float, which I need for the rest of the sketch.

  if (RX[0] == 'V' && RX[3] == '=' && RX[strlen(RX) - 1] == '!')   // V25=0.00!   - format of received data
  {
     char nodeIncrCH[3];
     nodeIncrCH[0] = RX[2];
     nodeIncrCH[1] = RX[3];
     nodeIncrCH[2] = '\0';
     nodeIncr = atoi(nodeIncrCH);

     int y = 0;
     volatile char tempCh[5];
    
     while (RX[y + 4] != '!')
     {
       tempCh[y] = RX[y + 4];
       tempCh[y + 1] = '\0';
       y++;
     }
     volatile float tempFl = atof(tempCh);
     noInterrupts();
     volts[nodeIncr] = tempFl;
     interrupts();
  }

The float array is defined as global variable.

float volts[30];

The issue I'm facing is that the compiler throws this error when I try to convert the volatile char array to volatile float. When I compile the same code for an Uno or Mega2560 there is no error or warning even, so I'm guessing the code could work?

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

Is my code bad or is there a way to allow this warning to go through for Minicore boards?

Try with explicit cast of tempCh


volatile float tempFl = atof((const char*)tempCh);

That did it, thanks @cotestatnt .

My next hurdle should probably address a new topic, but any idea why the global variable "volts" does not carry its value over to the rest of the sketch where the value is needed?

You should post the complete code.

In addition, put some Serial.println() in order to check if conversion atof() and atoi() return wath you expect.

I didn't think this would have been the culprit, but there was one variable of type int in a similar function as the one above which I didn't define as volatile. I didn't think it would matter and still don't know if it does, since this variable is used outside of the noInterrupts() / interrupts() section.

But I defined it as volatile as everything jumped in place. I need to read up on this more.

Before this change I did use Serial.print and it showed that the global variables received the values inside this noInterrupts() / interrupts() section, but outside of this function the variables seems to have lost the value.

Local volatile variable doesn’t make much sense to me, could you explain the big idea behind it please?