Turning an Atom Lite into an Infrared Proxy

A photo of an m5stack Atom Lite which has been flashed with ESPHome firmware to act as a Bluetooth Proxy for Home Assistant

Earlier this month, I wrote about adding Bluetooth Proxy support to an existing Infrared Proxy. Today, I’m doing the opposite: taking an m5stack Atom Lite which already acts as a Bluetooth Proxy, and enabling its Infrared pin in ESPHome.

I’d originally set up the m5stack Atom Lite using the Ready-Made Projects tool on the ESPHome web site, and so all it could do was act as a Bluetooth Proxy. Essentially, all its other features were disabled. Back then, being a Bluetooth Proxy was quite taxing even for an ESP32-based device, and so it was recommended that you didn’t enable its other functions.

Nowadays, the code that powers the Bluetooth Proxy component is more efficient, and so it’s possible to open up some of the other features of the Atom Lite. I’m going to focus on the Infrared Proxy component, as this is relatively new to ESPHome and Home Assistant.

Enabling the Infrared pin

To enable the Infrared pin in ESPHome, we need to add the following YAML code:

remote_transmitter:
  - id: ir_tx
    pin: GPIO12
    carrier_duty_percent: 50
    non_blocking: true

You can also do this in the ESPHome Device Builder using the interface:

  1. Add the Remote Transmitter component.
  2. Enter the pin number as ‘GPIO12‘.
  3. Set ‘Carrier Duty Percent’ to ‘50‘.
  4. Set the ID to ‘ir_tx‘.

Adding the Infrared Proxy

Next, we need to enable the Infrared Proxy component. Again, here’s the YAML code:

infrared:
  - platform: ir_rf_proxy
    name: IR Transmitter
    remote_transmitter_id: ir_tx

And here are the steps to add it in the user interface:

  1. Add the ‘IR/RF Proxy’ component.
  2. Name it ‘IR Transmitter’
  3. Set the Remote Transmitter ID to ‘ir_tx‘, matching the name in step four above.

Save it, recompile your code and upload it to your Atom Lite. If this is already linked with Home Assistant, then you should see it added as an Infrared Remote under Settings, Connectivity, Infrared.

Note that whilst the Atom Lite can send Infrared commands, it doesn’t have the ability to receive them. That means it’s not possible for it to learn commands from other remotes; it can only send pre-defined commands.

Using it in practice to control a Sony Blu-Ray player

Whilst it’s rare that we watch physical media nowadays, we do still have a functioning Blu-Ray player. By parking the Atom Lite in front of it, and using this integration from HACS, it’s now possible to control it using Home Assistant. So far I’ve only tested opening and closing the disc tray but Home Assistant should be capable of controlling most features of the Blu-Ray player.

Enabling other Atom Lite features

The Atom Lite is designed to be a development board, and so features a number of pins that you can connect up to third party sensors or other devices. But it also has a couple of additional onboard features, besides its ESP32 chip and Infrared pin:

  • A button
  • A colour-changing LED

The m5stack documentation includes the necessary YAML code if you want to enable these in ESPHome too. I’ve enabled the colour-changing LED, although as yet I haven’t worked out what to do with it.

Creating a Bluetooth proxy with ESPHome

A photo of an m5stack Atom Lite which has been flashed with ESPHome firmware to act as a Bluetooth Proxy for Home Assistant

My latest Home Assistant project has been creating a Bluetooth Proxy – a device that essentially extends the range of my Raspberry Pi’s Bluetooth signal. To do this, I’ve purchased a small device with a ESP32 chip on, and flashed it with firmware from ESPHome.

Okay, so that introduction has a lot of jargon. Allow me to break it down a little.

What is a Bluetooth proxy?

Because Bluetooth connections are point-to-point, you can’t use range extenders like you can with Wifi, Zigbee and Thread networks. That means that any Bluetooth devices that you want to connect to Home Assistant need to be in range of the device that you’re running Home Assistant on. I recently moved my Raspberry Pi to a different location, which meant that it was out of range of one of my Bluetooth thermometers.

