<article-heading title="Media center remote: Infrared receiver" is-published="true" updated-date="2021-09-04" /> <p class="article-description"> The first stage of making the <a href="" data-article="media-center-remote">media center remote</a> is setting up a basic ESPHome configuration to receive and decode infrared signals. </p> <p>The goals of this stage are to:</p> <ul> <li>Get the ESP8266 to connect to a WiFi network.</li> <li>Get the infrared receiver wired up to receive and log incoming infrared signals.</li> <li>Correlate the remote controller button presses to the resulting signals.</li> </ul> <section class="gallery previews-large"> <figure> <img src="/content/articles/media-center-remote/infrared-receiver/media-center-remote-stage-1-breadboard-diagram.png" alt="A breadboard diagram showing an ESP8266 connected to an infrared receiver module" /> <figcaption>Stage 1 breadboard diagram</figcaption> </figure> <figure> <img src="/content/articles/media-center-remote/infrared-receiver/media-center-remote-stage-1-prototype.jpg" alt="An ESP8266 wired up to an infrared receiver module" /> <figcaption>Stage 1 prototype</figcaption> </figure> <figure> <img src="/content/articles/media-center-remote/infrared-receiver/remote-controller.jpg" alt="A generic 21-button remote controller" /> <figcaption>"Car MP3" remote controller</figcaption> </figure> </section> <h2>ESPHome configuration</h2> <h3><code class="inline">media-center-remote.yaml</code></h3> <pre class="prettyprint" v-pre="v-pre"> <code class="lang-yaml">esphome: name: media-center-remote platform: ESP8266 board: esp01_1m api: password: !secret media_center_remote_ota_password logger: baud_rate: 0 ota: password: !secret media_center_remote_ota_password wifi: ssid: !secret wifi_ssid password: !secret wifi_password # Skip searching for available networks first fast_connect: true # Connecting is faster and more reliable if you don't wait for DHCP. # Just make sure the router is also configured to reserve this address for your device. manual_ip: static_ip: !secret media_center_remote_wifi_manual_ip_static_ip gateway: !secret media_center_remote_wifi_manual_ip_gateway subnet: !secret media_center_remote_wifi_manual_ip_subnet remote_receiver: pin: number: GPIO2 inverted: true # The Car MP3 remote controller signals can be interpreted as LG codes, # so let's just pretend it's an LG remote controller. dump: - lg</code> </pre> <h3>Log output</h3> <p> Powering up the device and pressing buttons on the remote controller yields logs similar to the following: </p> <pre class="prettyprint" v-pre="v-pre"><code>... [17:48:34][C][remote_receiver.esp8266:059]: Remote Receiver: [17:48:34][C][remote_receiver.esp8266:060]: Pin: GPIO2 (Mode: INPUT, INVERTED) [17:48:34][C][remote_receiver.esp8266:065]: Buffer Size: 1000 [17:48:34][C][remote_receiver.esp8266:066]: Tolerance: 25% [17:48:34][C][remote_receiver.esp8266:067]: Filter out pulses shorter than: 50 us [17:48:34][C][remote_receiver.esp8266:068]: Signal is done after 10000 us of no changes ... [17:48:47][D][remote.lg:053]: Received LG: data=0x00FFA25D, nbits=32 [17:48:49][D][remote.lg:053]: Received LG: data=0x00FF629D, nbits=32 [17:48:50][D][remote.lg:053]: Received LG: data=0x00FFE21D, nbits=32</code></pre> <h2>Next steps</h2> <p> </p>With the infrared receiver working, it's time to react to these signals in Stage 2: <a data-article="media-center-remote/kodi-integration">Kodi integration</a>. <p> This article is part of the <a data-article="media-center-remote">Media center remote</a> set. If you have any feedback or questions related to this article, please reply to <a href="https://twitter.com/TassSinclair/status/1434156531663048707">my post on Twitter</a>. </p>