- Sun Jan 14, 2018 9:47 am
#73128
here are some more details, just one example of code i've tried, unsuccessfully
// next 2 lines converts the push button counter to text then publishes same message to MQTTBox, works great thx schufti & gdsports!
itoa(buttonPushCounter,msg,10);
client.publish("OsoyooDataF",msg);
// Trying to do the same thing here, publish the RGB LED color values string to the MQTTBox
client.publish("OsoyooDataF", (String("r,g,b = " + String(rgbLed.redPin) + "," + String(rgbLed.greenPin) + "," + String(rgbLed.bluePin))));
// herein lies the error, trying to send the same message to the MQTTBox that is going to the serial monitor, next line
// Serial.println("r,g,b = " + String(rgbLed.redPin) + "," + String(rgbLed.greenPin) + "," + String(rgbLed.bluePin) );
Arduino: 1.8.2 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"
C:\Users\GADAWE\Documents\Arduino\node_ct_rgb_box\node_ct_rgb_box.ino: In function 'void loop()':
node_ct_rgb_box:138: error: no matching function for call to 'PubSubClient::publish(const char [12], String)'
client.publish("OsoyooDataF", (String("r,g,b = " + String(rgbLed.redPin) + "," + String(rgbLed.greenPin) + "," + String(rgbLed.bluePin))));
^
C:\Users\GADAWE\Documents\Arduino\node_ct_rgb_box\node_ct_rgb_box.ino:138:144: note: candidates are:
In file included from C:\Users\GADAWE\Documents\Arduino\node_ct_rgb_box\node_ct_rgb_box.ino:2:0:
C:\Program Files\arduino-1.8.2\libraries\pubsubclient\src/PubSubClient.h:130:12: note: boolean PubSubClient::publish(const char*, const char*)
boolean publish(const char* topic, const char* payload);
^
C:\Program Files\arduino-1.8.2\libraries\pubsubclient\src/PubSubClient.h:130:12: note: no known conversion for argument 2 from 'String' to 'const char*'
C:\Program Files\arduino-1.8.2\libraries\pubsubclient\src/PubSubClient.h:131:12: note: boolean PubSubClient::publish(const char*, const char*, boolean)
boolean publish(const char* topic, const char* payload, boolean retained);
^
C:\Program Files\arduino-1.8.2\libraries\pubsubclient\src/PubSubClient.h:131:12: note: candidate expects 3 arguments, 2 provided
C:\Program Files\arduino-1.8.2\libraries\pubsubclient\src/PubSubClient.h:132:12: note: boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int)
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength);
^
C:\Program Files\arduino-1.8.2\libraries\pubsubclient\src/PubSubClient.h:132:12: note: candidate expects 3 arguments, 2 provided
C:\Program Files\arduino-1.8.2\libraries\pubsubclient\src/PubSubClient.h:133:12: note: boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int, boolean)
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);
^
C:\Program Files\arduino-1.8.2\libraries\pubsubclient\src/PubSubClient.h:133:12: note: candidate expects 4 arguments, 2 provided
exit status 1
no matching function for call to 'PubSubClient::publish(const char [12], String)'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.