Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

minimqtt_certificates.py
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

minimqtt_certificates.py

by inghal on Mon Jun 22, 2020 9:51 am

What is the correct syntax for the certificates.py file for use in the minimqtt_cerificates.py example file?
(DEVICE_CERT and DEVICE_KEY)
inghal
 
Posts: 7
Joined: Thu Sep 06, 2012 6:29 pm

Re: minimqtt_certificates.py

by brubell on Mon Jun 22, 2020 1:36 pm

This example may be outdated. I suggest just adding the .pem.crt and .pem.key files directly to the CIRCUITPY file-system.

To do this, replace this block of code (https://github.com/adafruit/Adafruit_Ci ... ate.py#L89) with the code below:
Code: Select all | TOGGLE FULL SIZE

# Get device certificate
try:
    with open("YOUR_DEVICE_CERT.pem.crt", "rb") as f:
        DEVICE_CERT = f.read()
except ImportError:
    print("Certificate (YOUR_DEVICE_CERT.pem.crt) not found on CIRCUITPY filesystem.")
    raise
 
# Get device private key
try:
    with open("PRIVATE_KEY.pem.key", "rb") as f:
        DEVICE_KEY = f.read()
except ImportError:
    print("Key (PRIVATE_KEY.pem.key) not found on CIRCUITPY filesystem.")
    raise

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: minimqtt_certificates.py

by inghal on Mon Jun 22, 2020 5:20 pm

Thank you brubell, it worket very well.

But when executing
client.connect()
I got the following error:
>>> print("Attempting to connect to %s" % client.broker)
Attempting to connect to lambda2.inghal.net
>>> client.connect()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/adafruit_minimqtt.py", line 238, in connect
File "/lib/adafruit_minimqtt.py", line 238, in connect
MMQTTException: ('Invalid broker address defined.', RuntimeError('Expected 01 but got 00',))

I'm using Feather M4 express with circuitpython 5.3.0 and adafruit AirLift-ESP32 breakout .
(I'm also using an selfsigned CAcert)
inghal
 
Posts: 7
Joined: Thu Sep 06, 2012 6:29 pm

Re: minimqtt_certificates.py

by brubell on Tue Jun 23, 2020 10:25 am

What version of nina-fw (https://github.com/adafruit/nina-fw) is running on the ESP32 module?

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: minimqtt_certificates.py

by inghal on Tue Jun 23, 2020 1:13 pm

brubell wrote:What version of nina-fw (https://github.com/adafruit/nina-fw) is running on the ESP32 module?


Version 1.2.2

The problem is in the ssl/tls system. Once I switched to disable ssl/tls everything works fine.
Thanks for helping.
inghal
 
Posts: 7
Joined: Thu Sep 06, 2012 6:29 pm

Re: minimqtt_certificates.py

by brubell on Wed Jun 24, 2020 10:45 am

inghal wrote:
brubell wrote:What version of nina-fw (https://github.com/adafruit/nina-fw) is running on the ESP32 module?


Version 1.2.2

The problem is in the ssl/tls system. Once I switched to disable ssl/tls everything works fine.
Thanks for helping.


Could you update to the latest version of nina-fw by following this guide?

https://learn.adafruit.com/upgrading-esp32-firmware

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: minimqtt_certificates.py

by inghal on Wed Jun 24, 2020 4:25 pm

No, it dosn't work.

$ esptool.py --port /dev/ttyACM0 --before no_reset --baud 115200 write_flash 0 NINA_W102-1.6.0.bin
esptool.py v3.0-dev
Serial port /dev/ttyACM0
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header

I'm using the arduino passthrough method.
inghal
 
Posts: 7
Joined: Thu Sep 06, 2012 6:29 pm

Re: minimqtt_certificates.py

by brubell on Thu Jun 25, 2020 5:06 pm

Did you solder the 3 control pins underneath the AirLift ESP32 breakout together: https://learn.adafruit.com/upgrading-es ... -3041624-1

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: minimqtt_certificates.py

by inghal on Fri Jun 26, 2020 5:28 am

brubell wrote:Did you solder the 3 control pins underneath the AirLift ESP32 breakout together: https://learn.adafruit.com/upgrading-es ... -3041624-1


There are no control pins underneath! Adafruit product id 4201
inghal
 
Posts: 7
Joined: Thu Sep 06, 2012 6:29 pm

Re: minimqtt_certificates.py

by brubell on Fri Jun 26, 2020 9:28 am

Are your S.S pin, ACK pin, and RESETN pins connected according to the pin definitions in the sketch?

https://learn.adafruit.com/upgrading-es ... 3041428-18

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: minimqtt_certificates.py

by inghal on Fri Jun 26, 2020 12:30 pm

brubell wrote:Are your S.S pin, ACK pin, and RESETN pins connected according to the pin definitions in the sketch?

https://learn.adafruit.com/upgrading-es ... 3041428-18


Yes they are.

The problem was that I also had to connect the tx and rx pins between the feather m4 express and the esp32 breakout.
I'm now running 1.6.0
inghal
 
Posts: 7
Joined: Thu Sep 06, 2012 6:29 pm

Please be positive and constructive with your questions and comments.