BME280 | Micropython driver for the BME280 sensor
kandi X-RAY | BME280 Summary
kandi X-RAY | BME280 Summary
The Bosch BME280 Environmental Sensor is a combined temperature, pressure and humidity sensor. It can communicate via I2C or SPI; this driver uses I2C. See the datasheet at for details.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Return the altitude of the forecast
- Reads the raw data from the L3 result
- Read raw data
- Calculate dew_point
- Return a tuple of the temperature and pressure
BME280 Key Features
BME280 Examples and Code Snippets
Community Discussions
Trending Discussions on BME280
QUESTION
so i was working with the bme280 and tried to make a function that reads the temperature without using the library. but for some reason it is giving me - numbers. does someone know why that is the case?
...ANSWER
Answered 2021-May-16 at 16:52The int
in Arduino environment is 16-bit long. It is used for calculations of values with the size of int
or below, but it is not sufficient to deal with 20-bit temperature value of BME280. You should use long
, which is 32-bit long, instead.
Also the shifting amounts looks wrong. According to 5.4.8 of the datasheet of BME280, The bits [3:0]
are stored in the high half of 0xFC, bits [11:4]
are stored in 0xFB and bits [19:12]
are stored in 0xFA. The shift amount should match these.
In conclusion, the lines
QUESTION
I am working in a project where I need to show external data (from an ESP32 with an BME280 sensor) over a video in real time. I'm using opencv in Python to get the video from my webcam. The video working fine until I put the code for get the sensor data over the video, it turn very slow and freezing every 1/2 second (related with the delay in ESP32 code). Too I found that timeout (in python code) has a very important role... if I put it in 0 the video flow fine, but the data cant show properly. So I understand that readline() in my code has a blocking behaviour, if it doesn't receiver the last character of the line ("\n"), it can't to continue in the loop "while". The question is, how I can to redefine my code for avoid that??
Python code:
...ANSWER
Answered 2021-Apr-12 at 09:47I can immediately think of three ways to solve your problem.
A simple solution is to read the temperature from ESP32 in non-blocking way. As a useful hack you can be specify a very small timeout value when creating the pyserial port - say 1 ms. Then readline()
will return nothing if there's no data in the serial buffer from the ESP32. When that happens, simply skip updating the variable rawString
. See the notes on readline()
QUESTION
I recently started working on a small driver for the raspberry pico and the bme280 sensor. I wanted to use the official bosh API written in C and therefore decided to write all the code in C using the micropython C api to write usermodules. I managed to get my code compiled into a UF2 file and my module shows up when I try to list the modules with help('modules')
. When I import my module the class with the driver code shows up in dir(mymodule)
but when I try to create an object the terminal connected to the PICO hangs and doesn't respond anymore.
ANSWER
Answered 2021-Apr-06 at 08:58You have .print
defined but it doesn't exist in your code.
QUESTION
I'm trying to setup a Raspberry Pi 3 B+ with a Waveshare BME280 Environmental Sensor. I followed this guide to wire the cables and ran the supplied bme280.py script. My sensor has 2 additional cables, the CS and ADDR/MISO, that are not present in the model on the guide but the rest are plugged in to the same GPIO pins. The I2C and SPI interfaces are enabled and I am running the latest Raspbian OS Lite.
When I run the script, I get the following message:
Traceback (most recent call last):
File "bme280.py", line 172, in
main()
File "bme280.py", line 161, in main
(chip_id, chip_version) = readBME280ID()
File "bme280.py", line 56, in readBME280ID
(chip_id, chip_version) = bus.read_i2c_block_data(addr, REG_ID, 2)
OSError: [Errno 121] Remote I/O error
There's another odd issue: when I run i2cdetect -y 1
I get every line with dashes, but if I run it a second time immediately after, I get x77 to show up, but x76 still doesn't.
I found a similar thread and tried modifying my /boot/config.txt file by adding i2c_baudrate=100000
and rebooting but that did not fix it.
I made sure to test the pi using gpiotest and the results came back as
Skipped non-user gpios: 0 1 28 29 30 31
Tested user gpios: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Failed user gpios: None
I had gotten similar issues using a DHT11 sensor and running Adafruit libraries and got an error signifying there was no data flowing from the sensor. I tried using several different sensors and Raspberry Pis and have reinstalled the OS several times over. At this point, I'm not sure how to proceed. Any help is appreciated.
...ANSWER
Answered 2021-Mar-09 at 01:43I managed to create a very hacky solution to this issue. Since i2cdetect seems to only read devices on the second (or later) times it is run, I decided to simulate running it inside the sensor script.
I added the following lines to my code:
QUESTION
I'm trying to code a simple program for a ESP32 board. My main program is fairly simple and it has to run on a loop. On the side, the device also needs to be able to respond to HTTP requests with a very simple response.
This is my attempt (a rework of https://randomnerdtutorials.com/micropython-esp32-esp8266-bme280-web-server/):
...ANSWER
Answered 2021-Jan-09 at 19:57The problem is that s.accept()
is a blocking call...it won't return until it receives a connection. This is why it pauses your loop.
The easiest solution is probably to check whether or not a connection is waiting before calling s.accept()
; you can do this using either select.select
or select.poll
. I prefer the select.poll
API, which would end up looking something like this:
QUESTION
How can I get float values from a BME280 on a integer build using the BME280 Lua module with bme280_math?
Using the deprecated bme280 c-Module, for instance, temperature values were: temperature in °C * 100, getting float values was like:
tempFloat = tostring(temp/100).."."..temp%100
Now, with bme280 Lua module and bme280_math, the temperature is returned in °C, so on an integer build readings are now "24" instead of "24378". How to get "24378" again?
...ANSWER
Answered 2020-Dec-22 at 16:06The bme280 lua module used on an integer build will return integer values with 1°C resolution only.
QUESTION
I feel like I'm missing something obvious here and need it pointed out. I'm trying to create an instance of a struct that's a member of a class contained within a library that's been included in the current file, but inside a class I've defined myself. If I do this outside of the class, it works, but inside the class it appears to try to instantiate the struct as if it was a member of the parent class it's in.
The library is for a BME280 sensor and the struct is to pass chip settings to the constructor of the main class that drives the sensor. Not even sure how to word this problem, but hopefully the code illustrates what I'm trying to say.
If I instantiate this struct outside of a class it works fine,
...ANSWER
Answered 2020-Oct-11 at 12:42Yes it is possible to default initialize members, although in the C++ standard in-class initialization can only use =
or {}
. This is better answered here.
Using parentheses is confusing since it looks like a function declaration.
IntelliSense is most likely complaining about error types since it thinks you are declaring a function with invalid types and a return type of BME280I2C::Settings
(assuming the setting values you provided are values and not types).
The initilization could look like this assuming there exists a non-explicit constructor (notice the change from ()
to {}
)
QUESTION
Fisrt of all i want to say that i am new in python I am trying to get the temperature value of a BME280 sensor and display it into a label widget via tkinter.
Here is my sample code:
...ANSWER
Answered 2020-Jul-11 at 17:46This is your code updated
QUESTION
Long story short, I am using RTCZero library to create an alarm to wake up my arduino, after some time, but I have ascertained, that when I add more sensors, with more libraries, RTC library is not compatible with them. I thought that it is caused my including , but problem still persists. Any solution?
!!!EDIT!!!
More precisely, I found, that problematic libraries are only these: Here you can download whole library (includes in this script are in). https://github.com/charles-the-forth/openCanSat-library
...ANSWER
Answered 2020-Mar-06 at 07:29In the RTCZero.cpp
you can see #include
which is standard header and library rely on it.
In linked library (openCanSat) you can see Time.h and Time.cpp which is some custom implementation of time functions and it's completely incompatible with standard time.h. However, because Arduino IDE is such a dummy IDE, the Time.h
took precedence before time.h
(this won't happen on OS with case sensitive filesystems - like linux, osx, ...). So you can either rename Time.h in the library, or you can try changing #include
to #include
, but it's probably including time.h too, so...
QUESTION
I started the following code to handle a Bosch BME280 sensor with a Nucleo-F446ZE and a Nucleo-F411RE boards.
...ANSWER
Answered 2020-Jan-05 at 20:20No, between HAL_I2C_Mem_Read
and the HAL_I2C_Master_Transmit
, wait
, HAL_I2C_Master_Receive
procedure is only a nuance cf How do I use the STM32CUBEF4 HAL library to read out the sensor data with i2c? . If you know what size of data you want to receive you can use the HAL_I2C_Master_Transmit
, wait, HAL_I2C_Master_Receive
procedure.
A C++ HAL I2C example is in https://letanphuc.net/2017/05/stm32f0-i2c-tutorial-7/
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install BME280
You can use BME280 like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page