M5Stack Core2
M5Core2 to ulepszone urządzenie drugiej generacji w serii zestawów do rozwoju IoT M5Stack. Wyposażone jest w mikroprocesor ESP32 D0WDQ6-V3 z dwurdzeniowymi procesorami, Wi-Fi, 16MB pamięci Flash, 8MB PSRAM oraz 2,0-calowy pojemnościowy ekran dotykowy. Zawiera interfejs USB Type-C, baterię 390mAh zarządzaną przez układ AXP192 oraz dodatkowe komponenty, takie jak wbudowany moduł RTC, silnik wibracyjny, gniazdo karty TF, cyfrowy interfejs audio I2S oraz programowalne pojemnościowe przyciski. Możemy dobrze wykorzystać ekran core2 do wyświetlania.
ENV Pro Unit
Projekt
Połącz
Ta część jest bardzo prosta. Core 2 i jednostka ENV Pro używają interfejsu Grove, a oba korzystają z portu Grove PORT A. To port interfejsu I2C. Potrzebujemy tylko kabla Grove.

Kod
// 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); }
Wynik
