Bosch BME280 driver

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
pythoncoder
Posts: 1564
Joined: Fri Jul 18, 2014 8:01 am

Re: Bosch BME280 driver

Postby pythoncoder » Fri Jul 22, 2016 10:23 am

When you unzip it you should see a directory xtensa-lx106-elf - ensure your PATH points to it and you should be good to go, simply by moving to micropython/esp8266 in your clone of the source and following the build instructions. There is no installation required.

The only 'gotcha' I encountered is that the directory 'xtensa-lx106-elf' itself contains a subdirectory 'xtensa-lx106-elf'. Ensure that it looks like this when you unzip it.

Code: Select all

[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython
$ cd xtensa-lx106-elf
[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/xtensa-lx106-elf
$ pwd
/mnt/qnap2/data/Projects/MicroPython/xtensa-lx106-elf
[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/xtensa-lx106-elf
$ ls -l
total 736
drwx------ 2 adminpete adminpete   4096 Jul 19 13:29 bin
-rw------- 1 adminpete adminpete 725887 Jul 10 18:49 build.log.bz2
drwx------ 3 adminpete adminpete   4096 Jul 19 13:30 include
drwx------ 4 adminpete adminpete   4096 Jul 19 13:30 lib
drwx------ 3 adminpete adminpete   4096 Jul 19 13:29 libexec
drwx------ 4 adminpete adminpete   4096 Jul 19 13:30 share
drwx------ 6 adminpete adminpete   4096 Jul 19 13:30 xtensa-lx106-elf
[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/xtensa-lx106-elf
$ echo $PATH
/mnt/qnap2/Scripts:/mnt/qnap2/data/Projects/MicroPython/xtensa-lx106-elf/bin:/home/adminpete/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/xtensa-lx106-elf
$
Peter Hinch

warren
Posts: 73
Joined: Tue Jul 12, 2016 5:47 pm

Re: Bosch BME280 driver

Postby warren » Fri Jul 22, 2016 1:58 pm

pythoncoder wrote:When you unzip it you should see a directory xtensa-lx106-elf - ensure your PATH points to it and you should be good to go, simply by moving to micropython/esp8266 in your clone of the source and following the build instructions. There is no installation required.

Success!! Thank you so much.

And one further question:

In the ESP8266 folder are two folders: "modules" and "scripts"

Where is the documentation about these two folders and the difference between them?


Thanks again - much appreciated...

User avatar
pythoncoder
Posts: 1564
Joined: Fri Jul 18, 2014 8:01 am

Re: Bosch BME280 driver

Postby pythoncoder » Fri Jul 22, 2016 4:11 pm

warren wrote:...In the ESP8266 folder are two folders: "modules" and "scripts"

Where is the documentation about these two folders and the difference between them?
...
The modules directory is for modules to be frozen as bytecode. I wish I knew the purpose of the scripts directory. Frozen bytecode is a very recent feature for ESP8266 and I'm not aware of any official documentation.
Peter Hinch

User avatar
dhylands
Posts: 2374
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: Bosch BME280 driver

Postby dhylands » Fri Jul 22, 2016 4:18 pm

If my reading of the makefile is correct, scripts should just contain python source that you want frozen (but not precompiled), whereas modules will contain scripts which get precompiled into bytecode.

warren
Posts: 73
Joined: Tue Jul 12, 2016 5:47 pm

Re: Bosch BME280 driver

Postby warren » Fri Jul 22, 2016 4:59 pm

OK thank you - this has been very helpful.

angel
Posts: 1
Joined: Sun Aug 14, 2016 8:00 am

Re: Bosch BME280 driver

Postby angel » Sun Aug 14, 2016 8:03 am

Hello Jim,

You mention you know what changes to do to get more accurate readings?
I have connected the WiPy to the sensor but the readings are off.

Thank you!

Angel

jiemde
Posts: 10
Joined: Sun Jun 19, 2016 12:07 pm
Location: Belgium
Contact:

Re: Bosch BME280 driver

Postby jiemde » Tue Sep 27, 2016 6:24 pm

Hi all, I'm trying to read an BME280 module first with an "Amica" nodemcu with only 4 Mbits of flash memory without success, and now with an version 3 with 32Mbits of Flash memory, but after transfering the bme280 library, when I try to execute the main.py with:

Code: Select all

import machine
import bme280

i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))
bme = bme280.BME280(i2c=i2c)

print(bme.values)


I will obtain an error message that there is no "BME280" in the module "bme280"

When, in esplorer, I do

Code: Select all

 import bme280
>>> dir(bme280)
['__name__']


Effectively there is no "BME280" in the list !

If someone have an idea where I go wrong, thanks in adavnce for solution.
Best regards

Jiemde

jiemde
Posts: 10
Joined: Sun Jun 19, 2016 12:07 pm
Location: Belgium
Contact:

Re: Bosch BME280 driver

Postby jiemde » Tue Nov 08, 2016 2:05 pm

pythoncoder wrote:Assuming you've double checked that bme280.py on the ESP8266 is correct, I suspect you have run out of RAM. Are you running it from webrepl? It might be worth not running webrepl and using a direct connection. Executing the following after the error may be informative:

Code: Select all

import micropython
micropython.mem_info()



Hi All, don't really understand why I don't receive any answer to the same problem with an ESP8266 with 4Mbyte !
Best regards

Jiemde

User avatar
kfricke
Posts: 327
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Bosch BME280 driver

Postby kfricke » Tue Nov 08, 2016 4:14 pm

The problem is not the size of the flash (ROM). It is based on the limits of heap (RAM). What firmware build number/version are you using?

The BME280 driver is quite a memory hog (uses attributes instead of the suggested functions to access the sensor values, but is kindly developed with absence of floating point support in mind!), but I do use this together with my HDC1008 driver and quite large "user space code" modules loaded from flash filesystem. They do implement my sensor network nodes. Only uMQTT (robust and simple) is baked as frozen bytecode into my firmware image.

upymar
Posts: 2
Joined: Sat Feb 04, 2017 7:47 am

Re: Bosch BME280 driver

Postby upymar » Sat Feb 04, 2017 8:10 am

[quote="catdog2"]I have modified the driver quite a bit for the ESP8266:

https://github.com/catdog2/mpy_bme280_esp8266

The main goal was to make It less memory hungry, especially during import. Worked I think. I only tested it with a BMP280 as I don't possess a BME280 yet.[/quote]

I use NodeMCU with esp8266-20170108-v1.8.7.bin and BME280

I always have to call twice
[code]import bme280[/code]
as I get this error after the first call:
[code]Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "bme280.py", line 5[/code]

After
[code]bme = bme280.BME280(i2c=i2c)[/code]
I get:
[code]Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'BME280'[/code]

Also, I am unsure about the pin numbers in
[code]i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))[/code]

Could you please help me?


Return to “Drivers for External Components”

Who is online

Users browsing this forum: No registered users and 1 guest