Hourglasses are very impressive devices, especially when you consider how mechanically-simple they are. It isn’t known when the first hourglass was produced, but the first recorded example was constructed in the 8th century CE. That was an era when most people couldn’t measure time anymore accurately than by the general position of the sun. It was quite the feat to be able to calibrate an hourglass to measure the passage time by the trickle of sand. Simulating that digitally is also difficult, but that’s exactly what Mike Szczys, editor-in-chief of Hackaday, has done with Sand-ular Automata.
Szczys built this digital hourglass for the 2019 OSH Park Bring-a-Hack event using mostly parts he already had laying around. Those include a 128x64 OLED display salvaged from a KiCon badge and an ESP32 development board. The only component that Szczys purchased was the IMU (Inertial Measurement Unit), which is a 16-bit MPU-6050 gyroscope and accelerometer. As Szczys points out, that module is overkill when it’s just being used to detect how far the digital hourglass has been tipped, but it was the cheapest module he could find with a quick delivery time.
What makes this digital hourglass particularly interesting is how Szczys programmed the “physics” of the sand falling. Technically, there aren’t any physics involved — at least not in the traditional sense. Instead, Szczys used a model inspired by cellular automata. In cellular automata simulations, a grid of cells are given operating parameters. Each cell affects it neighbor and the array evolves over time. Szczys used a similar set of rules, but the rules affecting those cells are gravity and open space. If there is no sand particle or glass in the way, a individual cell will fall with gravity into the next available open spot in the array. If there is something in the way, it will stop until room is available. In that way, it acts remarkably similar to a real hourglass.