Wei1234c / Elastic_Network_of_Things_with_MQTT_and_MicroPython

Using MicroPython on ESP8266 modules to form an elastic network of things with MQTT broker (Mosquitto).
GNU General Public License v3.0
10 stars 5 forks source link

Running out of Memory #1

Closed bthome closed 6 years ago

bthome commented 6 years ago

Thank you for contributing this. I have been working with ESP8266 sensors for a while and came across your project and wanted to try and incorporate it into my Home Automation setup.

I did get it working and it does the basics (blink), however when I try to upload a script for execution I run into memory constraint problems. It looks like 30K is allocated and only 5k is available. When it tries to upload the file it fails on allocating ~800 bytes. I'm compiled to .MPY and get the same error.

The failure occurs on the return of the OrderedDict.

def get_OrderedDict(self, dictionary):
        return OrderedDict(sorted(dictionary.items()))

Can you recommend possible next steps to resolve?

Wei1234c commented 6 years ago

The get_OrderedDict function is used merely to keep the STDOUT printout in order, and in a practical sense can be omitted entirely. Therefor, you can delete the get_OrderedDict function and bypass the function wherever it's used to save some memory.

Also, for your information, I personally have gradually migrate to ESP32, which has more memory and less constrain. Code for ESP32 is at : https://github.com/Wei1234c/MQTT_bridged_workers

bthome commented 6 years ago

Hey. Thanks for getting back to me. I resolved the issue (out of memory heap space allocation). I ended up compiling the Micropython firmware and "froze the bytecode" for your implementation. I now have plenty of room to allocate for other custom modules\scripts that I plan to integrate in.

I look forward to any new projects that you have coming up...and if you find any gotchas I should keep my eye on please let me know.

Thanks, Brian

Wei1234c commented 6 years ago

Close for now.