UNIT_ENV_III「M5Stack用温湿度気圧センサユニット Ver.3(ENV Ⅲ)」を動かす
2021/12/30
初版
UNIT_ENV_III
UNIT_ENV_III
概要
UNIT_ENV_III「M5Stack用温湿度気圧センサユニット Ver.3(ENV Ⅲ)」を動かす。
ソースは共通になっており、ターゲットのM5StickCPlus,M5Core2をplatformio.iniの内容で切り替えてビルドする。
ソース
src/main.ino
/*
*******************************************************************************
* Copyright (c) 2021 by M5Stack
* Equipped with M5Core2 sample source code
* 配套 M5Core2 示例源代码
* Visit the website for more information:https://docs.m5stack.com/en/core/core2
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/core2
*
* describe:ENVIII_SHT30_QMP6988. 环境传感器
* date:2021/8/17
*******************************************************************************
Please connect to Port A,Read temperature, humidity and atmospheric pressure and display them on the display screen
请连接端口A,读取温度、湿度和大气压强并在显示屏上显示
*/
#ifdef M5C2
#include <M5Core2.h>
#endif
#ifdef M5STICK_CP
#include <M5StickCPlus.h>
#endif
#include "Adafruit_Sensor.h"
#include <Adafruit_BMP280.h>
#include "UNIT_ENV.h"
SHT3X sht30;
QMP6988 qmp6988;
float tmp = 0.0;
float hum = 0.0;
float pressure = 0.0;
void setup() {
#ifdef M5STICK_CP
M5.begin();
M5.Axp.ScreenBreath(12);
M5.Lcd.setRotation(3);
M5.lcd.setTextSize(2);
#endif
#ifndef M5STICK_CP
M5.begin(); //Init M5Core2. 初始化 M5Core2
M5.lcd.setTextSize(2); //Set the text size to 2. 设置文字大小为2
#endif
Wire.begin(); //Wire init, adding the I2C bus. Wire初始化, 加入i2c总线
qmp6988.init();
M5.lcd.println(F("ENV Unit III test"));
}
void loop() {
pressure = qmp6988.calcPressure();
if(sht30.get()==0){ //Obtain the data of shT30. 获取sht30的数据
tmp = sht30.cTemp; //Store the temperature obtained from shT30. 将sht30获取到的温度存储
hum = sht30.humidity; //Store the humidity obtained from the SHT30. 将sht30获取到的湿度存储
}else{
tmp=0,hum=0;
}
M5.lcd.fillRect(0,20,100,60,BLACK); //Fill the screen with black (to clear the screen). 将屏幕填充黑色(用来清屏)
M5.lcd.setCursor(0,20);
M5.Lcd.printf("Temp: %2.1f \r\nHumi: %2.0f%% \r\nPressure:%2.0fPa\r\n", tmp, hum, pressure);
delay(2000);
}
platformio.ini
M5Core2用
[env:m5core2]
platform = espressif32
board = m5stack-core2
framework = arduino
upload_speed = 2000000
monitor_speed = 115200
board_build.partitions = default_16MB.csv
build_flags =
-DM5C2
-DCORE_DEBUG_LEVEL=4
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
lib_deps =
https://github.com/m5stack/M5Core2.git
https://github.com/FastLED/FastLED
;https://github.com/m5stack/M5Core2/blob/master/examples/core2_for_aws/ArduinoECCX08.zip
lovyan03/LovyanGFX
adafruit/Adafruit BMP280 Library @ ^2.5.0
adafruit/Adafruit Unified Sensor @ ^1.1.4
m5stack/UNIT_ENV @ ^0.0.2
lib_ldf_mode = deep+
M5StickCPlus用
[env:M5StickCPlus]
platform = espressif32
board = m5stick-c
framework = arduino
build_flags = -DM5STICK_CP
monitor_speed = 115200
lib_ldf_mode = deep+
lib_deps =
m5stack/M5StickCPlus @ ^0.0.5
tinyu-zhao/FFT @ ^0.0.1
m5stack/UNIT_ENV @ ^0.0.2
adafruit/Adafruit BMP280 Library @ ^2.5.0
adafruit/Adafruit Unified Sensor @ ^1.1.4
動作
LCDに、気温、湿度、気圧が表示される。
参考情報
terminal関連:
Bootterm – a developer-friendly serial terminal program
platformio関連:
arduinoフレームワーク用platformio.ini集
Building Core2 FactoryDemo in PlatformIO
VSCodeとPlatformIOでM5Stack Core2開発
M5Stack Core2とVSCode + PlatformIOとでM5Stackプログラミングを始めてみた。
Arduino-IDE関連:
Arduino IDE environment - M5Paper
Arduino IDEのインストールと設定 (Windows, Mac, Linux対応)
M5Stackファミリ関連:
M5Core2 Arduino Install
M5Paper Arduino Install
M5CoreInk Arduino Install
M5Stamp-PICO Arduino Install
M5Stamp-C3 Arduino Install
Wio-Terminal/ESP8622/ESP32ボードを共通のスケッチで動かす(NTP-CLIENT編)
Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(STARWARS編)
Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(MQTT編)
Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(REST-API編)
Wio-Terminal/M5Atom/ESP8622/ESP32ボードを共通のスケッチで動かす(v2)(OSC編)
以上
| 固定リンク
「PlatformIO」カテゴリの記事
- NuEVI/NuRADのビルド(2022.08.18)
- Wio_ExtFlashLoad(WriteSampleMenu.ino)スケッチをplatformioでビルドする(2022.02.03)
- uncannyeyesスケッチをplatformioでビルドする(2022.01.31)
- LovyanGFX-Display ライブラリを使用したスケッチをplatformioでビルドする(2022.01.30)
- Wio-Terminal/M5Core2のWiFiAnallyzer(2022.01.24)
この記事へのコメントは終了しました。


コメント