My laser cut binary clock, Wooden Bits, originally had no means to set the clock, other than at compile time. I later added a tactile button and ISR to provide this function (increment the time until the correct time is shown) but I wanted a way to tap into the extra features of the DS3231 (alarm, temperature) and also to experiment in wireless control.
First I tried a Bluetooth LE module that provided a UART link over BLE. Implementing this was as simple as adding a data callback function with command interpreter. I used the first char as a setting type ID (‘s’ set, ‘t’, temp, ‘a’ alarm, ‘c’ colour), followed by the data to set. For example, to set the time to 09:34, one would send ‘s0934’. I also added visual feedback upon receipt of these commands.
To test the implementation, I used the Nordic BLE UART iOS app, which allows connection to a Nordic chip and a terminal to send/receive commands. In the long term I would design an app with GUI, which would invoke the serial commands behind the scenes.
Second I wanted to use an ESP8266 I had ordered a while ago with all the hype surrounding it. For the uninitiated, it’s a < £4 SoC with WiFi that provides wireless access to a microcontroller via serial in its most basic form. It is based around a 32-bit microcontroller with spare GPIO too, so can form projects on its own. For this project, I hooked it up to the serial of the Arduino.
Set-up as an access point, one can connect to the device and send HTTP get requests. These requests can then be read from the chip with the Arduino serial link, and the buffered data processed and acted upon. Similar to the BLE UART but with a bit more data handling due to the included HTTP header information and interfacing with the chip.
The result is the same as using the BLE solution but the webpage makes it instantly cross-compatible. Here’s a video demonstrating both methods:
My initial experiences with both is that the BLE is much more reliable – it works 100% of the time – but is considerably more expensive.
The ESP8266 solution doesn’t always seem to receive the requests. I have ideas as to why this might be but need to perform more debugging. This was due to using bit-banged serial rather than a hardware one – use a hardware serial and save software serial for debug.
I’ve branched the original code on GitHub for each solution: