Esp 32 MQTT

Annex for ESP32
Post Reply
Michael S
Posts: 9
Joined: Mon May 17, 2021 7:09 pm
Location: Delbrück-Germany
Has thanked: 7 times

Esp 32 MQTT

Post by Michael S »

Hello community
I need your knowledge again.
The following code

r1= mqtt.setup("mqtts://test.mosquitto.org", 1) '
r2= mqtt.connect("", "")
wlog r1,r2
wait

under ESP 8266 1.44 it works fine, but
under ESP 32 1.48 it does not work at all.
What am I missing ?
the code is identical at the beginning.

Thanks for your help.

Michael
User avatar
cicciocb
Site Admin
Posts: 2020
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 432 times
Been thanked: 1339 times
Contact:

Re: Esp 32 MQTT

Post by cicciocb »

I think that it requires a certificate.

You can download the certificate from mosquitto test server here:
image.png
Then, upload this file to Annex in the root folder (in the example below I left the original name "mosquitto.org.crt" and try the example below

Code: [Local Link Removed for Guests]

' MQTT SSL test program

' Using mosquitto test server
a$ = file.read$("/mosquitto.org.crt") ' load the certificate
onmqtt mqtt_msg
print mqtt.certif(a$)
print mqtt.setup("mqtts://test.mosquitto.org", 1)
print mqtt.connect("", "") ' No login / pass required
print mqtt.subscribe("/AnnexTest") ' subscribe to the topic /AnnexTest
 
for z = 1 to 10
  ' send messages to the topic /AnnexTest
  print mqtt.publish("/AnnexTest", "Annex"+str$(z))
  pause 100
next z
print ramfree
wait
' receive messages from the server
mqtt_msg:
print "TOPIC  : "; mqtt.topic$
print "MESSAGE: "; mqtt.message$
return

You do not have the required permissions to view the files attached to this post.
Michael S
Posts: 9
Joined: Mon May 17, 2021 7:09 pm
Location: Delbrück-Germany
Has thanked: 7 times

Re: Esp 32 MQTT

Post by Michael S »

Thank you cicciocb
Thanks for the quick help
After seeing that it seems complicated to create a certificate, I used a Rapsi as a brocker.
Runs great and the data stays in house.

Michael
Post Reply