Publishing a value through PubSubClient
<p>I tried the following code to publish a value using Arduino onto Mosquitto broker. The code appears to be right but then as soon as I compile/verify, the following error is thrown. What's the cause and how do I overcome this problem?       </p>

<pre><code>#include &lt;SPI.h&gt;
#include &lt;Ethernet.h&gt;
#include &lt;PubSubClient.h&gt;


#define CLIENTID "ArduinoSensor"
#define TOPICNAME "sensor/temperature"
#define POLLINTERVAL 120000

void callback(char topic, byte payload, unsigned int length){
//Do nothing as we are publishing ONLY.
}

byte mac [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED} ;
byte server [] = { 85, 119, 83, 194 };
EthernetClient ethClient;
PubSubClient arduinoClient(server, 1883, callback, ethClient) ;
unsigned long boardTime = 0 ;
float sensedTemperature = 0;
char charTemperature [20];


void setup(void) {
Serial.begin(9600);
//Connect to the MQTT server - test.mosquitto.org
beginConnection() ;
}

//Initialise MQTT connection
void beginConnection() {
Serial.begin(9600);
Ethernet.begin(mac) ;   //using the address assigned through DHCP 
int connRC = arduinoClient.connect(CLIENTID) ;
if (!connRC) {
Serial.println(connRC) ;
Serial.println("Could not connect to MQTT Server");
Serial.println("Please reset the arduino to try again");
delay(100);
exit(-1);
}
else {
Serial.println("Connected to MQTT Server...");
}
}

void loop(void) {
boardTime = millis();
if ((boardTime % POLLINTERVAL) == 0) {
  getTemp();
  dtostrf(sensedTemperature,5,2,charTemperature) ;
  arduinoClient.publish(TOPICNAME, charTemperature) ;
}
}

void getTemp() {
// Send the command to get temperatures
delay(100);
sensedTemperature = analogRead(2);   //temperature sensor at analog pin 2 on Arduino.
delay(150);
}
</code></pre>

<p>Error Printed:</p>

<pre><code>publisher:18: error: invalid conversion from 'void (*)(char, byte, unsigned int) {aka void (*)(char, unsigned char, unsigned int)}' to 'void (*)(char*, uint8_t*, unsigned int) {aka void (*)(char*, unsigned char*, unsigned int)}' [-fpermissive]

 PubSubClient arduinoClient(server, 1883, callback, ethClient) ;

C:\Users\Chetan\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:98:4: error:   initializing argument 3 of 'PubSubClient::PubSubClient(uint8_t*, uint16_t, void (*)(char*, uint8_t*, unsigned int), Client&amp;)' [-fpermissive]

    PubSubClient(uint8_t *, uint16_t, MQTT_CALLBACK_SIGNATURE,Client&amp; client);

 ^

exit status 1
invalid conversion from 'void (*)(char, byte, unsigned int) {aka void (*)(char, unsigned char, unsigned int)}' to 'void (*)(char*, uint8_t*, unsigned int) {aka void (*)(char*, unsigned char*, unsigned int)}' [-fpermissive]

In file included from C:\Users\Chetan\Desktop\publisher\publisher.ino:4:0:
</code></pre>

<p>Any suggestions?</p>