arduino-libraries / ArduinoMqttClient

ArduinoMqttClient Library for Arduino
GNU Lesser General Public License v2.1
187 stars 73 forks source link

How to use username and paswword on the connect function #25

Closed hofmeisterchrigu closed 4 years ago

hofmeisterchrigu commented 4 years ago

Hi I try to use the WiFiSimpleSender Example for a device that should send MQTT messages to my Network. The problem I have is that I can't connect to my broker without using credentials.

I modified the original statement from this: mqttClient.connect(broker, port) to this: mqttClient.connect(broker, port, user, pass) but unfortunately, it didn't work.

Would you give me any suggestions? Thanks, Chris

sandeepmistry commented 4 years ago

Hi @hofmeisterchrigu,

Please see the commented lines in the example for the how to set a username and password for the client:

https://github.com/arduino-libraries/ArduinoMqttClient/blob/master/examples/WiFiSimpleSender/WiFiSimpleSender.ino#L62-L63