Design challenges with Bluetooth for a wooden remote
Step 1/4 in the “Everything you need to build your own Turn Touch smart remote” series
This is part of the full guide on how to make your own Turn Touch from scratch. This is the story of the design challenges faced when trying to make a seamless remote and how to overcome them. If you follow this guide, using the accompanying open-source design files, then you will be able to build your own Turn Touch that you can use to control your smart devices and apps on your phone and computer.
If you want to get your own, Turn Touch is on Kickstarter.
At the heart of Turn Touch lies a circuit board with four tactile switches and a bluetooth module. This board alone is the remote, since it can be used without a wooden enclosure.
The source code for the Bluetooth firmware, circuit board schematic, and board layout is available on Github.
The circuit board is composed of four parts:
- Bluetooth module
- Other board components
- The PCB
- Metal dome sticker array
Choosing a Bluetooth radio isn’t trivial. In fact, choosing Bluetooth in the first place is a tradeoff.
The goal for the remote is to control smart devices, but those devices range in terms of which wireless protocol they speak. For the most part, you can assume WiFi is in the equation.
Philips Hue lightbulbs speak Zigbee, a low-power peer-to-peer mesh network, and connect to a hub that speaks both Zigbee and WiFi. Sonos speakers, Belkin Wemo smart power switches, Lockitron smart locks, and many others are also on WiFi.
So how about just using a WiFi module?
Part of the requirement for the remote is that a button press is near-instantaneous (with less than a 100 ms delay). But a WiFi module, such as the popular ESP8266, draws up to 250 mA at 3V (750 mW) when transmitting and as low as 0.9 mA when sleeping.
Considering a standard CR2032 coin cell battery has 225 mAh, you can run a WiFi module with normal use (sleeping 99% of the time) for only 28 hours if you want instantaneous feedback. You can use bigger batteries, but now you’re working on integrating giant AA batteries into a tiny hand-held remote, which won’t work.
Better yet would be to bring the WiFi module down to the 10 µA level. But that requires a deep sleep which severs the connection. So when you press a button that requires the module to wakeup from deep sleep, it can takes several seconds to register the click. Amazon Dash buttons work this way and are able to last for over a year, since a several second latency is not a problem for them.
Your phone to the rescue
The good news is that while WiFi is too power hungry for this type of device, our phones and tablets, which are on WiFi and get charged every single day, work as a terrific relay. Our phones speak Bluetooth, so why not use the still fresh Bluetooth Low Energy (BTLE) protocol?
There are a number of usable Bluetooth 4.0 modules to choose from. There’s the BlueGiga BLE112 module, Roving Networks RN-42 module, BlueRadios BR-LE4.0-S2A module, and the famous Nordic Semiconductor nRF51822 based MBDT40 by Raytec (pictured above).
The principle concerns for a Bluetooth module are:
- The microcontroller and accompanying example firmware
- Ease of over-the-air device firmware updates (OTA DFU)
- Module size and profile
- Power requirements
- Debugging abilities
- Community and support
- Development kit and documentation
Here’s how the most well known and easily available Bluetooth 4.0 modules compare.
While all of the modules fit the necessarily small footprint, the MDBT40 module with Nordic’s nRF51 series won out due to the robust community and plentiful open source examples. It also had twice the max output power with half the power requirements of the BLE112. Plus it came with example projects for over-the-air device firmware updates (OTA DFU), which allows the remote to be easily upgraded for firmware changes down the road.
Not enough can be said about a thriving open source community around the nRF51 chip. Running into problems with power management, over-the-air device firmware updates, and even paramters for load capacitors on external crystals can be cleared up by consulting the massive online community that formed around the Nordic chip.
Now that a Bluetooth module has been chosen, let’s move on to the passive electronic components that it needs to operate.
Other board components
The nRF51822 datasheet is solid. The standard GATT attributes of the Bluetooth stack is easy enough to implement. What we’re looking for in the datasheet are low power modes. The remote will be asleep for most of its life, but it needs the ability to wake up and transmit the button press in under 100 ms in order to be called instantaneous.
There are a couple options:
- Maintain connection with the phone/computer but in a low-power sleep. A coin cell battery lasts 1 year in this mode.
- Disconnect and power down to a lower-power deep sleep. A coin cell battery can last 3–5 years in this mode.
I chose the 1 year option. Interestingly, if I had chosen the 3–5 year option, the quickest way of waking up and transmitting a button press to a phone uses a special advertisement packet that can take up to 4 seconds to send and be read. These numbers are adjustable and there are certainly graphs you could draw, but I found the tradeoff to be worthwhile by staying connected and being limited to 12 months of battery life.
Considerations for low power
From the datasheet we see that the low power mode works best with a 32.768 kHz external crystal oscillator with 9 pF load capacitance and a ±20 ppm frequency tolerance. This Nordic Semiconductor support thread on minimizing current consumption has the details, and this thread can help you determine the crystal specs.
Considerations for buttons
Apart from the external crystal used for low power, the only other peripheral we have on the microcontroller are the four buttons. These are internal pull-up GPIO pins with interrupts. This means that when the button is pressed in, the module is running at full power. One optimization to make would be to go back to sleep, but that would require external pull-up resistors, 1 per button, for a total of 4 more resistors on the board.
Follow the rules and you get the schematic drawing above. I used EAGLE. Next time I would use KiCAD, if only because with open source EDA software it becomes easy to share the schematic and board layout with consultants and online forums for debugging and optimization.
You can download the board layout on Github.
Here’s where we get our first intersectional consideration. Before we were just thinking about what happens to the performance of the remote based on decisions made about the firmware and microcontroller. But the shape of the circuit board needs to know what the rest of the remote looks like.
The way I attacked this problem was to declare the minimum size for the circuit board and battery. A geometric symmetry is desired, but for the battery holder and the bluetooth module to fit, they had to be rotated 45°. From that requirement, tracks were routed around the five mounting holes. Two of the mounting holes are nudged a bit apart (the two in the top right) so that the board cannot be inserted upside down or in any other orientation on the same mounting pins.
The 8 magnets that hold the remote together look like they have bitten the PCB on all four sides. The reason for those divets is that the buttons themselves only take up so much space, considering their size is dictated not by electronics but by design. But the PCB is bigger than the button size as a matter of fitting both the battery holder and the bluetooth module. So we can cut into the board a bit with the magnets and just route the tracks around them.
Metal dome tactile button sticker array
Buttons come in many shapes and sizes to satisfy different requirements. I spent a lot of time looking at buttons that were industrial sized and could take pinball machine levels of abuse. Finding a way to press down and make contact was not trivial. Getting to “metal dome array” took a long, long time.
The requirement for the remote was to have a low profile (short) button, but all of the mechanics of off the shelf buttons have a vertical profile of nearly a centimeter.
You can find surface mount tactile switches for $0.20 on Digikey. The E-Switch is one example. There are two reasons I did not choose to use this, one pragmatic and one aesthetic.
Practically speaking, if you have surface mount components on two sides of a board, you just doubled your PCBA (PCB assembly) costs, since the board house has to solder one side at a time, holding one of the sides down in order to solder the other side. It’s time consuming and costly, and if you can get away with a single-sided board, you should.
Aesthetically speaking, there’s this phenomenom I like to call “accidental swastika”.
By using a sticker dome array, we save money on PCBA but instead have to adhere the dome array during the full box build assembly process later on. Aligning a sticker array takes far less time, and we have the ability to choose between different click feels, pressures, and click sounds with tactile metal domes.
Snaptron M-Series metal domes were the first dome I tried. It was magical. All I had to do was design the board layout with two concentric rings, add a via in the center as an escape for air, and tape the metal dome down.
Ordering a metal dome array was easy. I just had to upload my gerber CAM files from EAGLE and send it off to CMD. $100 later I had 100 metal dome arrays with 400 individual buttons. Peeling them off and sticking them in the right spot is quick and accurate.
We now have a functional circuit board with a long-lived battery running Bluetooth. It’s now time to design the remote enclosure.
This is part one of a four part series on everything you need to build your own Turn Touch smart remote.
If you want to get your own, Turn Touch is on Kickstarter.