MQTT client with TLS example code

Hi all,

This question has been asked before but with no real satisfactory reply yet, I suspect a few people have managed to successfully implement it on an Arduino.

I am looking for an example bit of code which I can then adapt for an Arduino to connect to a MQTT server using TLS so it can publish and read messages as a client.

Some posts seem to suggest date/time synchronisation seems to be important.

I have the certificate which I would like to place in the code/sketch if possible.

Does anyone know of a working example of this?

I am using an Arduino Uno Wifi Rev2 if that helps at all.

Thanks.
H

I am looking for an example bit of code which I can then adapt for an Arduino to connect to a MQTT server using TLS so it can publish and read messages as a client.

This isn't possible as many Arduinos aren't able to handle TLS secured connections. For specific platforms there are many examples online.

I am using an Arduino Uno Wifi Rev2 if that helps at all.

You can use an ESP8266 example but use WiFiSSLClient instead of WiFiClientSecure and don't use the setCACert() call as the library for your hardware doesn't support it.