peterhinch / micropython-mqtt

A 'resilient' asynchronous MQTT driver. Recovers from WiFi and broker outages.
MIT License
549 stars 116 forks source link

Tutorial installation needs clarification #52

Closed JJGO closed 2 years ago

JJGO commented 3 years ago

I'm following the tutorial to do the installation on a ESP8266, and I'm stumped about what I need to do. I tried copying mqtt_as.py and config.py, and got a memory error which was expected given the warning.

Could you provide further reference or pointers about how to cross-compile the module or build it as frozen bytecode?

The module is too large to compile on the ESP8266. It must either be cross compiled or (preferably) built as frozen 
bytecode: copy mqtt_as.py to esp8266/modules in the source tree, build and deploy. Copy config.py to the filesystem 
for convenience.
JJGO commented 3 years ago

~I tried cross compiling with mpy-cross mqtt_as.py and copying the generated mqtt-as.mpy and got an identical memory error to when it was copied as raw code.~

I needed to delete the mqtt-async.py I was not aware the .py over .mpy priority. Adding pointers to pip install mpy-cross and mpy-cross ./mqtt_as.py to the tutorial would be great.

Also, clarifying the the frozen bytecode part would be great.

peterhinch commented 3 years ago

Information on these issues belongs in MicroPython documentation rather than in that for any one specific application.

The official docs are here. The last time I looked the official docs were a little out of date with regard to manifests. See my notes here.

If you find problems with the official docs there is always the option of raising an issue or PR against them.

ebolisa commented 2 years ago

Hi, thanks for sharing. In the range.py file a msg is published but sub_cb() is not called. How do I subscribe so I can activate my relays? Also, how do I get wlan parameters w/o modifing the lib? TIA

peterhinch commented 2 years ago

In my testing sub_cb is called. A message is printed and the blue LED flashes whenever a message is received. If this isn't occurring I would check that it is being transmitted to the correct topic. This may be verified using mosquitto_sub on a PC.

Please could you explain your query about wlan parameters.

ebolisa commented 2 years ago

Thank you for getting back to me. I solved the first part of the problem this morning. I had a space in the topic's string. As for the wlan, I usually pub the rssi so I can monitor its strength via a node-red gauge. I can visualize the self.dprint(s.ifconfig()) and self.dprint(s.status('rssi')) data from the library, but I need the call often the rssi from the main loop so it can be published. I tried library.function.variable but it doesn't work. Perhaps, it may be a good idea for the library to share said info so it can be available. BTW, I'm not a programmer, so, I apologize for the question.

peterhinch commented 2 years ago

The range_ex.py example publishes RSSI.

ebolisa commented 2 years ago

Will loot at it. Thank you again.