LoginSignup
1
0

More than 1 year has passed since last update.

IRリモコン(M5stick-CPlus)で部屋の温度を快適にする(その1)

Posted at

まず、筆者が現在住んでいる環境の説明をば、

・よくあるワンルームマンション
・ワンルーム部分は約6畳
・石油ストーブ禁止
・24時間換気義務付け物件

そして

採光面がなんと北!天井高2.3mという環境にもかかわらず
エアコンの暖房システム出力は約2.2kWという貧弱スペック!!!

大体体感で2、3時間は適温に上がってくるまでかかります。
というわけで、下記の理由・目的で着手していきます。

・会社に出かけている間エアコンつけっぱはもったいない
・効率を考えて段階的に設定温度を上げていきたい。
・M5stick-Cで遊びたかった

ということで下記を用意しておきます。

・M5stick-C(今回の肝、便利すぎる)

M5StickC - スイッチサイエンス
https://www.switch-science.com/products/6470?_pos=4&_sid=3f94a217e&_ss=r

・IRUnit (簡単お手軽なキット)

https://www.switch-science.com/products/5699?_pos=5&_sid=1ef5b8ce8&_ss=r

まずはM5stick-Cの標準IR受信プログラムを動かして「detected!」と表示させます。
これはArduinoIDEのスケッチ例から入手できます。

#include <M5StickCPlus.h>
// select the input pin for the potentiometer
int ir_recv_pin     = 33;//受信のIOに合わせて変更
int ir_send_pin     = 32;//送信のIOに合わせて変更
int last_recv_value = 0;
int cur_recv_value  = 0;

void setup() {
    M5.begin();
    M5.Lcd.setRotation(3);
    pinMode(ir_recv_pin, INPUT);
    pinMode(ir_send_pin, OUTPUT);
    // send infrared light
    // now, you can see the infrared light through mobile phone camera
    digitalWrite(ir_send_pin, 1);
    // M5.Lcd.setTextSize(2);
    M5.Lcd.setCursor(0, 0);
    M5.Lcd.print("Test for IR receiver: ");
}

void loop() {
    // now, once you press the button on a remote controller to send infrared
    // light the screen will display "detected!"
    cur_recv_value = digitalRead(ir_recv_pin);
    if (last_recv_value != cur_recv_value) {
        M5.Lcd.setCursor(0, 25);
        M5.Lcd.fillRect(0, 25, 150, 25, BLACK);
        if (cur_recv_value == 0) {  // 0: detected 1: not detected
            M5.Lcd.print("detected!");
        }
        delay(100)
        last_recv_value = cur_recv_value;
    }
    Serial.println(cur_recv_value);
    delay(100);
}

これをArduinoIDEでコンパイルして流し込みます。

PC接続用のUSB-Cのケーブルは100円均一でそろえて使っています。
@モバイルバッテリー用に購入したダイソーの60WのPD対応のものを流用しちゃってます。
image.png

赤外線センサに向かってエアコンのリモコンを押すと無事にdetected!の表示がされました。(ちっちゃいですけどね)
IMG_2984.PNG

受信しているときは表示されています。

今回の記事はここまでにします。
次回はリモコンの送信コードを取得、M5stick-Cから再送信でエアコンが動かせるか確認していきます。

ここまでお読みくださりありがとうございます。
近日中にその2を投稿したいと思います。
(既に実施済みのため)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0