【ラズパイ】リモコンの赤外線を受信してみる。

赤外線受信モジュールの出力をGPIO21番に接続し、

以下の様にプログラムを組んでみました。

import RPi.GPIO as GPIO
import time
import datetime

def __main__():
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(21,GPIO.IN)
    GPIO.add_event_detect(21, GPIO.BOTH, callback=callback)
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        GPIO.cleanup()

def callback(channel):
    print(str(GPIO.input(21)) + " " + datetime.datetime.now().isoformat())

__main__()

GPIO21の信号が変わったタイミングで割り込みを発生し、そのときの出力値と時間を標準出力で表示させます。

ただ、このテレビのリモコン、電源ボタンを押しっぱなしにしないと信号が出ないみたいで、

で、なおかつ、押しっぱなしにすると信号が出続けるもので。

0 2020-11-24T10:14:30.712150
1 2020-11-24T10:14:30.718138
0 2020-11-24T10:14:30.765131
1 2020-11-24T10:14:30.765352
0 2020-11-24T10:14:30.804348
1 2020-11-24T10:14:30.812659
0 2020-11-24T10:14:30.817313
1 2020-11-24T10:14:30.817765
0 2020-11-24T10:14:30.818497
1 2020-11-24T10:14:30.818897
0 2020-11-24T10:14:30.819593
1 2020-11-24T10:14:30.820053
0 2020-11-24T10:14:30.820533
1 2020-11-24T10:14:30.821233
0 2020-11-24T10:14:30.821634
1 2020-11-24T10:14:30.822347
0 2020-11-24T10:14:30.822964
1 2020-11-24T10:14:30.823503
0 2020-11-24T10:14:30.824101
1 2020-11-24T10:14:30.824575
0 2020-11-24T10:14:30.826361
1 2020-11-24T10:14:30.826822
0 2020-11-24T10:14:30.827364
1 2020-11-24T10:14:30.827968
0 2020-11-24T10:14:30.829730
1 2020-11-24T10:14:30.830241
0 2020-11-24T10:14:30.832033
1 2020-11-24T10:14:30.832501
0 2020-11-24T10:14:30.834314
1 2020-11-24T10:14:30.834766
0 2020-11-24T10:14:30.836554
1 2020-11-24T10:14:30.837033
0 2020-11-24T10:14:30.838794
1 2020-11-24T10:14:30.839353
0 2020-11-24T10:14:30.841086
1 2020-11-24T10:14:30.841601
0 2020-11-24T10:14:30.842042
1 2020-11-24T10:14:30.842722
0 2020-11-24T10:14:30.844382
1 2020-11-24T10:14:30.845010
0 2020-11-24T10:14:30.845743
1 2020-11-24T10:14:30.846213
0 2020-11-24T10:14:30.847861
1 2020-11-24T10:14:30.848455
0 2020-11-24T10:14:30.849055
1 2020-11-24T10:14:30.849573
0 2020-11-24T10:14:30.850183
1 2020-11-24T10:14:30.850725
0 2020-11-24T10:14:30.852405
1 2020-11-24T10:14:30.852972
0 2020-11-24T10:14:30.853503
1 2020-11-24T10:14:30.854129
0 2020-11-24T10:14:30.854628
1 2020-11-24T10:14:30.855277
0 2020-11-24T10:14:30.855717
1 2020-11-24T10:14:30.856376
0 2020-11-24T10:14:30.858106
1 2020-11-24T10:14:30.858635
0 2020-11-24T10:14:30.859222
1 2020-11-24T10:14:30.859775
0 2020-11-24T10:14:30.861550
1 2020-11-24T10:14:30.862049
0 2020-11-24T10:14:30.863799
1 2020-11-24T10:14:30.864357
0 2020-11-24T10:14:30.864821
1 2020-11-24T10:14:30.865492
0 2020-11-24T10:14:30.867127
1 2020-11-24T10:14:30.867739
0 2020-11-24T10:14:30.869522
1 2020-11-24T10:14:30.870102
0 2020-11-24T10:14:30.871770
1 2020-11-24T10:14:30.872296
0 2020-11-24T10:14:30.912677
1 2020-11-24T10:14:30.921864
0 2020-11-24T10:14:30.923867
1 2020-11-24T10:14:30.924497
0 2020-11-24T10:14:30.972354
1 2020-11-24T10:14:30.981305
0 2020-11-24T10:14:30.985768
1 2020-11-24T10:14:30.986297
0 2020-11-24T10:14:30.986901
1 2020-11-24T10:14:30.987434
0 2020-11-24T10:14:30.987902
1 2020-11-24T10:14:30.988581
0 2020-11-24T10:14:30.989105
1 2020-11-24T10:14:30.989750
0 2020-11-24T10:14:30.990292
1 2020-11-24T10:14:30.990898
0 2020-11-24T10:14:30.991490
1 2020-11-24T10:14:30.992017
0 2020-11-24T10:14:30.992618
1 2020-11-24T10:14:30.993143
0 2020-11-24T10:14:30.994968
1 2020-11-24T10:14:30.995415
0 2020-11-24T10:14:30.995996
1 2020-11-24T10:14:30.996558
0 2020-11-24T10:14:30.998247
1 2020-11-24T10:14:30.998835
0 2020-11-24T10:14:31.000531
1 2020-11-24T10:14:31.001089
0 2020-11-24T10:14:31.002897
1 2020-11-24T10:14:31.003358
0 2020-11-24T10:14:31.005463
1 2020-11-24T10:14:31.005794
0 2020-11-24T10:14:31.007627
1 2020-11-24T10:14:31.007885
0 2020-11-24T10:14:31.009823
1 2020-11-24T10:14:31.010188
0 2020-11-24T10:14:31.010786
1 2020-11-24T10:14:31.011313
0 2020-11-24T10:14:31.013177
1 2020-11-24T10:14:31.013577
0 2020-11-24T10:14:31.014196
1 2020-11-24T10:14:31.014723
0 2020-11-24T10:14:31.016505
1 2020-11-24T10:14:31.016988
0 2020-11-24T10:14:31.017615
1 2020-11-24T10:14:31.018132
0 2020-11-24T10:14:31.018801
1 2020-11-24T10:14:31.019244
0 2020-11-24T10:14:31.021049
1 2020-11-24T10:14:31.021532
0 2020-11-24T10:14:31.022264
1 2020-11-24T10:14:31.022711
0 2020-11-24T10:14:31.023231
1 2020-11-24T10:14:31.023825
0 2020-11-24T10:14:31.024497
1 2020-11-24T10:14:31.024954
0 2020-11-24T10:14:31.026808
1 2020-11-24T10:14:31.027232
0 2020-11-24T10:14:31.027891
1 2020-11-24T10:14:31.028356
0 2020-11-24T10:14:31.030251
1 2020-11-24T10:14:31.030616
0 2020-11-24T10:14:31.032629
1 2020-11-24T10:14:31.032920
0 2020-11-24T10:14:31.033644
1 2020-11-24T10:14:31.034099
0 2020-11-24T10:14:31.035998
1 2020-11-24T10:14:31.036321
0 2020-11-24T10:14:31.038409
1 2020-11-24T10:14:31.038591
0 2020-11-24T10:14:31.040637
1 2020-11-24T10:14:31.040889
0 2020-11-24T10:14:31.085001
1 2020-11-24T10:14:31.090315
0 2020-11-24T10:14:31.142103
1 2020-11-24T10:14:31.143617
0 2020-11-24T10:14:31.317687
1 2020-11-24T10:14:31.317986
0 2020-11-24T10:14:31.320925
1 2020-11-24T10:14:31.321246
0 2020-11-24T10:14:31.321999
1 2020-11-24T10:14:31.322382
0 2020-11-24T10:14:31.324284
1 2020-11-24T10:14:31.324646
0 2020-11-24T10:14:31.325373
1 2020-11-24T10:14:31.325785
0 2020-11-24T10:14:31.326453
1 2020-11-24T10:14:31.326927
0 2020-11-24T10:14:31.327589
1 2020-11-24T10:14:31.328064
0 2020-11-24T10:14:31.329898
1 2020-11-24T10:14:31.330335
0 2020-11-24T10:14:31.330809
1 2020-11-24T10:14:31.331572
0 2020-11-24T10:14:31.333278
1 2020-11-24T10:14:31.333753
0 2020-11-24T10:14:31.335543
1 2020-11-24T10:14:31.336043
0 2020-11-24T10:14:31.336674
1 2020-11-24T10:14:31.337190
0 2020-11-24T10:14:31.338941
1 2020-11-24T10:14:31.339489
0 2020-11-24T10:14:31.341160
1 2020-11-24T10:14:31.341743
0 2020-11-24T10:14:31.343484
1 2020-11-24T10:14:31.343990

たぶん、この中に電源の信号パターンがあり、繰り返し送信されているものかと。

それと、この信号を再現させるために、大体0.1ミリ秒ごとに0/1のパターンデータを作成して、送信するっていう形の方が良いのかな。

ちょっとこれを元に考えてみます。

「【ラズパイ】リモコンの赤外線を受信してみる。」への1件のフィードバック

コメントを残す

メールアドレスが公開されることはありません。

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください