Site icon Hackatronic

Arduino Weather Station Project with BME680 Sensor

Arduino Weather Station with BME680 Sensor

Arduino Weather Station with BME680 Sensor

Weather monitoring is essential for various applications, from agriculture to home automation. The Arduino-based Weather Station using the BME680 sensor allows users to measure temperature, humidity, pressure, and gas resistance. The data will be displayed on an I2C LCD screen in cyclical manner, also it calculates Dew Point using Magnus formula and Altitude from pressure. This project provides an affordable and efficient solution for real-time environmental monitoring and can be expanded for IoT-based applications.

Components Required for Arduino Weather Station

To build this weather station, you need the following components:

Understanding the BME680 Sensor

The BME680 is an advanced environmental sensor developed by Bosch Sensortec. The BME680 is a highly versatile environmental sensor that combines temperature, humidity, pressure, and gas sensing in one compact module.

BME680 Sensor Pinout
BME680 Sensor

It is ideal for air quality monitoring, IoT applications, and smart devices. While it has some limitations (gas detection specificity), it remains one of the most popular sensors for environmental data collection.

1. Key Features of BME680 Sensor

2. Working Principle

The BME680 has different sensors that work together:

(A) Temperature Sensor (MEMS)

(B) Humidity Sensor (Capacitive)

(C) Pressure Sensor (Piezo-Resistive)

(D) Gas Sensor (MOX – Metal Oxide)

3. Communication Interfaces

The BME680 supports two types of communication:

It allows easy integration with microcontrollers like Arduino, Raspberry Pi, ESP32, STM32, etc.

4. Applications

The BME680 is widely used in:
Air Quality Monitoring – Detects VOCs in smart homes & offices.
Weather Stations – Measures humidity, temperature, and pressure.
Smart Wearables – Provides environmental sensing in fitness trackers.
Industrial Safety – Detects harmful gases in factories.
Smart Agriculture – Monitors environmental conditions for precision farming.
IoT Devices – Used in smart city & automation projects.

5. Indoor Air Quality (IAQ) Interpretation with Gas Resistance

IAQ Value Air Quality Gas Resistance (Ω)
0 – 50 Excellent > 500 kΩ
51 – 100 Good 200 – 500 kΩ
101 – 150 Moderate 100 – 200 kΩ
151 – 200 Poor 50 – 100 kΩ
201 – 300 Unhealthy 10 – 50 kΩ
301+ Hazardous < 10 kΩ

6. Power Consumption

7. Comparison of BME680 with BME280 and BMP280 Sensors

Feature BME680 BME280 BMP280
Temperature ✅ Yes ✅ Yes ✅ Yes
Humidity ✅ Yes ✅ Yes ❌ No
Pressure ✅ Yes ✅ Yes ✅ Yes
Gas Sensor ✅ Yes ❌ No ❌ No
IAQ Index ✅ Yes ❌ No ❌ No
Power Usage Moderate Low Low

8. Limitations

Arduino Weather Station Circuit Diagram and Wiring

Arduino Weather Station
Arduino Weather Station Circuit

Connections

Component Arduino Pin
BME680 VCC 5V
BME680 GND GND
BME680 SDA A4 (SDA)
BME680 SCL A5 (SCL)
LCD VCC 5V
LCD GND GND
LCD SDA A4 (SDA)
LCD SCL A5 (SCL)

The BME680 sensor and LCD display both communicate with Arduino via I2C protocol, making wiring simple and reducing the number of connections. This makes it ideal for beginners and professionals alike.

Arduino Weather Station
Arduino Weather Station

Arduino Weather Station Program

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"
#include <LiquidCrystal_I2C.h>

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME680 bme; // I2C
LiquidCrystal_I2C lcd(0x27, 16, 2); // Change address if necessary

void setup() 
{
Serial.begin(9600);
while (!Serial);
Serial.println(F("BME680 Weather Station"));

lcd.init();
lcd.backlight();
lcd.setCursor(3, 0);
lcd.print("Tech Trends");
lcd.setCursor(5, 1);
lcd.print("Shameer");
delay(2000);
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("BME680 Weather");
lcd.setCursor(6, 1);
lcd.print("Station");
delay(2000);
lcd.clear();

if (!bme.begin()) 
{
Serial.println("Could not find a valid BME680 sensor, check wiring!");
while (1);
}

// Set up oversampling and filter initialization
bme.setTemperatureOversampling(BME680_OS_8X);
bme.setHumidityOversampling(BME680_OS_2X);
bme.setPressureOversampling(BME680_OS_4X);
bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
bme.setGasHeater(320, 150); // 320*C for 150 ms
}

