UNIT_IR_REMOTE 受信編
2021/12/30
初版
UNIT_IR_REMOTE 受信編
UNIT_IR_REMOTE 受信編
概要
UNIT_IR_REMOTE「M5Stack用赤外線送受信ユニット」を使用してIR受信を行う。
送信側は「M5StickCで赤外線リモコンを使う」のスケッチをM5StickCPlus用に修正して使用する。
受信側はIRrecvDumpV2のスケッチを使用する。
ソースは共通になっており、platformio.iniの内容で切り替えてビルドする。
送信側
「M5StickCで赤外線リモコンを使う」のスケッチをM5StickCPlus用に修正して使用する。
1.「M5StickCで赤外線リモコンを使う」の「送信側コード(GitHub)」のソースをコピーする。(src配下に置く) 2.ヘッダーを変更する
#include <M5StickC.h>
→
#include <M5StickCPlus.h>
使用時は電源を繋いたほうが安定して動作するようだ。
platformio.iniは、後節のものを使用する。
受信側
以下の手順を実行する:
mkdir src
cd src
wget https://github.com/crankyoldgit/IRremoteESP8266/raw/master/examples/IRrecvDumpV2/IRrecvDumpV2.ino
# kRecvPinを変更する
# ソースを以下のように修正する:
修正前:
const uint16_t kRecvPin = 14;
→
修正後:
#ifdef M5ATOM
const uint16_t kRecvPin = 32;
#endif
#ifdef M5C2
const uint16_t kRecvPin = 33;
#endif
#ifdef M5STICK_CP
const uint16_t kRecvPin = 33;
#endif
ターゲットとして、M5Atom,M5Core2,M5StickCPlusが使用できるが、platformio.iniで切り替える。
platformio.ini
M5Atom用
[env:M5ATOM]
platform = espressif32
board = m5stick-c
framework = arduino
build_flags = -DM5ATOM
upload_poert = /dev/ttyUSB0
monitor_speed = 115200
lib_deps =
m5stack/M5Atom @ ^0.0.7
fastled/FastLED @ ^3.4.0
adafruit/Adafruit NeoPixel @ ^1.10.3
crankyoldgit/IRremoteESP8266 @ ^2.8.0
lib_ldf_mode = deep+
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
adafruit/Adafruit NeoPixel @ ^1.10.3
crankyoldgit/IRremoteESP8266 @ ^2.8.0
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
adafruit/Adafruit NeoPixel @ ^1.10.3
crankyoldgit/IRremoteESP8266 @ ^2.8.0
動作
M5StickCPluseでIR送信すると、その受信結果がシリアル出力される。
出力例:
#シリアル通信を起動する
bt -L 1
<省略>
IRrecvDump is now running and waiting for IR input on Pin 32
Timestamp : 000014.259
Library : v2.8.0
Protocol : UNKNOWN ←エラーになると「UNKNOWN」になるようだ
Code : 0xA3C8EDDB (34 Bits)
uint16_t rawData[67] = {8912, 4534, 534, 610, 518, 606, 508, 616, 516, 604, 506, 616, 508, 614, 514, 608, 512, 610, 516, 1728, 514, 1728, 514, 1728, 486, 1756, 506, 1736, 510, 1732, 514, 1728, 512, 1730, 514, 1728, 512, 612, 510, 1732, 514, 610, 504, 1736, 482, 640, 486, 634, 512, 610, 518, 604, 478, 1762, 514, 610, 506, 1734, 506, 620, 486, 1756, 514, 1728, 480, 1762, 512}; // UNKNOWN A3C8EDDB
Timestamp : 000019.971
Library : v2.8.0
Protocol : NEC
Code : 0xFFA857 (32 Bits)
uint16_t rawData[67] = {8962, 4482, 564, 578, 548, 574, 538, 528, 604, 574, 538, 584, 618, 506, 544, 578, 544, 578, 546, 1696, 544, 1698, 544, 1698, 486, 1756, 536, 1708, 540, 1702, 544, 1700, 516, 1726, 544, 1698, 542, 582, 514, 1726, 544, 580, 510, 1732, 536, 588, 516, 604, 538, 584, 546, 576, 534, 1706, 598, 526, 534, 1708, 532, 592, 516, 1686, 582, 1702, 510, 1732, 542}; // NEC FFA857
uint32_t address = 0x0;
uint32_t command = 0x15;
uint64_t data = 0xFFA857;
btについては「Bootterm – a developer-friendly serial terminal program」を参照のこと
参考情報
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)
この記事へのコメントは終了しました。


コメント