Circuit Documentation
Summary
This circuit involves an Arduino UNO microcontroller interfaced with a BME/BMP280 sensor module. The sensor is connected to the Arduino via the I2C protocol, and the Arduino reads temperature, pressure, and humidity data from the sensor and prints the values to the Serial Monitor.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
BME/BMP280 Sensor Module
- Description: A sensor module capable of measuring temperature, pressure, and humidity.
- Pins: GND, SCL, SDA, VIN
Wiring Details
Arduino UNO
- 5V: Connected to VIN of the BME/BMP280 sensor module.
- GND: Connected to GND of the BME/BMP280 sensor module.
- A4: Connected to SDA of the BME/BMP280 sensor module.
- A5: Connected to SCL of the BME/BMP280 sensor module.
BME/BMP280 Sensor Module
- VIN: Connected to 5V of the Arduino UNO.
- GND: Connected to GND of the Arduino UNO.
- SDA: Connected to A4 of the Arduino UNO.
- SCL: Connected to A5 of the Arduino UNO.
Code Documentation
/*
* This Arduino Sketch reads temperature, pressure, and humidity data from a
* BME/BMP280 sensor connected via I2C and prints the values to the Serial
* Monitor.
*/
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // I2C
void setup() {
Serial.begin(9600);
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
delay(2000);
}
Code Explanation
Libraries Included:
Wire.h: For I2C communication.Adafruit_Sensor.handAdafruit_BME280.h: For interfacing with the BME/BMP280 sensor.
Constants:
SEALEVELPRESSURE_HPA: Defines the sea level pressure in hPa.
Global Objects:
Adafruit_BME280 bme: Creates an instance of the BME280 sensor.
Setup Function:
- Initializes the Serial communication at 9600 baud rate.
- Initializes the BME280 sensor and checks if it is connected properly.
Loop Function:
- Reads temperature, pressure, and humidity from the BME280 sensor.
- Prints the values to the Serial Monitor.
- Delays for 2 seconds before repeating the loop.
