I am trying to publish
JSON data to mqtt with following code snippet
#include <Arduino_JSON.h> JSONVar data; data["temperature"] = temperature; data["humidity"] = humidity; data["pressure"] = pressure; data["chipId"] = chipId; String jsonString = JSON.stringify(data); client.publish("esp32/data", jsonString);
But getting following error
/home/ubuntu/Arduino/libraries/PubSubClient/src/PubSubClient.h:144:12: note: candidate expects 4 arguments, 2 provided Multiple libraries were found for "PubSubClient.h" Used: /home/ubuntu/Arduino/libraries/PubSubClient Multiple libraries were found for "Wire.h" Used: /home/ubuntu/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/Wire Multiple libraries were found for "Adafruit_BME280.h" Used: /home/ubuntu/Arduino/libraries/Adafruit_BME280_Library Multiple libraries were found for "Adafruit_Sensor.h" Used: /home/ubuntu/Arduino/libraries/Adafruit_Unified_Sensor Multiple libraries were found for "SPI.h" Used: /home/ubuntu/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/SPI Multiple libraries were found for "Arduino_JSON.h" Used: /home/ubuntu/Arduino/libraries/Arduino_JSON Multiple libraries were found for "WiFi.h" Used: /home/ubuntu/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi Not used: /opt/arduino-1.8.10/libraries/WiFi exit status 1 no matching function for call to 'PubSubClient::publish(const char , String&)'
Whats is wrong here ?