A Bluetooth proxy acts as a kind-of bridge between Bluetooth and Wi-Fi. You place the proxy device within range of the Bluetooth devices that you want to connect to Home Assistant, and connect it to your home Wi-Fi network. Once set up, Home Assistant should see your Bluetooth devices as if they were in range.

If you’re running Home Assistant Container, then a Bluetooth proxy may also be easier to set up than a USB Bluetooth dongle. Passing USB devices into a Docker image doesn’t always work well.

It’s worth noting here that Bluetooth proxies are just a Home Assistant ‘thing’. They won’t help you connect a Bluetooth speaker to, say, a smartphone that’s out of range. Also, you can’t buy a device that works as a Bluetooth proxy out of the box. Seriously, if you go onto Amazon and search for ‘Bluetooth proxy’ (sponsored link), all you will get is results for Bluetooth adaptors and development boards with ESP32 chips.

The M5Stack Atom Lite

Whilst there are lots of boards that you can buy, a good option is the M5Stack Atom Lite (also available from AliExpress, where I got mine). This is because it comes with a plastic case, and connects easily using a USB-C cable. You could buy a different board and make your own case for it, but I don’t have a lot of time right now and don’t own a 3D printer. Besides, it costs less than £10 delivered.

The device is tiny – about the size of a 50p piece, and less than a centimetre thick. Because it’s a development board, it also comes with several pins to connect to other devices, but these aren’t necessary if you’re just using it as a Bluetooth proxy. Inside, is the Espressif ESP32 chip.

There are other ESP32-based products in the M5Stack Atom range, that add (for example) a microphone or GPS chip, but again, we don’t need these for a simple Bluetooth proxy.

Installing ESPHome

ESPHome is a sister project to Home Assistant, as they’re both managed by the Open Home Foundation. It’s similar to Tasmota, which I’ve blogged about before, in that they’re both custom firmware packages that you can flash onto ESP devices. Whilst Tasmota and ESPHome can do many of the same things, if you want a Bluetooth proxy then you’ll need to use ESPHome as Tasmota doesn’t support it.

Probably the easiest way to install ESPHome is using one of the ready-made projects. These can be flashed directly from your web browser, as long as you’re using Chrome or Edge (Firefox doesn’t yet support WebSerial so won’t work). You’ll need to connect your Atom Lite to your computer using a USB-C cable that supports both data and charging. You may also need to install the USB drivers – on my Windows 10 machine, the ‘CH9102_VCP_SER_Windows’ download worked. You should then be able to install the firmware, which will take a couple of minutes. Once done, you’ll be prompted for your home Wi-Fi network name and password, and then you should be good to go. Home Assistant will hopefully detect your new Bluetooth proxy automatically.

Managing your Bluetooth proxy in ESPHome

I used ‘hopefully’ in the previous sentence, because this didn’t happen in my case. As I used Home Assistant Supervised, I was able to install the official ESPHome addon; if you use Docker, you can just run docker pull ghcr.io/esphome/esphome to install it. Once installed, the ESPHome addon/docker image should detect your Bluetooth proxy and allow you to ‘adopt’ it.

This will let you view the hostname of your Bluetooth proxy device, which will be something like ‘atom-bluetooth-proxy-wibble.local‘. You can then add the ESPHome integration to Home Assistant, specifying the hostname, and you’ll be good to go. As soon as the integration was working, Home Assistant was able to see a new Bluetooth device and allowed me to configure the integration.

Going forward, you should find that Home Assistant is able to automatically update your ESPHome devices whenever new firmware is available – this is a new feature from the 2024.07 release. But you can also use the ESPHome addon/docker image to add or change features on your device. You could, for example, allow your device to act as an iBeacon as well (I think).

One thing to bear in mind is that Bluetooth and Wi-Fi both use the same 2.4 GHz frequency band. So, if you’re comfortable building your own board with a wired Ethernet connection instead of Wi-Fi, then you may get better performance.

Creative Commons License
Except where otherwise noted, the content on this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.