June 2, 2026
Description
This project is a standalone, battery-powered Event Counter and Logger built around an ESP32. It is designed to track manual inputs—such as visitor numbers or recurring events—with high precision and reliability.
Turn-On Process: The logger shows the total number of presses on start up. After it scraped the local time shown by the blinking LED, it shows the daily number of presses.
Time Synchronization: On startup, the device connects to WiFi to synchronize with an NTP time server. If no network is available, it features an Offline Date Editor to set the time manually via the integrated button and LED display.
Data Logging: Every button press is saved to a microSD card in a .csv format, including a precise timestamp (Date;Time;Total Count).
Intuitive UI: A 7-segment LED display (MAX7219) shows the current count. The system uses the OneButton library to support different inputs:
Single Click: Increment counter and log data.
Long Press: Decrement counter and remove the last entry from the SD card (error correction).
Double Click: Used within the offline menu for faster value adjustment.
Power Management: Optimized for battery use with a compact 3D-printed enclosure, integrated charging circuitry, and status LEDs for visual feedback.
This logger is perfect for anyone needing a portable, "set-and-forget" device for data collection in environments without permanent computer access.
Design in Fritizing with a two layer approach to manufacture the PCB in a local Makerspace on a Fiber-Laser.
The finished PCB after manufacturing it with three different types of lasers (C02, Fiber, Diode). The starting point was a clean copper plate. The CO2-Laser was used to cut the outline of the PCB with an increased size of 10%. The boards get really burned while using the CO2-Laser. So I can grind the boards clean. Afterward I used the fiber-Laser to remove all the unwanted copper besides the traces and the writing. This process takes a lot of time because the fiber-Laser can remove the copper, but only a little. If the power is too high the fiber glass beneath the copper gets burned. After this PCB got sprayed with a cut of acrylic paint. After drying the diode laser is used to remove the paint from the pads. The diode laser can remove the paint but not the copper, so only the paint on the pads get remove. The last step is to drill the four holes in the corners. The picture shows the PCB
Use tree support to print the buttom- and top-cover. Be careful while removing the tree support from the bottom cover at USB-C port location.
The marked parts in the bottom right corner are the battery indication translucent parts to see the battery status. Print them in a different Material or color than the shown material that was used for the main case.
I liked the idea to have a central PCB with an external Battery management system and not directly connecting the battery to the PCB of the microcontroller.
The first step is the mounting of the M3 nuts inside the case. Two nuts are mounted in the top cover and one is directly mounted below the USB-C port. The bottom nut is a little bit hard to push in. My tip is to put the nut in and use a long screw to pull the nut in its desired position. Afterward you can unscrew the long screw and use a shorter one.
Assemble the battery management system (BMS) with the battery and the switch. The switch is secured with two M2 screws that are directly screwed into the plastic. The battery is simply secured with a strip of isolation tape. The USB-C Port cable is pushed through the open slit and pushed into place the outer case will make sure that it will stay in place. After the BMS is assembled check for the full functionality and connect the battery. If all for LEDs light up everything should work fine.
On the top case push the LED 7-Segment Matrix through the rectangular hole. Afterward put the big button without the electronics into the round hole. Then use the mechanism on the button to push it into the button case.
Secure the SD-card module with two M2 screws on the right side, connect all the necessary components with the JST-connectors and put the PCB at its designated place. You have to insert M2 nuts from the other side to mount the PCB. At least connect power to the PCB.
Close the mechanism with three M3 tapered screws from the outside. They screw into the previously inserted nuts.
Both the flowchart for the setup() and loop() function are shown below. On start up you can Long press the button to open up the WiFiManger Portal to log in with your Wi-Fi credentials. After this process the device uses the Long press to remove a value from the count. A short press will increase the number. If you are totally not able to connect to a Wi-Fi network you can use the offline editor which lets you edit the date and time from the last data point saved on the micro SD card.
You can find more information for the code on the GitHub page here.
To make the logged data actually useful, I built an Excel workbook that turns the raw CSV into something you can read at a glance. Just paste each row from log.csv into the RawData sheet, the rest fills itself in automatically.
The workbook contains four analysis sheets:
Heatmap Day x Time - every day on one row, split into 48 half-hour slots, with a colour scale that immediately shows when things happen.
Daily Summary - one row per day with the total count, the weekday, and the first and last event of that day.
Time-of-Day Distribution - all events aggregated into half-hour bins across 24 hours, including the percentage share. Useful to spot the busy times-of-day across your whole dataset.
Weekday x Time - the same Day x Time grid, but aggregated by weekday. Good for spotting weekly patterns (e.g. quiet Mondays, busy Friday afternoons).
Everything runs on COUNTIFS and SUMPRODUCT against the RawData table, so as long as you append new rows at the bottom, all sheets update on their own. I kept the labelling generic ("Event" instead of "Visitor"), so the same file works whether you are counting visitors, button presses on a different project, defects on a production line, or anything else.
You can get the Excel-File on the GitHub page here. (Printables doesn't allow .xlsx files :( )
In the beginning while making this device I thought I could finish the project in a week or two but in the end this project took around three months. Not constantly working on it but as a side project. I took much longer as expected to program a working Wi-Fi connection with my university Wi-Fi. But in the end it worked. I learned a lot of fast production for PCB and using a Fiber-Laser.
License:
Creative Commons — Attribution — Noncommercial — Share Alike