Zephyr and Nordic nRF Connect SDK - 03b Temperature, pressure and humidity from a Bosch BME280
ฝัง
- เผยแพร่เมื่อ 26 มิ.ย. 2024
- Zephyr and Nordic nRF Connect SDK - 03b Reading temperature, pressure and humidity from a Bosch BME280 (over I²C and using a driver)
nRF Connect SDK is the new SDK from Nordic Semiconductor and replaces the old nRF5 SDK. It is based on the Zephyr real-time operating system. Zephyr supports multithreading. The hardware is configured via a device tree and components are activated or deactivated via a configuration file. Internal and external resources such as I²C-bus or sensors can be controlled via drivers. The nRF connect SDK supports the network technologies OpenThread, ZigBee, BLE and Matter. Visual Studio Code can be used as a development environment. In this video we read out the temperature, pressure and humidity from a Bosch BME280 I²C-sensor with Zephyr. We will do this on two ways. First we send direct I²C commands and second we using the devicetree and a sensor driver.
You can support me at Patreon:
/ wsnandiot
##Hardware###########
Developer board nRF52840-dk:
www.nordicsemi.com/Products/D...
Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor
www.adafruit.com/product/2652
00:00 Introduction
01:20 Pin connections and I2C-address
01:13 Compensation registers
07:29 Measurement registers
08:20 Data structure for bme280
08:58 Buffer arrays
10:16 Reading chip ID
11:36 Reading temperature compensation registers
12:55 Reading pressure compensation registers
13:58 Reading humidity compensation registers
15:39 Reading uncompensated temperature, pressure and humidity
16:46 Compensation functions
23:43 Outro - วิทยาศาสตร์และเทคโนโลยี
OMG! I can't believe how complicated it was, surely after seeing this I would have preferred to try it with the MCP9808 sensor, but unfortunately I couldn't find one like yours. Thanks for this video, keep it up because it helps a lot of students to get into the Zephyr environment and that's very helpful. Regards friend. 💪
I had an issue with my BMP280 sensor that the value printed out would not change. For anyone else that this might help I had looked in the driver code and the datasheet and figured out that I had to turn the device from sleep mode to normal mode (or forced). I did this by adding these lines:
#define BME280_TEMP_OVER (3
hello, first of all I'd like thank you a lot for making such videos over nRF Connect SDK, I wanted to request you if you could make a video about reading an NDEF message over nfc that would help me a lot in my project thank you.
Thanks so much, it helped me a lot. I prefer the MCP9808 but this was the one I had. Congratulations for this video!
@wsniot Thank you for sharing, could you maybe look at the LSM303AH device from ST, there is currently no zephyr driver for this, only for a older part that is discontinued.
In many applications I would recommend to use an accelerometer without driver anyway, because in general a high sampling rate is needed. I'm not sure if a driver in Zephyr can always deliver this optimally.
In Zephyr there is a driver for LSM303DLHC most registers seem to be identical. Maybe this driver will work. Otherwise I would probably test the sensor first with an Arduino, look at the library there and slowly approach the programming. Probably I would use I²C at the beginning, because it is easier to implement and then read the WHO_AM_I register first.
Hey, I was watching your NRF Series and I was testing the OpenThread connection. I tried to send the BME280 Temperature results by OT but I encounter a problem. When I trying to send the temperature, the other dk recieved the signal, but there was no message. I also tried to incorporate the BME code as a library but I couldn´t... You know how to do it? It will help me a lot!
Hi,
how do you know the other device receive the data? How did you send the data (UDP, CoAP)? Which format did you use (Text, binary, Json)? Did you check with a sniffer the package? Did you try to split up the task? First send fake temperature data to check if the transmitting working. Later add the sensor part.
@@wsniot When I click the button in the dk, it says "Recieved:" but with no data. I send it through CoAP. I am using a Json format, and no, i didn´t check it... I already send fake data, and the 2nd DK recieve the data correctly, but when I try to integrate the BME280 library it fails
Thanks for answering my question! It means a lot to me!
It was a very good explanation. Can I get the source code? Thanks.
Thank you for posting such great videos !! Really helpful. Is it possible to share the source code via Github?
hi I am using nrf52840dk- nrf52840 board to interface the IMU Sensor lsm6dsox using I2C using nrf connect sdk for vs code.
But I am facing error:
i'm using the code in ncs/samples/sensor/lsm6dso
here is prj.conf:
CONFIG_STDOUT_CONSOLE=y
CONFIG_I2C=y
CONFIG_SENSOR=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_LSM6DSO_TRIGGER_GLOBAL_THREAD=y
CONFIG_LSM6DSO=y
here is thr overlay file:
&pinctrl {
i2c0_default: i2c0_default {
group1 {
psels = ,
;
bias-pull-up;
};
};
i2c0_sleep: i2c0_sleep {
group1 {
psels = ,
;
low-power-enable;
};
};
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
pinctrl-0 = ;
pinctrl-1 = ;
pinctrl-names = "default", "sleep";
label = "I2C_0";
clock-frequency = ;
lsm6dso@6a {
compatible = "st,lsm6dso";
reg = ;
};
};
the probleme is when i flash my code this the output :
*** Booting nRF Connect SDK v2.5.2 ***
Testing LSM6DSO sensor in trigger mode.
Could not set sensor type and channel
can you please help me
I dont have an lsm6dso sensor, so i cannot test it. So you dont get an error warning? Can be also connection problem or a faulty sensor. You should check the I2C connection if the sensor response. If you dont have a i2c capture device try to communicate with the sensor directly.