[Diao Ye learns programming] Arduino hands-on (212) --- 9-in-1 expansion board to complete Arduino's 10th type of expansion experiment - GY-BMP280-3.3 atmospheric pressure altimeter sensor experiment

insert image description here

The reference to 37 sensors and modules has been widely circulated on the Internet. In fact, there must be more than 37 sensor modules compatible with Arduino. In view of the fact that I have accumulated some sensors and modules on hand, according to the concept of practice (hands-on try), for the purpose of learning and communication, I am going to do experiments one by one here, and will record them regardless of whether they are successful or not. It is a difficult problem, and I hope to be able to throw bricks and spark jade.

[Arduino] 168 kinds of sensor module series experiment (data code + simulation programming + graphics programming)
experiment 212: 9 in 1 multi-function expansion board DHT1 device temperature and humidity LM3 temperature 5 buzzer 1 compatible with UNO

insert image description here

Take the combination of "Arduino program code" + "Mind + graphics programming" + "Linkboy simulation programming"

Complement each other, lay a solid foundation, and promote understanding

insert image description here

Experiment catalog (Arduino hands-on)
1. LED experiment
01 Blink: D13 blue LED blinks
02 Blink2: D12, D13 red and blue LEDs blink alternately
03 Blink3: Simulate flashing alarm light
04 Breath_LED: D9 full-color LED simulates red breathing light
2. Button experiment
05 Button: D2 button controls D13 blue LED
06 Button_Lock: D3 button controls D13 blue LED self-locking experiment
3. Potentiometer experiment
07 RS232_AD: serial port reads A0 potentiometer to collect value (rotation angle 270° output 0 -3.3V/5V voltage signal potentiometer resistance value 10K)
08 Rotation_LED: A0 potentiometer controls D11 full-color LED blue terminal brightness
09 RC_Motor: A0 potentiometer controls the steering gear at the output port of D7 to control its rotation angle (the steering gear needs to be automatically Arduino needs external power supply)
4. RGB full-color LED experiment
10 LED_RGB_Text: full-color LED basic color change
11 LED_RGB: full-color LED rainbow change
5. Infrared sensor D6 experiment (infrared remote control needs to be prepared by yourself)
12 IRrelay: press infrared remote control Any key of the device can control the D13 LED switch (control distance 1-8 meters, frequency 38KHz, compatible with most infrared remote controls on the market)
13 IRrecord: The serial port displays the read infrared remote control code
6. Temperature sensor experiment
14 LM35_RS232AD: The serial port
displays the temperature read by the LM35 temperature sensor on the A2 port (it can test the indoor and outdoor temperature, the range is -50-150°C, and the sensitivity is good).
Taken temperature and humidity data (temperature measurement range 0-50°C, humidity range 20%-90%PH)
8. Brightness sensor experiment
16 Light Sensor: serial port displays the value collected by the photoresistor of port A1
17 Light_LED: control of the photoresistor of port A1 D13 LED switch (sensitive to light, suitable for teaching experiments and civilian equipment)
9. Buzzer experiment
18 Buzzer: D5 port passive buzzer to simulate an ambulance siren (can make simple music sounds, music needs to be programmed)
10 , Extended experiment
19 Analog ultrasonic ranging sensor (detection type I, IIC/I2C interface)
20 Bus DS18B20 temperature sensor (numeric type, connected to the digital D7 interface of the expansion board)
21 TM1637 four-digit digital tube (digital tube and dot matrix type, connected to Expansion board digital D7/D8 interface)
22 GY-BMP280-3.3 Atmospheric pressure altimeter sensor module (numeric type, IIC/I2C interface)
23 GY-NEO-6MV2 new flight control GPS satellite signal receiving module (numeric type, TTL interface)
24 5V low-level trigger single-channel relay module (executive type, digital D7 interface)
25 4-wire sound sensor module with electret microphone (trigger type, digital D7 interface)
26 BH1750FVI digital light intensity module light sensor (numeric type, IIC/ I2C interface)
27 Open source DFPlayer Mini TF card MP3 player module (output actuator type D7/D8 digital interface)
28 LCD1602 LCD screen module (output display type, IIC/I2C interface)
29 Human body infrared pyroelectric motion sensor module (trigger type, digital D7 interface)
30 DS1307 clock module Tiny RTC I2C module (detection sensor type, IIC/I2C interface)
31 compatible HC-06 slave Bluetooth module (communication and storage type, TTL interface)

insert image description here

Ten. Extended experiment
22 GY-BMP280-3.3 Atmospheric pressure altimeter sensor module (numeric, IIC/I2C interface)
23 GY-NEO-6MV2 new flight control GPS satellite signal receiving module (numeric, TTL interface)

BMP280
Bosch Sensortec - The BMP280 is an absolute barometric pressure sensor designed for mobile applications. The sensor module comes in an extremely compact package. Thanks to its small size and low power consumption, this device can be used in battery-powered devices such as mobile phones, GPS modules or watches. Like the previous generation, BMP180, BMP280 are also based on Bosch's mature piezoresistive pressure sensor technology, featuring high accuracy and linearity, as well as long-term stability and high EMC robustness. Multiple device operating options provide maximum flexibility to optimize the device in terms of power consumption, resolution and filtering performance.

