Sonos speakers are great sounding and highly practical since you can control them from your phone, tablet or computer. I use the one installed in my bedroom to wake me up in the morning to my favorite tune. The speaker is installed at the other end of the room so if I want to stop the alarm, I must either walk to the speaker or launch the Sonos application from my mobile phone which is not always nearby since I don’t sleep with my phone. In order to wakeup more gently, I decided to build this Sonos remote control. It allows to stop the alarm, play/pause the currently playing tune, skip to the next one and raise/lower the volume.
It is based on a ESP8266 combined with a cheap ATTINY85 that allows easier and better power management and will give you over a year of operation on a small 500 mAh Li-Po battery.
IMPORTANT: In order to get this remote to work, you’ll need a device able to run node.js. This could be a desktop computer or a Raspberry Pi. It will run the excellent Sonos HTTP API by jishi which is based onnode.js. I installed it on my desktop and configured it as a service.
Material- ESP01
- Attiny85
- 2 x Momentary push buttons
- JST connector
- Li-Po Battery 500 mAh
- 2N3904 transistor
I initially built this circuit without the ATTINY85. It worked fine but I went through batteries way to fast, even though the ESP01 was almost always in deep sleep mode with the LED unsoldered. This might have been caused by some object being left on the remote who kept the button pushed indefinitely. Since the ESP01 functionalities a too basic when in deep sleep, there is no way to handle this kind of situation.
Also, I wanted to add another button and double click detection but the ESP01 is not able to determine which one was pressed after waking up from deep sleep since the wake-up process is triggered through the reset pin.
Using the ATTINY85 as proved to be a wise choice for this.The ATTINY code is using less than 2uA while in sleep mode. I use hardware interrupts on the buttons to wake it up. Once triggered, the ATTINY determines which button was pressed, single or double-clicked. It then switches the ESP01 on through the 2N3904 transistor, wait for it to come online and sends the command associated with the button pressed.
The first command sent will take between 3 to 10 seconds to perform since the ESP01 has to boot, connect to Wifi and send the command tothe web server. The ESP01 stays awake for another 20 seconds after the last command in order to avoid the repeat of the connection time.
Using the DeviceTop button (single click) : PlayPause
Top button (double click): PlayNext song
Bottom button (single click) : VolumeUp
Bottom button (double click) : VolumeDown
Building the deviceI made a PCB with the components soldered and 3D printed an enclosure for the device. Please note that I used breakaway headers for the ESP01 and machine pin breakway headers for the ATTINY so the chips can easily be removed and updated if needed in the future.
I also 3D printed a device holder so it can serve as an easy to reach “Stop the alarm” button in the morning. I position the remote upside down on it. Pressing on the back of the device sends a play/pause command to my SONOS speaker.
Comments