The purpose of this project is to develop hardware and microcontroller firmware to synchronize time with multiple clocks in the household. It also can be used for setting time on a carry-on device. Usually, buttons are used for this in conventional clocks. However, in many cases the button interface becomes very inconvenient. Clocks manufactured by various vendors differ in the user interface and assume different button press combinations for setting time/alarm time. Moreover, buttons have limited lifetime in terms of number of presses and might stop responding to user presses or make those presses unreliable. This is particularly true for clocks operated by multiple users, e.g., alarm clocks in hotels.
Using a contactless synchronizer simplifies the process of updating digital clock time while also being much more accurate and in most cases requires no interaction with users. Many commercial products are equipped with automatic time setup by using different wireless approaches. Thus, some wall clocks have a built-in radio receiver that receives time information from National Institute of Standards and Technology (NIST) radio station via WWVB interface [1]. This station is in Colorado and its signals can be received virtually in most places in the USA. However, this is only true for optimal clock antenna orientation, and the signal reception is influenced by the daytime (better propagation is at night) and time of the year. In several cases like presence of nearby factories or devices that generate a lot of electromagnetic disturbance at the WWVB frequency or if the clock is operated in a basement no WWVB reception is to be possible.
Another common approach is to utilize Internet Wi-Fi connection for getting time from one of NTP (Network Time Protocol) servers. This is how the clocks in any computer get their actual time. However, this approach is well suited for devices that have reasonable power sources such as wall adapters or decent lithium batteries. Wi-Fi is intended for transmitting massive amounts of data at a high speed. This makes power requirements for Wi-Fi modules way higher than, say, a single cell battery can deliver. Power requirements for Bluetooth devices are 10 to 30 times lower compared to Wi-Fi, but there is no common time source to get time from.
In our design we eliminate the limiting factor of both approaches. The synchronizer of our system is powered by a wall adapter and implements both Bluetooth and Wi-Fi interfaces. It has an internal reference clock, which is periodically synchronized with an external NTP server via Wi-Fi interface. The synchronizer then uses its reference clock to synchronize multiple external digital clocks upon their request that can occur at any time of the day via Bluetooth interface. External clocks send such requests periodically to the synchronizer and display current time on the display, resulting in accurate time. The synchronizer requires only a one-time setup to connect to the household Wi-Fi AP (Access Point) and subsequently works automatically from then. In our approach digital clocks do not need to have any buttons at all. Once the battery is inserted, the clock looks up for the synchronizer and loads time from it and automatically updates it afterwards. Alternatively, clock time can be synchronized with a smart device (e.g., smartphone) by using a special app. This app looks for Bluetooth devices whose name starts with “Clock.” Upon finding an appropriate device, the app connects to it and uploads time. A special user-friendly interface is used for setting alarm times, if needed. This way setting external clock time only requires launch of the Bluetooth app which is done with a single icon click. Here we only describe the first approach based on a special wireless synchronizer.
The synchronizer prototype is based on the BGM22 Bluetooth microcontroller module from Silicon Labs and the WizFi360 Wi-Fi module manufactured by WIZnet. These modules were chosen because of their flexibility. The modules are powered from a 3.3V regulator presented on the BGM22 board. The BGM22 is the master device and issues all commands to the WizFI360 via UART interface at 115200 bd speed.
The WizFi360 module is assembled on a self-etched Printed Circuit Board (PCB, on right) which plugs into the mikroBUS socket on the BGM22 board (on left). The transmission power of the BGM22 Bluetooth module is set +8 dBm and the one for the Wi-Fi module is at least +12 dBm. This establishes sufficient working range for a connection to Wi-Fi AP and synchronizes all clocks within any apartment and in most households.
Schematic | Assembly | |
While our goal was to design a system that requires no user interaction, on this prototype we utilize two buttons, which are mostly used during debugging. Pressing the RST button forces reconnection to the Wi-Fi AP, and every press of BTN0 forces the board to connect to an NTP server and reload time into its reference clock. Frequency of this clock is stabilized by a watch crystal, which makes timekeeping accurate within 1-2 seconds per day, so synchronization with NTP servers can be very rare. Since both modules are within the 2.4 GHz band, to exclude interference between each other and improve their co-existence, the Wi-Fi module is disabled between synchronization periods with NTP servers, and the Bluetooth module is disabled whenever the Wi-Fi module is active. Therefore, the Wi-Fi module is active for about 5 seconds per day during the time synchronization, which makes overall power consumption low. The Bluetooth module draws about 10 mA in receiving mode.
The digital clock is based on another BGM22 development board fulfilling the same role as the synchronizer, and the SSD1306 display from Solomon Systech Ltd mounted on a self-etched PCB. The SSD1360 is a 128x64 dot matrix OLED, panel which receives its commands from the BGM22 via the I2C interface to display current time and the die temperature of the module processor. Resistors R1 and R2 are the I2C pull-up resistors.
The display module also plugs into the mikroBUS socket on the Bluetooth module. Like the synchronizer module, the clock frequency on this device is stabilized by a watch crystal which makes it unnecessary to synchronize time more often than once per day. To provide a possibility for multiple clocks to be synchronized by the same synchronizer, the clock expects data within 30 seconds after synchronization request. Moreover, there is some randomization of the sync period at every clock unit. The synchronizer in our design is capable of communicating with only one digital clock at a time. Synchronization of the external Bluetooth clock takes no longer than 1 second.
Schematic | Assembly | |
Outside of time synchronization periods, the Bluetooth part of the module is disabled. This reduces the power consumption and amount of unnecessary wireless radiation. This way the clock draws about 5 mA, which is mostly due to the always ON display module. Again, for testing purposes, every press of the BTN0 button forces a synchronization request to be sent by the clock to the synchronizer. This way the Bluetooth module activates and works as a server waiting for clients (synchronizer or smartphone app) to connect and load time. Assembled versions of synchronizer and digital clock prototypes are shown below. The temperature is displayed in Celsius, and the time is displayed in hh:mm military format.
Therefore, the prototyping hardware with extension boards mounted on the Bluetooth module boards looks as follows:
Hardware |
All microcontroller firmware is written in C programming language and developed in the Silicon Labs Simplicity Studio IDE. The programs are coded to allow the on-board microcontroller to control the Wi-Fi/Bluetooth/OLED module, verify accurate operation, transfer data, and control steps to ensure proper activations, deactivations, and timing of hardware systems for preventing errors. The microcontroller on each board has ARM Cortex-M33 architecture and is clocked at 38.4 MHz frequency, see details in [4]. The synchronizer program is coded to use the onboard low energy timer after receiving time via Wi-Fi update to allow synchronization with multiple digital clocks that may request time. Interface with the WizFi360 module is provided by an AT commands interpreter built into the module. To utilize the functions and understand how and what these AT commands do it is important to refer to WIZ5net's "AT Command Comparison Sheet", "AT Instruction Set", and "AT command examples" manuals. These manuals are essential in programming the firmware and can be found on WIZner.io in the WizFi360 module overview section [3]. Along with the AT manuals, WIZnet also has a datasheet which contains a pin diagram, which is used to configure the pin functions.
Silicon Labs documents [5] and [6] are used to understand the basics of how Bluetooth transfers and receives data and how to use its API commands to control the Bluetooth functionality. One of the most important concepts in Bluetooth development is Generic Attribute Profile (GATT) which is implemented as the GATT client and GATT server. Understanding and implementing these concepts allows for proper communication between the synchronizer and the digital clocks. Bluetooth focuses on using low energy when communicating, but even so, the firmware contains coding on both devices that further saves energy through sleep functions.
The prototype described above projects led to turning them into real devices. The synchronizer is assembled on top of a wall adapter by using WizFi360 and BGM220 modules mounted on self-etched PCBs. The PCBs are assembled on top of each other in a sandwich-like design.
Side view | Front view | |
There are two household Bluetooth digital clocks controlled by them. Each is powered from a single AAA cell. To save power we replaced the OLED display with LCD, which consumes significantly less power and can work without background light. This, however, requires the use of a special LCD driver PCA8561 to control them. The background light turns on for about 4 seconds after tapping a surface which the clock stands on. Single tap detection is provided by the LIS2DW12 accelerometer, which is mounted on the clock’s PCB. This way a single cell capacity is sufficient to power the clock for more than a year, depending on how often the background light turns on. Using background light for reading time is basically needed at dark time or night hours only.
Clock 1 | Clock 2 | |
Developing this project allowed me to learn how to utilize and program with Bluetooth and Wi-Fi while expanding on my experience with microcontrollers and their low power consumption capabilities during application. Programming the hardware utilizing Bluetooth and Wi-Fi helped me learn how to interpret and utilize the protocol data packets that are essential and different in each form of wireless communication. I also learned the importance of programming the microcontroller to perform a sequence of events in a manner that optimizes power consumption while preventing possible errors.
Utilizing Bluetooth for communication consumes low energy as opposed to other forms of communication like Wi-Fi. Using Wi-Fi from only one source, in this case the synchronizer, consumes 10 times less energy for each digital clock that is synchronized. Using the synchronizer's onboard timer, updates to the clocks can be achieved while limiting the intervals of the Wi-Fi module's usage to further lower the consumption of power. This application of Bluetooth communication as a synchronizer as opposed to each device containing its own Wi-Fi connection could be a great way to further lower the power consumption of other forms of "Smart" devices. In a world where we are learning and advancing to further reduce consumption of resources, the ability to receive and transmit data can serve to assist in this reduction of energy consumption as "Smart" technology continues to become a bigger part of the many developing home appliances and devices.