BMP280 is the latest digital air pressure sensor launched by Bosch. It has excellent performance and low price. The relative accuracy is ±0.12 hPa (equivalent to ±1 meter), and the sensor power consumption is only 2.7μA. The BMP280 has the industry's smallest package in an extremely compact 8-pin metal-lid LGA package with a footprint of only 2.0 x 2.5mm2 and a package height of 0.95 mm. Includes pressure and temperature measurement functions. The air pressure sensor supports SPI and IIC communication interfaces. Compared with the previous generation BMP180, the accuracy has been greatly improved. It is very suitable for low-cost multi-rotor aircraft flight controllers. The price is only a quarter of the current popular MS5611. one. The sensor module's small size and low power consumption of 2.74μA @ 1Hz allow implementation in battery-operated devices. Emerging applications for in-door navigation, healthcare, and GPS improvement require high relative accuracy and low TCO.

The BMP280 is ideal for applications such as floor level detection, as the sensor has an excellent relative accuracy of ±0.12 hPa, which is equivalent to a height difference of ±1m, and an offset temperature coefficient (TCO) of only 1.5 Pa/K (equivalent to 12.6 cm/K). As the successor to the widely implemented BMP180, which was first heavily used for barometric pressure measurement in mobile phones in 2011, the BMP280 achieves high performance in all applications requiring accurate pressure measurement. At the same time, BMP280 has higher application flexibility, new filter mode and SPI interface, and compared with BMP180, the footprint is reduced by 63%.

insert image description here
GY-BMP280-3.3 high-precision atmospheric pressure sensor module
is a low-power digital composite sensor that can measure ambient temperature and atmospheric pressure. The air pressure sensing element is a low-noise, high-precision, high-resolution absolute atmospheric pressure piezoelectric sensing element; the temperature sensing element has low-noise, high-resolution characteristics, and the temperature value can perform temperature compensation and self-calibration on the air pressure. By configuring the sampling rate register, the sampling rate of the sensitive element can be set. Ideal for space-constrained mobile devices such as smartphones, tablets, smart watches and wearables, weather forecasts, vertical speed indication, flight control equipment, indoor and outdoor navigation, and smart home devices.

insert image description here

22. GY-BMP280-3.3 Atmospheric pressure altimeter sensor module (I2C interface)
project: read temperature, air pressure and altitude data in real time through the serial port

Arduino experiment open source code

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  程序四:基于博世 BME280I2C 环境传感器数据表的测试
  安装库:https://itbrainpower.net/downloadables/sSense-BMx280.zip
*/

#define SERIAL_SPEED  19200 //初始化串口

#include <sSense-BMx280I2C.h>//导入驱动库

#include <Wire.h> 

/* 推荐模式 -
   基于博世 BME280I2C 环境传感器数据表。

天气监测:
   强制模式,1 个样本/分钟
   压力×1、温度×1、湿度×1、过滤
   电流消耗 = 0.16 μA
   RMS 噪声 = 3.3 Pa/30 cm, 0.07 %RH
   数据输出速率 1/60 Hz

湿度感应:
   强制模式,1 个样本/秒
   压力×0,温度×1,湿度×1,过滤
   电流消耗 = 2.9 μA
   RMS 噪声 = 0.07 %RH
   数据输出速率 = 1 Hz

室内导航:
   正常模式,待机时间 = 0.5ms
   压力×16,温度×2,湿度×1,过滤器= x16
   电流消耗 = 633 μA
   RMS 噪声 = 0.2 Pa/1.7 cm
   数据输出速率 = 25Hz
   滤波器带宽 = 0.53 Hz
   响应时间 (75%) = 0.9 秒

游戏:
   正常模式,待机时间 = 0.5ms
   压力×4,温度×1,湿度×0,过滤器= x16
   电流消耗 = 581 μA
   RMS 噪声 = 0.3 Pa/2.5 cm
   数据输出速率 = 83 Hz
   滤波器带宽 = 1.75 Hz
   响应时间 (75%) = 0.3 秒
*/


BMx280I2C::Settings settings(
   BME280::OSR_X1,
   BME280::OSR_X1,
   BME280::OSR_X1,
   BME280::Mode_Forced,
   BME280::StandbyTime_1000ms,
   BME280::Filter_Off,
   BME280::SpiEnable_False,

   0x76 // I2C 地址。 I2C 专用。
);

BMx280I2C ssenseBMx280(settings);

