A device for counting razor blade uses

A device for counting razor blade uses

A gentleman desires to keep modern technology out of his bathroom. Thus I prefer to keep my chin clean with a battle-tested open-comb Mühle razor instead of one of those multi-bladed cartridge abominations. As a man enjoying sharp blades while being particular about spending my hard-earned cents, I recently made an exception to the “no modern technology” rule. I designed a “handy” device that counts the number of times I’ve shaved since last changing the blade.

The front of a device for counting razor blade uses, with razor and brush on topThe back of a device for counting razor blade uses, displaying its components

It simply consists of an Arduino microcontroller hooked to a load cell via XH-711 ADC and uses a single LED as an output device. After removing the brush and the razor from the stand, the device increases an internal counter and blinks to signal the current value. When the counter reaches six (my preferred number of shaves per blade), it resets as it’s scantly intelligent enough to know that I will change the blade at that point. And then it repeats until eventually running out of battery.

It comes enclosed in a beautiful wooden housing. The choice was practical since I happened to have leftover wood from another project. The material may or may not be optimal for the bathroom environment, but more about that later.

The design

The schematics are very simple since I only needed

It was easy enough to figure out how that goes to a Veroboard, and fit it into wooden housing built by gluing together some 95mm planks.

I wanted to use XH connectors to connect the load cell to the main board. It was my first time using an XH crimp tool, and oh boy, I used it a lot before finally succeeding. After wasting about 100 crimp terminals to connect the load cell, I opted for a screw terminal for the battery housing.

Most tutorials on Arduino and XH-711 instruct to use the 5 V regulated power supply on the Arduino board to run the ADC. I opted to use a 3.3 V board and found out it works in practice. Perhaps I lost some measurement accuracy, but the purpose of the load cell for this project was to make the binary choice of whether the razor was sitting on the scale.

The software

The source code is available on GitHub. I hard-coded the calibration parameters, so the values are not directly usable in another device.

Since I designed for low power usage, I’d like to draw attention to two details:

  • The delay() function found in the Arduino standard library does busy waiting. To actually sleep between polling XH-711, I used the Low-Power library. It exposes a simple interface to deep sleeping.
  • XH-711 also has a low-power mode, so I utilized it while the Arduino board was sleeping. After being woken up, XH-711 needs some time before it is ready again. The popular XH711 library has the wait() function to wait for that to happen. The problem is that it’s again busy waiting, so I opted to attach an interrupt handler to the DOUT pin and sleep until the measurement became available. There are alternative interrupt-driven XH711 libraries for Arduino, but I found this the simplest solution.

Some more energy-saving tips

By using the 3.3 V Arduino board (instead of the traditional 5 V board) and paying attention to software design, I achieved six-week battery life using 3 AAA batteries with 1000 mAh capacity.

The next step on the road to more battery life would have been removing the power LED from the Arduino Pro Mini board. I didn’t yet do that, but I might do it later when growing tired of recharging the batteries.

What could be improved?

Unsurprisingly the wooden housing is not very good for the bathroom. After a few months, the bottom (the most likely part to be in direct contact with water left on the bathroom table) started to swell. If I ever make v2 of the device, the first thing would be to learn 3D printing and design a proper plastic housing for the board. Who knows, I might throw in a charger with a LiPo battery while I’m at it.

The current software keeps the counter in memory, which makes it reset when the device runs out of battery. While I could use the built-in EEPROM to store the counter in non-volatile memory, it would be even more interesting to convert this into a proper IoT device. By implementing the MQTT protocol, I could hook the shaving counter to my home automation, and be notified when its time to change the blade. I could also implement a protocol for calibrating the load cell via MQTT.

I hope this article gave some insights into designing a simple microcontroller project from start to finish. I had a lot of fun with it, and will surely have even more when implementing the improved version!