3D Printing, Electronics, Software

Bluetooth Snooze Button for iPhone

I like to sleep in late just like everyone else, but lately, I have been trying to get on an earlier morning schedule. This involved multiple alarms like 5 or 6 that I would have to dismiss every morning. So I thought wouldn’t it be great to have a button on my nightstand to turn them off without having to look at my phone or even roll over, yes I am that lazy!

Doing some research I could not find a physical button available to link to my phone to perform this function. It used to be so easy to do on a physical alarm clock from my childhood just reach over and slam that big snooze button right on top of the clock!

So I decided to build something that would fulfill this purpose. But how do you actually do this on an iPhone? I discovered that some of the alarm functions can be controlled via the volume buttons on the device. Basically, if an alarm is going off and you push either of the volume buttons it will snooze the alarm. And if the alarm is designated without the snooze option it will disable the alarm.

Therefore I just need a way of changing the volume remotely so let’s use Bluetooth! I have previously seen that the remote camera shutter control of various Bluetooth remotes uses a similar mechanism by toggling the volume up and down to trigger the shutter. So I tested this theory with a camera shutter button by setting an alarm and seeing if it dismissed the alarm.

Lo and behold this worked!

Now I just need to build my own Bluetooth-connected button to control the volume and make it look like a snooze button. Let’s start with the electronics.

Electronics

I googled around a bit to see if someone had created a Bluetooth volume button using one of the common microcontrollers and a simple programming language like Arduino or Circuitpython. I found a very helpful learning article from Adafruit (they are amazing) that detailed how to set up a BLE (Bluetooth low energy) volume knob and button.

Adafruit: bluetooth-le-hid-volume-knob-with-circuitpython

Their example used the Circuit Playground Bluefruit – Bluetooth Low Energy development board to set up the Bluetooth and electronic connections so if you want to build something similar I would suggest this board.

I didn’t have this exact board but I did have something that uses the same microcontroller, a Nordic nRF52840 chip, It’s a much smaller board from Seeed Studio called the XIAO-BLE-Sense-nRF52840.

Seeed-XIAO-BLE-Sense-nRF52840

Thankfully this board is supported in the Adafruit CircuitPython ecosystem making this almost a one-to-one replacement besides some of the missing io and led peripherals.

All I need for this project is a battery so that it does not need to be plugged in the whole time and a switch to be able to press. I still had some leftover CherryMX switches from a keyboard project and had already designed a 3D-printed mount for the one in the Pieca Camera so I just reused that!

A quick soldering job and we should be up and running.

Programming

CircuitPython is an amazing language, it makes it super simple to experiment with the code, and Adafruit has hundreds of examples (case in point the previous learning link).

I first needed to set up CircuitPython to run on the board. It is not simply hitting the program button in Arduino. You need to add a .u2f file to the board’s boot process, plug in the board to a computer double click the reset and a boot USB drive comes up. Copy over the .u2f that was downloaded from the CircuitPython website. The board should reset and another USB drive should come up named CIRCUITPY.

https://circuitpython.org/board/Seeed_XIAO_nRF52840_Sense/

Download the Adafruit library code as well

https://circuitpython.org/libraries

With CircuitPython your code is executed in a code.py file on the drive so all you need to do is open up the file in a text editor and start programming. When you save the file the board updates and starts executing it, no compiling is needed.

You can then monitor the board over a serial terminal on Linux or using the Mu Editor on Windows or Mac.

https://learn.adafruit.com/welcome-to-circuitpython/advanced-serial-console-on-linux

I was able to copy a large portion of the Adafruit example code and libraries that set up the Bluetooth and HID descriptors. This is the most complicated part of the Bluetooth setup. I then also took an example of the button debouncing and state machine from the example to actuate the volume up and down.

One issue with the code is that I could not get the device to start up the Bluetooth when directly powered by the battery. It needed a USB connection to a computer to start, not sure what the underlying issue is but the code without the BLE setup worked fine off just battery power.

So my current workaround is to just start it up on USB and then keep it powered on till the battery dies not elegant but works in practice! Plus I’ve had this thing on for months now and no sign of stopping!

3D Printing

I did a few quick sketches taking inspiration from different kinds of buttons. But my main muse was the big red stop button and the iconic staples button. Then using OnShape I designed a shell, a mounting plate for the switch, and a CherryMX-compatible keycap with a big S printed on the top!

Testing

After throwing it all together with a little super glue I set it up on my nightstand connected it to my phone and went to sleep with my alarms all set up for the morning.

BEEP BEEP BEEP! I lazily reached over and pressed the big snooze button, Silence! Never have I giggled before drifting back to sleep. It worked just perfectly!

GitHub Project

If you would like to create your own Big-Snooze button check my open source code repo.

GitHub: Tschucker/Big-Snooze