« 「Grove 超音波距離測定センサー - Ultrasonic Distance Sensor」を動かす | トップページ | M5CameraでCameraWebServerを動かす »

2021年12月31日 (金)

UNIT_NCIR「M5Stack用非接触温度センサユニット」を動かす

2021/12/30
初版

UNIT_NCIR

UNIT_NCIR

概要

UNIT_NCIR「M5Stack用非接触温度センサユニット」を動かす。
ソースは共通になっており、ターゲットの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/unit/ncir * 获取更多资料请访问:https://docs.m5stack.com/zh_CN/unit/ncir * * describe: ncir. 单点红外测温传感器 * date:2021/8/27 ******************************************************************************* Please connect to Port A,Use NCIR Unit to measure the temperature without contact and display the value on the screen. 请连接端口A,使用NCIR单元无接触测量温度,并在屏幕上显示。 */ #ifdef M5C2 #include <M5Core2.h> #endif #ifdef M5STICK_CP #include <M5StickCPlus.h> #endif void setup() { //M5.begin(); Wire.begin(); #ifdef M5C2 M5.begin(); M5.Lcd.setTextSize(3); M5.Lcd.setCursor(120, 0); #endif #ifdef M5STICK_CP M5.begin(); M5.Axp.ScreenBreath(12); M5.Lcd.setRotation(3); M5.lcd.setTextSize(2); M5.Lcd.setCursor(10, 0); #endif M5.Lcd.print("NCIR"); } void loop() { static uint16_t result; static float temperature; Wire.beginTransmission(0x5A); // Send Initial Signal and I2C Bus Address 发送初始信号和I2C总线地址 Wire.write(0x07); // Send data only once and add one address automatically. 只发送一次数据,并自动添加一个地址。 Wire.endTransmission(false); // Stop signal 停止信号 Wire.requestFrom(0x5A, 2); // Get 2 consecutive data from 0x5A, and the data is stored only. 从0x5A中获取2个连续的数据,并且只存储这些数据。 result = Wire.read(); // Receive DATA 接收数据 result |= Wire.read() << 8; // Receive DATA 接收数据 temperature = result * 0.02 - 273.15; #ifdef M5C2 M5.Lcd.setCursor(70, 100); #endif #ifdef M5STICK_CP M5.Lcd.setCursor(10, 20); #endif M5.Lcd.printf("Temp:%.3f",temperature); delay(500); }

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編)

以上

|

« 「Grove 超音波距離測定センサー - Ultrasonic Distance Sensor」を動かす | トップページ | M5CameraでCameraWebServerを動かす »

PlatformIO」カテゴリの記事

コメント

この記事へのコメントは終了しました。