void loop() 
{
if (! bme.performReading()) 
{
Serial.println("Failed to perform reading :(");
return;
}

float temperature = bme.temperature;
float pressure = bme.pressure / 100.0;
float altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
float humidity = bme.humidity;
float gas = bme.gas_resistance / 1000.0;
double dewPoint = dewPointFast(temperature, humidity);

Serial.print("Temperature = ");
Serial.print(temperature);
Serial.println(" *C");

Serial.print("Pressure = ");
Serial.print(pressure);
Serial.println(" hPa");

Serial.print("Humidity = ");
Serial.print(humidity);
Serial.println(" %");

Serial.print("Dew Point = ");
Serial.print(dewPoint);
Serial.println(" *C");

Serial.print("Approx. Altitude = ");
Serial.print(altitude);
Serial.println(" m");

Serial.print("Gas = ");
Serial.print(gas);
Serial.println(" KOhms");

// Display values on LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp:");
lcd.print(temperature);
lcd.print(" C");

lcd.setCursor(0, 1);
lcd.print("Hum:");
lcd.print(humidity);
lcd.print(" %");
delay(2000);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Pres:");
lcd.print(pressure);
lcd.print(" hPa");

lcd.setCursor(0, 1);
lcd.print("Alt:");
lcd.print(altitude);
lcd.print(" m");
delay(2000);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Gas:");
lcd.print(gas);
lcd.print(" KOhm");

lcd.setCursor(0, 1);
lcd.print("Dew:");
lcd.print(dewPoint);
lcd.print(" C");
delay(2000);

Serial.println();
delay(2000);
}

double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity * 0.01);
double Td = (b * temp) / (a - temp);
return Td;
}

Weather Station Code Explanation

This code is for an Arduino-based BME680 weather station that reads temperature, pressure, humidity, gas resistance, and dew point, then displays the values on an LCD screen and prints them to the serial monitor.

1. Included Libraries
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"
#include <LiquidCrystal_I2C.h>

2. Defining Constants and Initializing Devices
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME680 bme; // I2C
LiquidCrystal_I2C lcd(0x27, 16, 2); // LCD at I2C address 0x27

3. Setup Function
void setup()
{
Serial.begin(9600);
while (!Serial);
Serial.println(F("BME680 Weather Station"));

LCD Welcome Messages


lcd.init();
lcd.backlight();
lcd.setCursor(3, 0);
lcd.print("Welcome");
lcd.setCursor(5, 1);
lcd.print("Your Name");
delay(2000);
lcd.clear();

Sensor Initialization


if (!bme.begin())
{
Serial.println("Could not find a valid BME680 sensor, check wiring!");
while (1);
}

Configuring Sensor Settings


bme.setTemperatureOversampling(BME680_OS_8X);
bme.setHumidityOversampling(BME680_OS_2X);
bme.setPressureOversampling(BME680_OS_4X);
bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
bme.setGasHeater(320, 150); // 320°C for 150ms

4. Main Loop
void loop()
{
if (! bme.performReading())
{
Serial.println("Failed to perform reading :(");
return;
}

Extracting Sensor Data


float temperature = bme.temperature;
float pressure = bme.pressure / 100.0;
float altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
float humidity = bme.humidity;
float gas = bme.gas_resistance / 1000.0;
double dewPoint = dewPointFast(temperature, humidity);

Displaying Readings on Serial Monitor


Serial.print("Temperature = ");
Serial.print(temperature);
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(pressure);
Serial.println(" hPa");
Serial.print("Humidity = ");
Serial.print(humidity);
Serial.println(" %");
Serial.print("Dew Point = ");
Serial.print(dewPoint);
Serial.println(" *C");
Serial.print("Approx. Altitude = ");
Serial.print(altitude);
Serial.println(" m");
Serial.print("Gas = ");
Serial.print(gas);
Serial.println(" KOhms");

Displaying Readings on LCD

The LCD alternates between different readings every 2 seconds.


lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp:");
lcd.print(temperature);
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Hum:");
lcd.print(humidity);
lcd.print(" %");
delay(2000);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Pres:");
lcd.print(pressure);
lcd.print(" hPa");
lcd.setCursor(0, 1);
lcd.print("Alt:");
lcd.print(altitude);
lcd.print(" m");
delay(2000);


lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Gas:");
lcd.print(gas);
lcd.print(" KOhm");
lcd.setCursor(0, 1);
lcd.print("Dew:");
lcd.print(dewPoint);
lcd.print(" C");
delay(2000);
}

IoT-Based Indoor Air Quality Monitoring with Arduino & BME680 Sensor

Summary of Program

  1. Libraries Included: The required libraries handle I2C communication and BME680 sensor functionalities.
  2. BME680 Initialization: The sensor is set up with oversampling and a gas heater to improve accuracy.
  3. Data Retrieval: The performReading() function fetches temperature, humidity, pressure, and gas resistance values.
  4. Displaying Data: The LCD screen displays temperature and humidity, updating every 2 seconds.
  5. Error Handling: The code includes error handling for failed sensor readings.

LCD Display Output

Temp: 24.5 'C
Hum: 60.2 %
Pres: 1010.5 hPa
Alt: 81M
Gas: 48.2 KOhms
Dew: 25.58'C

Applications of Arduino Weather Station Project

Enhancements & Future Improvements

Conclusion

This Arduino Weather Station using the BME680 sensor provides real-time weather data in a compact and efficient system. With further enhancements, it can be integrated into IoT applications for smart cities and environmental monitoring. Its flexibility makes it an excellent project for learning embedded systems and building practical weather monitoring solutions.

ESP32 Weather Station with BMP280 / BME280 Sensor

1S, 2S, 3S, 4S BMS Circuit Diagram for Li-ion Batteries

Water Quality Monitoring System: TDS Sensor + ESP32/Arduino

12V Automatic Cut Off Battery Charger Circuit Using Relay

Exit mobile version