Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.
0

Pyportal CircuitPython MiniMQTT problems and errors
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Pyportal CircuitPython MiniMQTT problems and errors

by Jeeg76 on Wed Apr 22, 2020 9:14 am

Hi,
i am trying to execute the sample code of this guide https://learn.adafruit.com/mqtt-in-circuitpython, i have updated the libraries and circuitpython is the latest stable version (5.2.0).
I have the following problem: the example with adafruit broker works perfectly. The example where I use an internal broker (mosquito on home assistant, which works great with other clients) doesn't work at all. In particular, it gives me the error: Can't convert 'str' object to bytes implicitly. This happens in all the example files that I found for library.
this is like my code:
Code: Select all | TOGGLE FULL SIZE
.......... # Connect to WiFi
print("Connecting to WiFi...")
wifi.connect()
print("Connected!") #[b]here work great and the pyportal connect[/b]
 
# Initialize MQTT interface with the esp interface
MQTT.set_socket(socket, esp)
 
# Set up a MiniMQTT Client
client = MQTT.MQTT(
    broker=secrets["broker"],
)
 


for the broker, in the secrets file i have add
broker : "MY_IP" --- like 192.168.ecc
for the test i dont have user and password
the broker is up and running.
it seems to be related to the interpretation of the IP address, but I am a complete beginner and I can't solve ....
If i use adafruit io , it works perfectly
Thanks for your help

Jeeg76
 
Posts: 5
Joined: Sun Mar 15, 2020 1:11 pm

Re: Pyportal CircuitPython MiniMQTT problems and errors

by Jeeg76 on Thu Apr 23, 2020 11:52 am

[SOLVED] I need to write broker's IP in this way broker = "http://192.168.ecc.ecc) and work!

Jeeg76
 
Posts: 5
Joined: Sun Mar 15, 2020 1:11 pm

Please be positive and constructive with your questions and comments.