Hi,
My Samsung TV has never turned on the bundled soundbar reliably so an infrared remote control to automate the system was a Good Idea™! After looking at the ESPhome docs for remote_receiver
and remote_transmitter
, hardware was needed to make the idea a reality.
I’m a greybeard engineer so although designing a PCB from scratch was possible, shortcuts to save time and cash are always appreciated. Research found two main options:
- Generic “ESP8285 ESP-01M IR Transceiver Wifi Module Remote Control Switch” bare PCB modules with a single IR LED
- Cheap, reasonable hardware, easy to program
- Single IR LED has poor spread
- Generic IR Blaster devices on eBay likely fitted with Tuya module
- The dumb Tuya module can’t easily be used, however, there are pin-similar ESP* brains which can be transplanted with some soldering, strapping resistors, and patience.
- Great IR range and spread as has multiple LEDs in a ring.
Version 1 - Generic ESP8285 ESP-01M IR Transceiver Wifi Module
These are small (24mm x 22mm) bare PCBs with an ESP01-M mounted vertically on the board and a full set of header pins. The electrical design is fine, although the mechanical design has been shrunk so the IR LED is masked by the ESP itself.
Programming was fairy simple with a standard USB-to-TTL serial cable and the ESPhome web tools. Short GPIO0
to ground, connect, flash.
The ESPhome software project wasn’t too bad to get working - once I’d read around IR documentation about the differences between protocols. Raw
is too low-level, so all
works better for common protocols where the libraries can actually decode the bitstream into hex digits ideal for saving and transmitting again.
Version 1 software - ESPhome example IR blaster project
substitutions:
name: esph-ir-tv
friendly_name: "IR Blaster TV"
version_s: "1.0"
esphome:
name: ${name}
friendly_name: ${friendly_name}
name_add_mac_suffix: False
# This will allow for (future) project identification,
# configuration and updates.
project:
name: floatingboater.${name}
version: $version_s
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "DELETED"
# Allow Over-The-Air updates
ota:
platform: esphome
password: "DELETED"
# Allow provisioning Wi-Fi via serial
improv_serial:
wifi:
# Set up a wifi access point
ssid: !secret wifi_ssid
password: !secret wifi_password
# temp to allow hostname change
# https://esphome.io/components/esphome#changing-esphome-node-name
#use_address: 192.168.1.99
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${name} Fallback Hotspot"
password: !secret fallback_ap_password
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
####################################
binary_sensor:
- platform: gpio
name: "Boot Mode"
# not useful in HASS, so don't publish
internal: True
pin:
number: GPIO0
inverted: True
on_click:
then:
- logger.log: "Button Press GPIO0"
# https://esphome.io/components/remote_receiver.html?highlight=remote_receiver
remote_receiver:
pin:
number: GPIO14
inverted: True
mode:
INPUT_PULLUP
# input: True
# pullup: True
tolerance: 25%
# Raw gives very verbose RAW IR data.
# dump: raw
# All gives partially decoded and identified hex data which is more useful to define buttons later on
dump: all
# - all
# - samsung
# - samsung36
# - nec
# - rc5
# https://esphome.io/components/remote_transmitter.html?highlight=remote_receiver
remote_transmitter:
pin:
number: GPIO4
mode:
output: True
# Infrared remotes use a 50% carrier signal
carrier_duty_percent: 50%
##################################
# IPremoteESP8266 Supported protocols
# https://github.com/crankyoldgit/IRremoteESP8266/blob/702ec8b3560b80c1f84e8df036f06d0daa09660b/SupportedProtocols.md
button:
# Example button - appears in HASS as a button, can be automated, and triggers an IR transmission
# Samsung TV
- platform: template
name: TV Power Toggle
icon: mdi:power
on_press:
- remote_transmitter.transmit_samsung:
data: 0xE0E040BF
This hardware worked well, although positioning it in front of the TV was far from ideal. A 3d-printed case existed, fitted, but blocked the IR LED spread even more.
A better emitter was needed…
Version 2 - Generic IR Blaster with a Tuya module transplant
After a peruse of my favourite refernece for ESP* hardware hacking across Tasmota, ESPhome, and others, the next upgrade seemed straightforward.
- Buy several generic IR blaster modules from eBay/ Amazon/ “the usual scumbags”
- Open the hardware and find one with a known Tuya module
- Replace the module with a matching ESP-12S vatiant
- Profit!
Reality!
I bought two generic IR blaster modules to ensure at least one would be “hackable”.
Circular variant - “AI UNIVERSAL REMOTE”
Apart from the very optimistic name, the small round hardware looks nice, and came with a micro-USB lead for power only.
Opening the unit showed SMT LEDs, and a Tuya CBU
module which could be swapped with an ESP variant.
Ultimately, I found it easier to get another type of module so…
Square variant - “WiFi Smart IR Controller”
This also came apart easily to show a ring of eight 5mm IR LEDs (with space for one more in the centre) and a Tuya CB3S, which is compatible with an ESP8266MOD ESP-12S.
https://web.esphome.io/?dashboard_install
ESP-12S were available next-day so this is the module that got hacked.
I decided against ordering the ESP programming test fixture BlakAdder shows as the IR blaster PCB had the usual row of pin-headers - or so I thought!
I’d buy the programmer PCB as getting an ESP12-S to boot, and then flash-write was harder than expected.
TIP: The ESP12-S needs several strapping pins to boot.
Messing about with the ESPhome web tools and pin-headers wasted about half a day.
Basically, follow this (stolen) diagram:
I setup an ESP module on a breadboard with fine jumper pins through the holes and experimented until it flashed using 3V3 Tx / Rx from a USB-serial cable.
To save you the hassle, solder the module to the PCB and add:
- 10k pull UP to
CH_PD
(CHIP_EN
) - 10k pull DOWN to
GPIO15
(no idea why) - A wire to
GPIO0
(as the pin-header connects toGPIO2
- not useful!)
Here’s what it looks like:
After the pain of getting the ESP to boot with the additional strapping pins (10k resistors), the ESPhome software project was pretty simple.
Pin | Function |
---|---|
GPIO0 | NC - programming mode |
GPIO2 | Header Pin and ESP Blue LED |
GPIO5 | LED1 (tiny hole in the case) |
GPIO12 | IRRX |
GPIO13 | Button (underneath) |
GPIO14 | IRTX |
Version 2 software - ESPhome project
I added definitions for all of the hardware, but to be honest, the two blue LEDs are invisible in the case. I also added a 5mm red LED in the centre of the PCB, but after testing, it was removed as it’s invisible though the case and wastes IR transmit power!
Note the structure of ESPhome is slightly different as this is based on the template automatically added by current ESPhome versions. It seems to use includes for stuff like the API keys and portal - I left this alone as it worked fine!
substitutions:
name: esphome-web-dead00
friendly_name: "IR Blaster Square"
version_s: "1.0"
esphome:
name: ${name}
friendly_name: ${friendly_name}
min_version: 2024.6.0
name_add_mac_suffix: false
# This will allow for (future) project identification,
# configuration and updates.
project:
name: floatingboater.${name}
version: $version_s
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
# Allow provisioning Wi-Fi via serial
improv_serial:
wifi:
# Set up a wifi access point
ap: {}
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
dashboard_import:
package_import_url: github://esphome/example-configs/esphome-web/esp8266.yaml@main
import_full_config: true
# To have a "next url" for improv serial
web_server:
####################################
binary_sensor:
- platform: gpio
name: "Boot Mode"
# not useful in HASS, so don't publish
internal: True
pin:
number: GPIO0
inverted: True
# Test - set GPIO2 as an input
# - platform: gpio
# name: "Header Pin"
# # not useful in HASS, so don't publish
# internal: True
# pin:
# number: GPIO2
# inverted: True
- platform: gpio
name: "Button"
# not useful in HASS, so don't publish
internal: True
pin:
number: GPIO13
inverted: True
on_click:
then:
- logger.log: "Button Click"
output:
# Blue LED on PCB called LED1
- platform: gpio
pin: GPIO5
inverted: False
id: LED1
# Blue LED on ESP, also Header Pin
- platform: gpio
pin: GPIO2
inverted: True
id: LED_ESP
# Testing - IRTX inverted output (gets warm if ON 100%)
# - platform: gpio
# pin: GPIO14
# inverted: True
# id: IRTX
# https://esphome.io/components/remote_receiver.html?highlight=remote_receiver
remote_receiver:
pin:
number: GPIO12
inverted: True
mode:
INPUT_PULLUP
# input: True
# pullup: True
tolerance: 25%
# dump: raw
dump: all
# - all
# - samsung
# - samsung36
# - nec
# - rc5
# https://esphome.io/components/remote_transmitter.html?highlight=remote_receiver
remote_transmitter:
pin:
number: GPIO14
mode:
output: True
# Infrared remotes use a 50% carrier signal
carrier_duty_percent: 50%
##################################
button:
- platform: output
name: "LED1"
output: LED1
duration: 500ms
- platform: output
name: "ESP LED"
output: LED_ESP
duration: 500ms
# - platform: output
# name: "IR TX"
# output: IRTX
# duration: 500ms
# IPremoteESP8266 Supported protocols
# https://github.com/crankyoldgit/IRremoteESP8266/blob/702ec8b3560b80c1f84e8df036f06d0daa09660b/SupportedProtocols.md
# Samsung TV
- platform: template
name: TV Power Toggle
icon: mdi:power
on_press:
- remote_transmitter.transmit_samsung:
data: 0xE0E040BF
- platform: template
name: TV Power ON
icon: mdi:power-on
on_press:
- remote_transmitter.transmit_samsung:
data: 0xE0E09966
- platform: template
name: TV Power OFF
icon: mdi:power-off
on_press:
- remote_transmitter.transmit_samsung:
data: 0xE0E019E6
This second version took more work to get the hardware booting, but the IR range and spread is significantly better. It also gives a professional case powered from a micro-USB cable from an unused STBox port so is rather neat.
Summary
- There are many pre-built modules out there that enable “off the shelf” ESPhome projects to be created with a little knowledge.
- The documentation of these modules is terrible, they are widely copied again and again and again so some work, some are literal eWaste.
- Tuya modules are everywhere in cheap £10 products, but there are options to perform a
brain transplant
if you have the soldering skills. - The PCBs might look the same as an ESP-variant, but Tuya modules seem to need less pins connected to boot. This caught me out - although 2x 10k resistors were pretty simple to add.
- If you can, buy a programming test fixture from the same source - this would have saved me some time, although time learning the strapping pins might have been delayed rather than removed.
Thanks go to the original creators of the strapping pin diagram (links included), and BlakAdder’s Tasmota hardware hacking site.
Happy Hardware Hacking,
James
If this helps, this post!