Transform your adjustable bed into a smart home device using an ESP32 microcontroller and ESPHome. This project allows you to control your bed remotely through Home Assistant while preserving the original remote functionality.
- Overview
- Hardware Requirements
- Wiring Guide
- ESPHome Configuration
- Home Assistant Integration
- 3D Printed Case
- Installation Steps
- Troubleshooting
- Safety Considerations
This project enables smart control of adjustable beds by intercepting and replicating the signals from the original remote control. The ESP32 board acts as an intermediary, allowing both the original remote and Home Assistant to control the bed functions.
- Control bed head and foot positions remotely via Home Assistant
- Preserve original remote functionality
- WiFi connectivity for smart home integration
- Status LED indicator
- Safe relay-based switching
| Component | Description | Example Link |
|---|---|---|
| ESP32 Development Board | 4-relay ESP32 board with 7-30V power input | Amazon Canada |
| USB to TTL Converter | For programming the ESP32 board | Amazon Canada |
| DIN5 Extension Cable | To interface with bed's control system | Amazon Canada |
- Wire strippers
- Soldering iron and solder
- Multimeter (recommended)
- Screwdriver set
The bed remote uses a DIN5 connector with the following pin configuration:
| DIN5 Pin | Wire Color | Function |
|---|---|---|
| 1 | Red | Motor 2, Terminal 1 (Feet Up) |
| 2 | Yellow | Motor 1, Terminal 1 (Head Up) |
| 3 | Green | Positive (+) Power |
| 4 | Blue/Orange* | Motor 2, Terminal 2 (Feet Down) |
| 5 | Black | Motor 1, Terminal 2 (Head Down) |
| 6 | White | Negative (-) Power |
*Note: Extension cable may use orange instead of blue
- Green (+): Connect to ESP32 7-30V input and daisy-chain to all relay NO (Normally Open) contacts
- White (-): Connect to ESP32 GND input and daisy-chain to all relay NC (Normally Closed) contacts
Split the extension cable, connect the male end to the bed and wire the cables to the board as following :
| ESP32 Relay | Wire Color | Function | DIN5 Pin |
|---|---|---|---|
| Switch 1 COM | Black | Head Down | Pin 5 |
| Switch 2 COM | Orange/Blue | Feet Down | Pin 4 |
| Switch 3 COM | Yellow | Head Up | Pin 2 |
| Switch 4 COM | Red | Feet Up | Pin 1 |
Connect the remote in the female end of the extension cable and wire the cables to ESP32 GPIO pins to maintain remote functionality:
| ESP32 GPIO | Wire Color | Function |
|---|---|---|
| GPIO 2 | Black | Head Down Detection |
| GPIO 4 | Red | Feet Up Detection |
| GPIO 17 | Yellow | Head Up Detection |
| GPIO 18 | Orange/Blue | Feet Down Detection |
| GND | Green | Ground Reference |
The ESP32 runs ESPHome firmware with the provided SmartBed.yaml configuration. Key features:
output:
- platform: gpio
pin: GPIO32
id: relay_pin_1 # Head Down
- platform: gpio
pin: GPIO33
id: relay_pin_2 # Feet Down
- platform: gpio
pin: GPIO25
id: relay_pin_3 # Head Up
- platform: gpio
pin: GPIO26
id: relay_pin_4 # Feet Upswitch:
- platform: output
id: relay_1
name: "Head down"
output: relay_pin_1
- platform: output
id: relay_2
name: "Feet down"
output: relay_pin_2
- platform: output
id: relay_3
name: "Head up"
output: relay_pin_3
- platform: output
id: relay_4
name: "Feet up"
output: relay_pin_4The configuration includes binary sensors for each remote button that trigger the corresponding relays, ensuring the original remote continues to work alongside the smart controls.
Once the ESP32 is running ESPHome, it will automatically appear in Home Assistant as four switch entities:
switch.esphome_web_861ea0_head_downswitch.esphome_web_861ea0_head_upswitch.esphome_web_861ea0_feet_downswitch.esphome_web_861ea0_feet_up
These can be used in automations, scripts, and dashboards.
A custom 3D printable case is provided to protect the ESP32 board and provide professional mounting options.
- Snap-fit lid: Tool-free access for maintenance
- Cable management: Two cable entry points with integrated strain relief
- LED visibility: Windows for all relay and status LEDs
- Ventilation: Slots for heat dissipation
- Internal wire management: Channels to secure Dupont connections
box.stl- Main enclosure box for 3D printingcover.stl- Top cover/lid for 3D printing
Print Settings:
- Layer height: 0.2mm
- Infill: 20%
- Support: None required
- Print orientation: Bottom face down for both parts
Materials:
- PLA: Recommended for indoor use
- PETG: Better temperature resistance
- ABS: Maximum durability
Post-Processing:
- Remove any stringing or supports
- Test fit the snap mechanism before assembly
- Ensure cable holes are clear of debris
- Install board: Mount ESP32 board using M3 screws into integrated posts
- Route cables: Thread cables through strain relief channels and out cable holes
- Secure connections: Use internal channels to manage and secure wire connections
- Close case: Snap lid onto base using integrated tabs
Under-bed mounting (recommended):
- Position for easy cable routing to bed connection
- Ensure adequate clearance for lid removal
Wall mounting:
- Use appropriate anchors for wall type
- Consider cable management to connection points
-
Prepare the Hardware
- Cut the DIN5 extension cable in half
- Strip wire ends and identify each wire's function using a multimeter
-
Program the ESP32
- Install ESPHome
- Update WiFi credentials in
SmartBed.yaml - Flash the firmware using the USB to TTL converter
-
Make Connections
- Connect power wires (green/white) to ESP32 power input and relay commons
- Connect motor control wires to relay COM terminals
- Connect remote detection wires to GPIO pins
-
Test the System
- Verify original remote still functions
- Test each relay function from Home Assistant
- Check that movements stop when buttons are released
-
Install and Secure
- Mount the ESP32 board in a safe, accessible location
- Secure all connections
- Test final installation
Remote not working after installation:
- Check GPIO connections for remote detection
- Verify pullup resistors are enabled in configuration
- Test continuity of extension cable connections
ESP32 not responding:
- Check power connections (7-30V input)
- Verify WiFi credentials in configuration
- Check serial connection for programming
Bed movements don't stop:
- Verify NC (Normally Closed) relay connections
- Check that switches return to OFF state
- Review relay configuration in ESPHome
- Always test with original remote first
- Verify all movements stop when controls are released
- Check that relays are properly isolated
- Monitor for any unusual heating of components
- This project involves modifying electrical systems - ensure you understand basic electrical safety
- Always disconnect power when making connections
- Test thoroughly before regular use
- The original remote should always remain functional as a backup
- Consider having the installation reviewed by a qualified technician
This project is provided as-is for educational and personal use. Modify your bed's electrical system at your own risk.
Feel free to submit issues, improvements, or variations of this design. Photos and documentation updates are especially welcome.