pimoroni / bme280-python

Python library for the BME280 temperature, pressure and humidity sensor
https://shop.pimoroni.com/products/bme280-breakout
MIT License
65 stars 25 forks source link

Should setup() be called on each update? #17

Closed JimMadge closed 3 years ago

JimMadge commented 3 years ago

Hi,

When updating the sensor values the setup method is called before triggering a measurement when in forced mode, and reading the latest values.

https://github.com/pimoroni/bme280-python/blob/97c80ced20b02caa129e98c8801b31f1468ee4b0/library/bme280/__init__.py#L249-L255

Calling the method with no arguments will overwrite any arguments you may have set previous with the defaults (including setting normal mode, so it looks like the force mode logic in the if block in update_sensor may never be called) and forces a 0.1s sleep. Is it necessary to call setup this way every time?

JimMadge commented 3 years ago

Oops, missed this,

https://github.com/pimoroni/bme280-python/blob/97c80ced20b02caa129e98c8801b31f1468ee4b0/library/bme280/__init__.py#L214-L217