Page 1 of 1

import bme280.py fails

Posted: Fri Apr 03, 2020 11:01 pm
by der_kps
Hello,
I've some programms running well in an ESP32 environment and I want to run them on a
D1mini Pro (16MB) with ESP8266 firmware (flashed by uPyCraft).
Several Problems occur. One of them is this:
import bmp280.py is ok. I get at last the answer >>>
import bme280.py fails with the answer:

Code: Select all

download ok
excec(open('bmy280.py').read(),globals())
Traceback (most recent call last):
   File "<stdin>", line 1 in <module>
MemoryError:
>>>
This bme280.py runs well with ESP32. I tried 3 others.

What's that?

Regards

Re: import bme280.py fails

Posted: Sat Apr 04, 2020 11:25 am
by jimmo
The ESP8266 has very limited RAM, so the way that your IDE is doing the exec(open(file)) thing is particularly difficult. This requires it to have the entire text of the program in RAM, plus the parse tree, and then the compiled bytecode.

You'd likely have better luck if you put the file on the filesystem and imported it hte normal way (I think that's what you're saying works). That way you only need the last two.

If you make a .mpy you'll only need the frozen bytecode in RAM.

And if you freeze it into your firmware you won't need any RAM.

Re: import bme280.py fails

Posted: Sun Apr 05, 2020 8:13 pm
by der_kps
Ok,the small RAM (<36KB) might be a problem.
But I think I don't understand the solution and have tried this:
I open the bme280.py (or any other library) and download this file into the device.
I do not run it (F5)!

BMP280 (7kB) is a Sensor for Temp + Press; BME280 (11kB) is a Sensor for Temp + Press + Hum with a larger library.

Using import bmp280 in a corresponding program works.
Using import bme280 in a corresponding program does not work.

I get:

Code: Select all

download ok
exec(open('openbme280_p-h-t.py').read(),globals())
T
:(