Cannot send message over pubsub

I'm trying to send readings from an ADC to an MQTT broker via pubsub but I can't compile the code. Where am I wrong?
I am attaching all the code.
Thanks.

type o
//This is a simple code to handle payload as String.

#include "ADC.h"
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// Global variables for module
static int16_t  speed_mode = SLOW;        //!< The ADC Speed Mode settings. Change it to "FAST" for higher data rate.
static float    adc_vref = 2.5;           //!< The ADC reference voltage
static uint8_t  rejection_mode = ADC_R50; //!< The ADC rejection mode
static uint8_t  i2c_address = 0x24;       //!< I2C address in 7 bit format for part
static uint16_t eoc_timeout = 300;        //!< Timeout in ms
static float    adc_offset = 0;

#define C0 2

#define ssid "TP-LINK_09CE"
#define password "120120120"
#define mqtt_server "192.168.0.130"
#define client_name "NodeMCU 8CH"

const char* inTopic = "home/living";
const char* msgTopic = "home/msg";
const char* msgpH = "pool/pH";
char msgIN;

WiFiClient espClient;
PubSubClient client(espClient);
///////////////////////////////////////////////////////
void setup_wifi()
{
  delay(100);
  Serial.println("Connecting to ");
  Serial.print(ssid);
  WiFi.begin(ssid, password);
  WiFi.mode(WIFI_STA);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.print(WiFi.localIP());
  Serial.println();
}
///////////////////////////////////////////////////////
void reconnect()
{
  while (!client.connected())
  {
    Serial.println("Attempting MQTT connection...");

    if (client.connect(client_name))
    {
      client.publish(msgTopic, "MQTT is connected");
      //client.publish(msgpH, "Just test");
      Serial.println("connected");
      client.subscribe(inTopic);
    }
    else
    {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}
////////////////////////////////////////////////////////
void callback(char* topic, byte* payload, unsigned int length)
{
  String msgIN = "";
  for (int i = 0; i < length; i++)
  {
    msgIN += (char)payload[i];
  }
  String msgString = msgIN;
  Serial.println(msgString);

  //Message as String
  if (msgString == "CH1ON")
  {
    Serial.println("Channel1 is ON");
    client.publish(msgTopic, "Channel1 is ON");
    digitalWrite(C0, HIGH);
  } else if (msgString == "CH1OFF")
  {
    Serial.println("Channel1 is OFF");
    client.publish(msgTopic, "Channel1 is OFF");
    digitalWrite(C0, LOW);
  }
}
/////////////////////////////////////////////////////
void setup()
{
  Wire.begin(4, 5); //(SDA,SCL)wake up I2C bus
  Serial.begin(9600);

  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);

  pinMode(C0, OUTPUT);
  digitalWrite(C0, LOW);
}
////////////////////////////////////////////////////
void loop()
{
  if (!client.connected())
  {
    reconnect();
  }
  client.loop();

  //from sourse
  uint8_t acknowledge = 0;

  acknowledge |= read_adc();

  if (acknowledge)
    Serial.println(F("***** I2C ERROR *****"));
  delay(1000);
  //end sourse
  if (!client.loop())
  {
    client.connect("ESP8266Client");
  }
}
/////////////////////////////////////////////////////
//! @return 0 if successful, 1 is failure
int8_t read_adc()
{
  uint8_t adc_command;
  int32_t adc_code = 0;
  float   adc_voltage = 0;
  uint8_t ack = 0;

  adc_command = rejection_mode | speed_mode;

  ack |= adc_read( i2c_address, adc_command, &adc_code, eoc_timeout );

  adc_voltage = adc_code_to_voltage( adc_code, adc_vref ) * 1000 + adc_offset;  //!< Convert the ADC code to mV voltage

  if ( !ack )
  {
    Serial.print( F("*************************\n" ) );
    Serial.print( "BNC Input Voltage: " );
    Serial.print( adc_voltage, 1 );
    Serial.print( F( "mV\n" ) );
    float pH_raw = adc_voltage;
    client.publish("pool/pH", String(pH_raw));
    //client.publish("sensors", packet.c_str());
    //client.publish( pH_raw);
    //client.publish(msgpH, String(pH_raw));
  }
  else
  {
    Serial.print( F( "Error in read" ) );
    return 1;
  }

  return ( 0 );

}r paste code here

Show us the compling error.

Arduino: 1.8.19 (Windows 7), Board: "LOLIN(WEMOS) D1 R2 & mini, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 921600"





















P:\work_pH\simple_pubsub_esp8266\simple_pubsub_esp8266.ino: In function 'int8_t read_adc()':

simple_pubsub_esp8266:155:45: error: no matching function for call to 'PubSubClient::publish(const char [8], String)'

  155 |     client.publish("pool/pH", String(pH_raw));

      |                                             ^

In file included from P:\work_pH\simple_pubsub_esp8266\simple_pubsub_esp8266.ino:7:

D:\arduino-1.8.19\libraries\PubSubClient\src/PubSubClient.h:151:12: note: candidate: 'boolean PubSubClient::publish(const char*, const char*)'

  151 |    boolean publish(const char* topic, const char* payload);

      |            ^~~~~~~

D:\arduino-1.8.19\libraries\PubSubClient\src/PubSubClient.h:151:51: note:   no known conversion for argument 2 from 'String' to 'const char*'

  151 |    boolean publish(const char* topic, const char* payload);

      |                                       ~~~~~~~~~~~~^~~~~~~

D:\arduino-1.8.19\libraries\PubSubClient\src/PubSubClient.h:152:12: note: candidate: 'boolean PubSubClient::publish(const char*, const char*, boolean)'

  152 |    boolean publish(const char* topic, const char* payload, boolean retained);

      |            ^~~~~~~

D:\arduino-1.8.19\libraries\PubSubClient\src/PubSubClient.h:152:12: note:   candidate expects 3 arguments, 2 provided

D:\arduino-1.8.19\libraries\PubSubClient\src/PubSubClient.h:153:12: note: candidate: 'boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int)'

  153 |    boolean publish(const char* topic, const uint8_t * payload, unsigned int plength);

      |            ^~~~~~~

D:\arduino-1.8.19\libraries\PubSubClient\src/PubSubClient.h:153:12: note:   candidate expects 3 arguments, 2 provided

D:\arduino-1.8.19\libraries\PubSubClient\src/PubSubClient.h:154:12: note: candidate: 'boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int, boolean)'

  154 |    boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);

      |            ^~~~~~~

D:\arduino-1.8.19\libraries\PubSubClient\src/PubSubClient.h:154:12: note:   candidate expects 4 arguments, 2 provided

exit status 1

no matching function for call to 'PubSubClient::publish(const char [8], String)'



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Solved. I just edit this line.

client.publish("pool/pH", String(pH_raw));

like this

client.publish("pool/pH", String(pH_raw).c_str());

Thanks.