Atmospheric pressure sensor BMP280_spi

Reference tutorial


SCM BMP280 (GY-BM E/P 280 module) atmospheric pressure and temperature sensor use detailed explanation
STM32 driver BMP280 module

Note: When writing, the highest position is 0, and when reading, the highest position is 1. Please refer to the data sheet below for details



Bmp280 module installation diagram





Source Code Path:
driver_210519mp280_spi1

Powering code: bmp280_drv.c
Compiler:
1、Copy “driver_210519 mp280_spi1” to the “lichee” directory in tina-d1 sdk
2、Enter bmp280_spi1 and execute the “make” command to generate the bmp280_drv.ko file
3、Copy to the development board, execute insmod bmp280_drv.ko, load the driver module and view the device “/dev/bmp280”, as shown below




Device tree file and adding nodes:
driver_210519sunxi-dts board.dts

  1. rvboards_bmp280:bmp280@0{
  2. device_type = "spibmp280";
  3. compatible = "tina-d1,rvboards-bmp280";
  4. spi-max-frequency = <500000>;
  5. reg = <0>;
  6. status = "okay";
  7. cs_gpio = <&pio PD 10 GPIO_ACTIVE_HIGH>;
  8. };


User layer test program: bmp280_user.c
Compile and execute:
1、Copy bmp280_user.c to the development board
2、Execute gcc -o bmp280_user bmp280_user.c to compile and generate bmp280_user execution program
3、Test command: ./bmp280_user /dev/bmp280