void setup(){
    
    
  delay(5000);
  DebugPort.begin(SERIAL_SPEED);

  while(!DebugPort) {
    
    } // 等待

  DebugPort.println("s-Sense BME/BMP280 I2C sensor.");

  Wire.begin();
  while(!ssenseBMx280.begin())
  {
    
    
    DebugPort.println("Could not find BME/BMP280 sensor!");
    delay(1000);
  }
  
  switch(ssenseBMx280.chipModel())
  {
    
    
     case BME280::ChipModel_BME280:
       DebugPort.println("Found BME280 sensor! Humidity available.");
       break;

     case BME280::ChipModel_BMP280:
       DebugPort.println("Found BMP280 sensor! No Humidity available.");
       break;
     default:
       DebugPort.println("Found UNKNOWN sensor! Error!");
  }

   // 使用前更改一些设置。
   settings.tempOSR = BME280::OSR_X4;

   ssenseBMx280.setSettings(settings);
}

void loop(){
    
    
   printBMx280Data(&DebugPort);
   delay(500);
}

void printBMx280Data(
   Stream* client
)
{
    
    
   float temp(NAN), hum(NAN), pres(NAN);

   BME280::TempUnit tempUnit(BME280::TempUnit_Celsius);
   BME280::PresUnit presUnit(BME280::PresUnit_Pa);

   ssenseBMx280.read(pres, temp, hum, tempUnit, presUnit);

   client->print("Temp: ");
   client->print(temp);

   //client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F'));
   client->print(" "+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F'));
   client->print("\t\tHumidity: ");
   client->print(hum);
   client->print("% RH");
   client->print("\t\tPressure: ");
   client->print(pres);
   client->println(" Pa");

   delay(1000);
}

Experimental serial port return

insert image description here
You can convert air pressure to altitude, but you are not sure if this altitude is correct?
Arduino Reference Open Source Code

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  程序五:可换算气压为高度,只是不确定这个高度是否正确?
  安装库:https://itbrainpower.net/downloadables/sSense-BMx280.zip
*/

#define SERIAL_SPEED  19200 //初始化串口

#include <BMx280_EnvCalc.h>//导入驱动库
#include <sSense-BMx280I2C.h>

#include <Wire.h>

// 默认值:强制模式,待机时间 = 1000 ms
// 过采样=压力×1,温度×1,湿度×1,过滤掉
BMx280I2C ssenseBMx280;

void setup(){
    
    
  delay(5000);
  DebugPort.begin(SERIAL_SPEED);

  while (!DebugPort) {
    
    } // 等待

  Wire.begin();

  while (!ssenseBMx280.begin())
  {
    
    
    DebugPort.println("Could not find BME280 sensor!");
    delay(1000);
  }

  switch (ssenseBMx280.chipModel())
  {
    
    
    case BME280::ChipModel_BME280:
      DebugPort.println("Found BME280 sensor! Humidity available.");
      break;
    case BME280::ChipModel_BMP280:
      DebugPort.println("Found BMP280 sensor! No Humidity available.");
      break;
    default:
      DebugPort.println("Found UNKNOWN sensor! Error!");
  }
}

void loop(){
    
    
  printBMx280Data(&DebugPort);
  delay(500);
}

void printBMx280Data( Stream* client )
{
    
    
  float temp(NAN), hum(NAN), pres(NAN);

  BME280::TempUnit tempUnit(BME280::TempUnit_Celsius);
  BME280::PresUnit presUnit(BME280::PresUnit_Pa);

  ssenseBMx280.read(pres, temp, hum, tempUnit, presUnit);

  client->print("Temp: ");
  client->print(temp);
  client->print(String(tempUnit == BME280::TempUnit_Celsius ? "C" : "F"));
  client->print("\t\tHumidity: ");
  client->print(hum);
  client->print("% RH");
  client->print("\t\tPressure: ");
  client->print(pres);
  client->print(" Pa");

  BMx280_EnvCalc::AltitudeUnit envAltUnit =  BMx280_EnvCalc::AltitudeUnit_Meters;

  BMx280_EnvCalc::TempUnit     envTempUnit =  BMx280_EnvCalc::TempUnit_Celsius;

  float altitude = BMx280_EnvCalc::Altitude(pres, envAltUnit);
  float dewPoint = BMx280_EnvCalc::DewPoint(temp, hum, envTempUnit);
  float seaLevel = BMx280_EnvCalc::EquivalentSeaLevelPressure(altitude, temp, pres);

  // seaLevel = BMx280_EnvCalc::SealevelAlitude(altitude, temp, pres); // 已弃用。请参见等效SeaLevelPressure()。

  client->print("\r\nAltitude: ");
  client->print(altitude);
  client->print((envAltUnit == BMx280_EnvCalc::AltitudeUnit_Meters ? "m" : "ft"));
  client->print("\tDew point: ");
  client->print(dewPoint);

  client->print(String(envTempUnit == BMx280_EnvCalc::TempUnit_Celsius ? "C" : "F"));
  client->print("\t\tEquivalent Sea Level Pressure: ");
  client->print(seaLevel);
  client->println(" Pa\r\n");

  delay(1000);//延时1000毫秒
}

Experimental serial port return

insert image description here

Experimental open source graphics programming (Mind+, programming while learning)

insert image description here
Experimental serial port return

insert image description here

insert image description here

insert image description here

insert image description here

Guess you like

Origin blog.csdn.net/weixin_41659040/article/details/132459999