Cambridge Audio CXA81 in Home Assistant with ESPHome (RS-232 + IR)
The Cambridge Audio CXA81 is a lovely amplifier with no network connection at all. I wanted it in Home Assistant: turn it on when the TV comes on, switch inputs from my phone, change the volume from the same scroll wheels that dim the lights, and, most of all, have Home Assistant know what the amp is doing when someone uses the remote instead.
It works now. An ESP32 the size of a sugar cube talks to the amp's RS-232 port for power, mute and input, and pretends to be the remote, over a wire, for volume. Soon it will live in a small printed box screwed onto the back of the amp; the case is on its way. This page has everything: the parts, the wiring, the protocol, the firmware, the case design, and everything that didn't work the first time.
The idea: two ports, two jobs
The back of the CXA81 has an RS232C socket and an IR in jack. Cambridge publishes the serial protocol (the CXA61 and CXA81 Serial Control Protocol, v1.0; my copy, in case that link moves), and it covers power, mute and input selection, but not volume: there is simply no volume command. Volume is an infrared-only affair. So the controller uses both: RS-232 for everything it can, and a wire into the IR input for volume.
The nice part of the serial port is that it is two-way. The amp announces changes on its own: press standby on the remote or turn the input knob, and a line comes down the cable a moment later. So Home Assistant always shows the real state, not a guess. Infrared is one-way and blind, which is fine for volume steps, since nothing needs to know the absolute volume.
Parts
| Part | Why |
|---|---|
| M5Stack ATOM Lite | ESP32 (PICO-D4) in a 24 × 24 mm box, with a button, an RGB LED and a Grove port. Runs ESPHome. |
| M5Stack Atomic RS232 Base (A136) | The ATOM clicks onto it. Proper RS-232 levels and a screw terminal for TX, RX and GND. |
| DB9 male to screw-terminal adapter | Plugs into the amp's RS232C socket, screws on with its own long bolts. I took it out of its housing to fit the case. |
| 3.5 mm mono (TS) plug with screw terminals | For the IR in jack. Mono matters: tip is signal, sleeve is ground. |
| A few short wires, a USB-C cable and a 5 V USB power supply | The ATOM runs from USB-C. Nothing is taken from the amp. |
| A Flipper Zero (optional) | To read the remote's codes. Any IR receiver that decodes RC-5 works, or just use mine below. |
| The printed case (optional) | Three parts, below. I don't own a printer, so I ordered it from Flintform. It hasn't arrived yet. |
The serial protocol
9600 baud, 8 data bits, no parity, 1 stop bit (9600 8N1), plain ASCII. Every message looks like #group,number[,data] followed by a carriage return. Commands go out in one group and the amp answers in the next group up: amplifier commands are group 1 and their replies group 2, source commands group 3 and replies group 4.
The full command list is in Cambridge's CXA61 and CXA81 Serial Control Protocol (PDF, 5 pages; there's a backup copy here). The handful I use:
| Send | Means | Reply |
|---|---|---|
#1,01 | What's the power state? | #2,01,1 on, #2,01,0 standby |
#1,02,1 / #1,02,0 | Power on / standby | #2,01,… |
#1,03 | Is it muted? | #2,03,1 or #2,03,0 |
#1,04,1 / #1,04,0 | Mute / unmute | #2,03,… |
#3,01 | Which input? | #4,01,NN |
#3,04,NN | Select input NN | #4,01,NN |
#13,02 | Firmware version | #14,02,… (mine: 04000G01A61E) |
Input codes: 00–03 are A1–A4, 04–06 D1–D3 (digital), 14 Bluetooth, 16 USB Audio, 20 A1 Balanced. Errors come back in group 0: #0,01 unknown group, #0,02 unknown number, #0,03 bad data, #0,04 not available right now.
Wiring
RS-232. TX, RX and ground, nothing else; leave the base's 12 V terminal alone. The protocol document doesn't say which pin the amp transmits on, so it's a coin toss: I started with TX on pin 3 and got nothing back, not a single byte. Swapping pins 2 and 3 fixed it immediately. Swapping is harmless, so if your amp doesn't answer, that's the first thing to try.
Infrared. G26 from the Grove port goes to the tip, GND to the sleeve, and the plug goes into IR in (not the Control Bus sockets next to it). No resistor: see the next section. Since the tip brushes the sleeve contact as a plug goes in, plug it in before powering the ATOM.
Volume over infrared, by wire
First, the codes. Pointing the original remote at a Flipper Zero (Infrared → Learn New Remote) decoded them straight away: RC-5, address 0x10, command 0x10 for volume up and 0x11 for volume down. RC-5 is Philips' old protocol: 14 bits, Manchester coded, each bit two halves of 889 µs, on a 36 kHz carrier.
Then the hard part: what does an "IR in" jack actually want? A remote's LED flashes a 36 kHz carrier; an IR receiver strips the carrier and outputs a clean signal that is high when idle and goes low during each flash. A wired IR input might want either, and Cambridge doesn't say. So I tried them, one firmware update over Wi-Fi each, pressing volume up and watching the knob:
| Try | Signal | Series resistor | Result |
|---|---|---|---|
| 1 | 36 kHz carrier, normal polarity | 1 kΩ | nothing |
| 2 | 36 kHz carrier, inverted | 1 kΩ | nothing |
| 3 | no carrier, inverted (like a receiver's output) | 1 kΩ | nothing |
| 4 | 36 kHz carrier, inverted | none | the volume went up |
The resistor was the problem all along. I'd added 1 kΩ in series out of habit, to protect the pin. But the input pulls itself up, and through 1 kΩ the ATOM could not drag the line low enough for the amp to see a signal. Without it, the inverted, carrier-modulated signal works every time.
One honest caveat: I only tried the other formats with the resistor fitted. One of them may also work without it. Inverted with the carrier works, so I stopped there.
The ESPHome firmware
Everything is in one ESPHome file, cxa81.yaml. The interesting parts:
Sending. Commands go through a queued script that adds the carriage return and waits 150 ms, so the amp gets one thing at a time and has time to answer.
cxa81.yamluart:
id: amp_uart
tx_pin: GPIO19 # Atomic RS232 Base
rx_pin: GPIO22
baud_rate: 9600 # 8N1 is the default
script:
- id: amp_send
mode: queued
max_runs: 20
parameters:
cmd: string
then:
- lambda: |-
std::string msg = cmd + "\r";
id(amp_uart).write_str(msg.c_str());
- delay: 150ms
Listening. Every 50 ms a small parser reads whatever has arrived, splits it into lines on \r, then into group, number and data, and publishes the state. Because this runs for every line, replies to our own commands and the amp's own announcements are handled the same way. That is the whole trick to staying in sync.
cxa81.yamlif (group == 2 && number == 1) {
id(amp_power).publish_state(data == "1");
} else if (group == 2 && number == 3) {
id(amp_mute).publish_state(data == "1");
} else if (group == 4 && number == 1) {
// source code -> "A1", "D2", "Bluetooth", ...
}
At boot, and every 60 seconds as a safety net, it asks for power, mute, input and firmware. The power and mute switches use restore_mode: DISABLED, so a reboot of the ATOM never sends anything to the amp. I learned that one when the first boot put the amp into standby.
Volume. One remote_transmitter on G26, inverted, and two scripts that each send one RC-5 frame followed by a 120 ms gap, so the amp sees separate presses rather than one long hold:
cxa81.yamlremote_transmitter:
id: ir_tx
pin:
number: GPIO26
inverted: true # idle high, bursts pull low
carrier_duty_percent: 50% # the RC-5 action sets 36 kHz
script:
- id: ir_volume_up
mode: queued
then:
- remote_transmitter.transmit_rc5:
address: 0x10
command: 0x10 # 0x11 = volume down
- delay: 120ms
An action for Home Assistant. volume_step takes a signed number of steps (capped at 20), so an automation can say "louder by 3" in one call:
cxa81.yamlapi:
encryption:
key: !secret cxa81_api_key
actions:
- action: volume_step
variables:
steps: int
then:
- repeat:
count: !lambda "return std::min<int>(abs(steps), 20);"
then:
- if:
condition:
lambda: "return steps > 0;"
then:
- script.execute: ir_volume_up
else:
- script.execute: ir_volume_down
- script.wait: ir_volume_up
- script.wait: ir_volume_down
To build it yourself, put cxa81.yaml next to a secrets.yaml (start from secrets.example.yaml), flash it once over USB with esphome run cxa81.yaml, and after that over Wi-Fi.
In Home Assistant
Home Assistant finds the ATOM on its own (Settings → Devices & services → ESPHome, with the API key from secrets.yaml). It shows up as Amplifier:
| Entity | Does |
|---|---|
switch.amplifier_power | On / standby, follows the remote |
switch.amplifier_mute | Mute, follows the remote |
select.amplifier_source | A1–A4, D1–D3, Bluetooth, USB Audio, A1 Balanced |
button.amplifier_volume_up / _down | One volume step |
esphome.cxa81_volume_step | Action: several steps at once, negative for quieter |
binary_sensor.amplifier_button | The ATOM's own button, which toggles the amp's power |
sensor.amplifier_firmware, sensor.amplifier_wifi_signal | Diagnostics |
For example, an automation step that turns it up by three:
action: esphome.cxa81_volume_step
data:
steps: 3 # -3 for quieter
Turning the amp on from standby over RS-232 works fine with the normal standby mode. I haven't tried it in Eco standby, where the amp may switch its serial port off.
The case
Status: not built yet. The parts are printing at Flintform and haven't arrived. Everything in this section is the design and the plan: nothing has been test-fitted, so a measurement may still be off. I'll update this post once it's on the amp.
A bare circuit board with wires hanging off the back of a nice amp is not a look. The goal: a small closed box where you see only the DB9 plug going into the amp and one cable leaving the side. Two things made it fiddly. The ATOM on its base is 56 mm long, more than the box could be deep, so it lies across the case on a shelf. And the DB9 adapter only fits once its plastic housing is removed, so the case holds the bare board by its metal flange.

Seen from above with the lid off:
+---------------------------------------+
| o bolt heads (outside, at back) o |
| +-------------------------------+ :: |
USB-C == | ATOM + RS232 base, on a shelf | :: | :: gap for the RS-232
+ IR == +-------------------------------+ :: | wires to go down
| (DB9 board under the shelf) |
+--------------[ DB9 ]----------------+
- Body: a tray with a slot in the front wall for the DB9 flange.
- Shelf: drops onto ledges above the board and carries the ATOM; its front closes the slot above the flange.
- Lid: a flat plate held by four M2.5 × 8 mm countersunk self-tapping screws.
The adapter's own long bolts go in from the back, through the case and the flange, into the amp's socket. So the case is screwed to the amp, and comes off again, without opening it.
It's designed in code rather than a CAD program: a Python script using manifold3d builds the parts from measured dimensions, writes the STL files and draws the preview above. Change a measurement at the top and run it again. One bug worth sharing: an early version hollowed the body before cutting the lid off, which left a skin of zero thickness across the top opening. Invisible in the preview, very visible to a slicer. Hollow after splitting.
pip install manifold3d trimesh numpy matplotlib
python cxa81_dongle.py # writes the three STLs and the preview
The plan for assembly: board in (flange into the front slot), screw the RS-232 wires to its terminals, bolts in from the back, shelf in with the wires up through its slot, ATOM on the shelf, plug in USB-C and the IR lead (both cables leave through one notch in the side), lid on.
What I'd tell myself first
- Silence on RS-232 means swap 2 and 3. Before anything else.
- No series resistor on the IR wire. The IR input pulls itself up; with 1 kΩ in line, the ATOM couldn't pull it low enough.
- Inverted, with the carrier. For the CXA81's IR in, at least.
- Never let a reboot send commands.
restore_mode: DISABLEDon anything that talks to the amp. - Read the state, don't remember it. Parse every line the amp sends, not just the replies you expect.
- Wait after an OTA update. ESPHome rolls back a new firmware if the device restarts too soon after installing it. Give it a minute before unplugging anything.
Files
Everything needed to build your own:
| File | What |
|---|---|
| cxa81.yaml | The ESPHome firmware (10 kB) |
| cambridge-audio-cxa61-cxa81-serial-control-protocol.pdf | Cambridge Audio's serial protocol, v1.0 (627 kB). A copy of the original. |
| secrets.example.yaml | The secrets it expects |
| cxa81_dongle.py | The case, as a Python script (17 kB) |
| cxa81_case_body.stl | Case body, ready to print (231 kB) |
| cxa81_case_shelf.stl | Shelf for the ATOM (6 kB) |
| cxa81_case_lid.stl | Lid (102 kB) |
| cxa81_case_preview.png | The render above, full size |
Built over a few evenings with Claude Code as my pair: it wrote most of the YAML and the case script and read the ESPHome logs while I held the wires. Questions, or did it work on your amp? Sign the guestbook or get in touch.