一、器材
BMP280,值得注意的是BMP280有2个版本,一种是3.3V的,一种是5V的,我这里用的是5V的
arduino uno
二、接线
BMP280 | arduino uno |
VCC | 5V |
GND | GND |
SCL | D3 |
SDA | D2 |
三、程序
mixly程序
arduino程序
#include <SoftwareWire.h>
#include "Adafruit_BMP280_Soft.h"
SoftwareWire Wire_2_3(2, 3);
Adafruit_BMP280_Soft bmp = Adafruit_BMP280_Soft(&Wire_2_3);
void setup(){
Serial.begin(9600);
bmp.setSampling(Adafruit_BMP280_Soft::MODE_NORMAL,
Adafruit_BMP280_Soft::SAMPLING_X2,
Adafruit_BMP280_Soft::SAMPLING_X16,
Adafruit_BMP280_Soft::FILTER_X16,
Adafruit_BMP280_Soft::STANDBY_MS_500);
while (!(bmp.begin(0x76))) {
Serial.println("没有搜索到BMP280传感器");
delay(500);
}
}
void loop(){
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" ℃");
Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.print("Approx altitude = ");
Serial.print(bmp.readAltitude(1013.25));
Serial.println(" m");
Serial.println("");
delay(1000);
}
四、效果
手机上的温度