can't await mqtt.simple publish method
Hi
I'm using umqtt.simple and there is problem when i await mqtt.publish in my code !
'NoneType' object isn't iterable
Is there any way to solve this issue ?
Or use other lib like https://github.com/peterhinch/micropython-mqtt/blob/master/mqtt_as ?
AttributeError: 'NoneType' object has no attribute 'write'
Hello there,
I'm currently trying to send a message from my Raspberry Pi Pico W to my Node-Red through MQTT.simple with the following snippet of code:
while True:
pin_state = gpio_pin.value()
print(f"Pin state: {pin_state}")
client.publish(MQTT_TOPIC, str(pin_state))
time.sleep(1)
"pin_state" is working as intended so I have no problems collecting the data I wish to but when I run the program I always get the error:
AttributeError: 'NoneType' object has no attribute 'write'
there was a issue previously where someone was suffering from the same issue and the two replies stated that you needed to connect to the broker first, which I have confirmed I am doing, and that it's possible that there isn't a connection to the broker at all; I believe there to be a connection between my Pi and the Broker because no errors are presented and the node within Node-Red does react to the connection.
If any more information is needed to help me, please do ask and I look forward to any help given!
The umqtt.simple module is sync.You'd better use peterhinch's uasync mqtt lib.
While you only need subscribe to some topic.
my solution is :
@2niuhe thanks, but using umqtt_async have its own problem : https://forum.micropython.org/viewtopic.php?f=15&t=7144
thanks for your solution but i had problem in publish part not others .