Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: M5Stack Core2 Air Quality Testing Project  (Read 1402 times)

0 Members and 1 Guest are viewing this topic.

OpenELAB

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 16
  • Last login:December 06, 2024, 04:11:24 am
  • I want to build my own arcade controls!
M5Stack Core2 Air Quality Testing Project
« on: November 22, 2024, 02:50:39 am »
Today let's do an air quality testing project with M5Stack Core2 and M5Stack ENV Pro Unit (BME688)

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
Code: [Select]
// 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);
}



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.


more infomation:https://openelab.io/blogs/learn/m5stack-core2-air-quality-testing-project