STM32_BMP280
单片机源程序如下:
- #include "sys.h"
- #include "delay.h"
- #include "usart.h"
- #include "led.h"
- #include "myiic.h"
- #include "bme280.h"
- int main(void)
- {
- float bmp280_temp;
- float bmp280_press;
- float bmp280_humi;
- float high;
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置中断优先级分组2
- uart_init(9600); //初始化USART
- LED_Init(); //初始化LED
- IIC_Init();
- delay_init();
- bme280Init();
- while(1)
- {
- bme280GetData(&bmp280_press,&bmp280_temp,&bmp280_humi,&high);
- delay_ms(1500);
- LED0=!LED0;
- printf("bmp280_press:%f\r\n",bmp280_press);
- delay_ms(100);
- printf("bmp280_temp :%f\r\n",bmp280_temp);
- delay_ms(100);
- printf("bmp280_humidity :%f\r\n",bmp280_humi);
- delay_ms(100);
- printf("bmp280_high :%f\r\n\r\n",high);
- }
- }
复制代码
所有资料51hei提供下载:
BME280_STM32.zip
(2.88 MB, 下载次数: 488)
|