Bosch BME280 driver
Re: Bosch BME280 driver
I just noticed that there is 1.9 release for esp8266.
Will I have more success with it getting the BME280 to work?
Will I have more success with it getting the BME280 to work?
Re: Bosch BME280 driver
V1.9 should not behave differently. Are you sure that you loaded bme280.py completely to your file system?
Execute:
The 7th element of the tuple is the file size. That should match the file size on your PC.
Execute:
Code: Select all
import uos
uos.stat("bme280.py)"
Re: Bosch BME280 driver
I did upload the bme280.py file via webrepl. Initially I had the same error on an esp8266 board when calling:
bme = bme280.BME280(i2c=i2c)
attributeerror: 'module' object has no attribute 'bme280'
I had to reset the board. After the reset it did work.
When I changed something in the bme280.py file I always had to reset the board after uploading it to the esp8266 board.
Does anyone know why it only works after a reboot/reset?
bme = bme280.BME280(i2c=i2c)
attributeerror: 'module' object has no attribute 'bme280'
I had to reset the board. After the reset it did work.
When I changed something in the bme280.py file I always had to reset the board after uploading it to the esp8266 board.
Does anyone know why it only works after a reboot/reset?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Bosch BME280 driver
That's how Python works. Try the following under Python 3 on a PC. Create this file:
rats29.py:
At the REPL issue
It will print "foo 1".
Now edit rats29.py to print something else. You'll find it still prints "foo 1" until you start a new Python session or reload the module. See https://stackoverflow.com/questions/437 ... ule#437591 for more information on reloading and its pitfalls. There is no equivalent in MicroPython and, as the link indicates, a reset is the best way.
rats29.py:
Code: Select all
def foo():
print('foo 1')
Code: Select all
import rats29
rats29.foo()
Now edit rats29.py to print something else. You'll find it still prints "foo 1" until you start a new Python session or reload the module. See https://stackoverflow.com/questions/437 ... ule#437591 for more information on reloading and its pitfalls. There is no equivalent in MicroPython and, as the link indicates, a reset is the best way.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Bosch BME280 driver
I tried it again with micropython release 1.9.2 on my esp8266
What has changed is that
seems to work correctly now.
But I am very unsure about the correct I2C wiring.
I have a BME280 for I2C and SPI from adafruit that has the following pinout:
VIN, 3Vo, GND, SCK, SDO, SDI, CS
Besides VIN and GND I connected SCK to D1 (GPIO5) and SDI to D2 (GPIO4).
After
I get:
I think that the pins in
aren't correct but I don't know better.
What has changed is that
Code: Select all
>>> import machine
>>> import bme280
But I am very unsure about the correct I2C wiring.
I have a BME280 for I2C and SPI from adafruit that has the following pinout:
VIN, 3Vo, GND, SCK, SDO, SDI, CS
Besides VIN and GND I connected SCK to D1 (GPIO5) and SDI to D2 (GPIO4).
After
Code: Select all
>>> i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))
>>> bme = bme280.BME280(i2c=i2c)
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "bme280.py", line 74, in __init__
OSError: [Errno 19] ENODEV
Code: Select all
>>> i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))
Re: Bosch BME280 driver
Does i2c.scan() return anything? The wiring seems correct, comparing with https://learn.adafruit.com/adafruit-bme ... g-and-test
Re: Bosch BME280 driver
Thanks for your reply.
Does this help?
deshipu wrote:Does i2c.scan() return anything?
Code: Select all
>>> import machine
>>> import bme280
>>> i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))
>>> i2c.scan()
[119]
Re: Bosch BME280 driver
Well, your driver defaults to address 118 (0x76), so maybe try this:
Code: Select all
bme = bme280.BME280(i2c, address=119)
Re: Bosch BME280 driver
Thank you so much, this did help me a lot.deshipu wrote:Well, your driver defaults to address 118 (0x76), so maybe try this:
Code: Select all
bme = bme280.BME280(i2c, address=119)
I changed your suggestion (that didn't work)
Code: Select all
bme = bme280.BME280(i2c, address=119)
Code: Select all
bme = bme280.BME280(i2c=i2c, address=119)
Thanks and have a nice day
-
- Posts: 19
- Joined: Wed Jul 26, 2017 5:15 pm
Re: Bosch BME280 driver
Hi. I am using the BME280 sensor with ESP-12.
i measure indoor. (unused room) and the place of the esp board does not change
Im running script one per hour an goes deepsleep.
I use 2 lipo battery and HT7333 ldo.
My questions is why the pressure values are unstable.
Thanks
i measure indoor. (unused room) and the place of the esp board does not change
Im running script one per hour an goes deepsleep.
I use 2 lipo battery and HT7333 ldo.
My questions is why the pressure values are unstable.
Code: Select all
DATE TEMP HUM PRESSURE
2017-09-18 12:30:05 22.37 48.56 905.53
2017-09-18 11:30:03 22.34 48.54 905.51
2017-09-18 10:30:03 22.33 47.78 906.03
2017-09-18 09:30:04 21.95 47.27 906.07
2017-09-18 08:30:03 21.91 47.25 906.13
2017-09-18 07:30:05 21.92 46.88 905.95
2017-09-18 06:30:03 21.99 46.88 905.57
2017-09-18 05:30:04 22.18 47.53 905.47
2017-09-18 04:30:17 22.15 47.52 905.46
2017-09-18 03:30:03 22.23 47.88 904.46
2017-09-18 02:30:02 22.32 48.18 905.47
2017-09-18 01:30:02 22.44 48.24 905.72
2017-09-18 00:30:02 22.59 48.34 905.79
2017-09-17 22:30:07 22.68 49.32 905.85
2017-09-17 21:30:03 22.70 49.51 906.45
2017-09-17 20:30:02 22.83 49.25 905.34
2017-09-17 19:30:02 22.94 49.23 904.63
2017-09-17 18:30:02 23.68 46.66 903.78
2017-09-17 17:30:02 23.64 46.65 903.80
2017-09-17 16:30:02 23.53 46.66 903.86
2017-09-17 15:30:04 22.37 48.57 904.82
2017-09-17 14:30:02 22.33 48.56 904.84
2017-09-17 13:30:02 22.19 48.55 905.46
2017-09-17 12:30:02 22.11 48.43 906.13
2017-09-17 11:30:02 22.05 48.07 906.80
2017-09-17 10:30:03 21.87 46.71 907.55
2017-09-17 09:30:02 21.84 46.71 907.52
2017-09-17 08:30:02 21.60 45.73 907.23
2017-09-17 07:30:02 21.62 45.75 907.16
2017-09-17 06:30:02 21.73 46.05 906.85
2017-09-17 05:30:02 21.80 46.46 905.99
2017-09-17 04:30:02 21.90 47.28 906.91
2017-09-17 03:30:02 22.14 48.44 906.70
2017-09-17 02:30:02 22.11 48.44 906.72
2017-09-17 01:30:04 22.37 49.31 906.85
2017-09-17 00:30:02 22.34 49.31 906.43
2017-09-16 23:30:02 22.43 50.92 905.60
2017-09-16 22:30:02 22.59 52.17 906.71
2017-09-16 21:30:02 22.95 52.58 906.48