Skip to content

+49 1626571232

info@openelab.io

🚀 Free Shipping from 50€ in EU / 80€ Worldwide

M5Stack Core2 Air Quality Testing Project

21 Nov 2024 0 Comments
Today let's do an air quality testing project with M5Stack Core2 and M5Stack ENV Pro Unit (BME688)
M5Stack Core2 ESP32 IoT Development Kit

M5Stack Core2 ESP32 IoT Development Kit

View Product

M5Stack Temperature, Humidity, Pressure and Gas Sensor (BME688)

M5Stack Temperature, Humidity, Pressure and Gas Sensor (BME688)

View Product

 

M5Stack Core2

M5Core2 is the upgraded second generation core device in the M5Stack IoT development kit series. It features an ESP32 D0WDQ6-V3 MCU with dual-core processors, Wi-Fi, 16MB Flash, 8MB PSRAM and a 2.0-inch capacitive touch screen. It includes a USB Type-C interface, a 390mAh battery managed by an AXP192 chip, and additional components such as a built-in RTC module, vibration motor, TF card slot, I2S digital audio interface, and programmable capacitive buttons.We can make good use of the core2 screen for display.

ENV Pro Unit

ENV Pro Unit is an environmental sensor that uses the BME688 sensor solution and supports the measurement of various environmental parameters such as volatile organic compounds (VOCs), indoor air quality (IAQ), temperature, humidity and atmospheric pressure. It features compact size, wide operating range, simple communication interface (I2C), excellent performance and low power consumption, making it suitable for weather stations, indoor environmental monitoring and air quality detection applications.

Project

Connect

This part is very simple. The Core 2 and the ENV Pro Unit all use Grove interface, and they both use Grove PORT A. It's an I2C interface port. We just need a Grove cable.

      

Code

// The code part is the hardest part of this project. Let's do it.
// First of all, let's find out which libraries we need:
#include 
#include 
#include 
#include  
// Because this sensor is a BME680 sensor, we can use Adafruit_BME680 and Adafruit_Sensor libraries for this part, and use a M5Core2 library, a Wire library.

// Next step, we need define the I2C pins:
#define SDA_PIN 32
#define SCL_PIN 33

// Next, creating the BME688 Object:
Adafruit_BME680 bme;

// Void Setup part:
void setup() {
  M5.begin();
  M5.Lcd.fillScreen(BLACK);
  M5.Lcd.setTextColor(WHITE);
  M5.Lcd.setTextSize(2);
  M5.Lcd.setCursor(10, 10);
  M5.Lcd.println("ENV Pro Unit Data");

// Initialize I2C:
Wire.begin(SDA_PIN, SCL_PIN);

 // Initializing the BME688 Sensor (BME688 default address is 0x77):
  if (!bme.begin(0x77, &Wire)) { 
    M5.Lcd.println("Could not find BME688 sensor!");
    while (1);
  }

 // Setting BME688 parameters:
  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); 

// Void Loop part (Check if the BME688 sensor is available first):
void loop() {
  if (! bme.performReading()) {
    M5.Lcd.println("Failed to perform reading!");
    return;
  }

 // Display sensor data:
  M5.Lcd.fillScreen(BLACK);
  M5.Lcd.setCursor(10, 30);
  M5.Lcd.printf("Temp: %.2f C", bme.temperature);
  M5.Lcd.setCursor(10, 60);
  M5.Lcd.printf("Humidity: %.2f %%", bme.humidity);
  M5.Lcd.setCursor(10, 90);
  M5.Lcd.printf("Pressure: %.2f hPa", bme.pressure / 100.0);
  M5.Lcd.setCursor(10, 120);
  M5.Lcd.printf("Gas: %d ohms", bme.gas_resistance);

// Update data every 11 seconds (Gas sensor standard scanning speed is 10.8s):
  delay(11000); 
}


✔ Copied!

 

Result

It worked fine, and I could update the data to our Home Assistant.
The gas reading is a milliohm reading. In our test, the value was higher than 20,000, so the air quality will be good, on the contrary, it is worse.
    
Prev Post
Next Post

Leave a comment

All blog comments are checked prior to publishing

Someone recently bought a

Thanks for subscribing!

This email has been registered!

Shop the look

Choose Options

Edit Option
Back In Stock Notification
this is just a warning
Login
Shopping Cart
0 items
RuffRuff App RuffRuff App by Tsun