Foriq: Counting machine strokes without touching the control system
How Foriq detects the strokes of presses and hammers from the outside, how the system is built and why we are publishing it as an open-source project.

How long a machine needs for an order depends largely on the output it actually achieves in everyday operation. These cycle rates feed into quotations, delivery dates and post-calculations. The more precisely they are known, the more reliably they can be used for planning.
For a long time, our presses ran without automatic output recording. Daily and monthly output, cycle rates and downtimes were therefore not continuously visible in one place. An obvious solution would be a connection to each machine's control system. In a machine park that has grown over the years, however, this connection looks different on every machine, and older machines often have no suitable interface at all. The effort therefore grows with every additional machine.
Foriq grew out of this situation: a system that records a machine's strokes from the outside without intervening in its control system. It now counts in our forge every day. With this article, we are publishing Foriq as an open-source project.
Measuring from the outside
Every stroke of a press or hammer briefly sets the machine body in motion. This motion can be measured with an acceleration sensor attached to the outside of the machine, for example with a magnetic holder, an adhesive pad or a cable tie. No electrical connection to the machine is required; the sensor only needs a USB-C power supply.
The sensor measures acceleration in three directions and calculates its magnitude . At rest, this magnitude equals gravitational acceleration, i.e. , regardless of the orientation in which the sensor is mounted. Detection therefore only looks at the deviation from this resting value and combines it over a short, sliding time window :
The value describes how strongly the machine is vibrating at that moment. If it rises above a threshold, a stroke begins. It is counted as soon as the vibration has dropped below the threshold again and a minimum time has passed since its peak. Any after-vibration within this time therefore still belongs to the same stroke and is not counted twice.
Two values can be set for each machine. The stroke period indicates the approximate interval between strokes; the window length and minimum time are derived from it. The sensitivity determines how strong a deflection must be to count as a stroke. A fast eccentric press therefore needs different settings from a slow hydraulic press with a soft touchdown.
Earlier versions of Foriq used a trained model for detection. Today's detection is deliberately kept simpler. Its behaviour can be described and understood with two values, and every deviation can be traced back to one of these values or to the mounting position. For a project that other companies are meant to run and adapt themselves, we consider this transparency more important than additional complexity.
From the sensor to the browser
Detection runs entirely on the sensor. Instead of raw data, it therefore transmits the detected strokes with a time stamp and a few parameters such as the strength of the deflection. The sensor sends them via Wi-Fi to a server on the company's own network. If the Wi-Fi is briefly unavailable, it buffers the strokes and transmits them later.
A Mac serves as the server. A desktop app starts and monitors the database and server there and sets up new sensors via USB. The user interface itself runs in the browser and can be reached from any computer on the network. It shows the output and cycle rate of each machine live, arranges the machines on a shop-floor plan, reports downtimes or failed sensors and displays the history over hours, shifts and days. The data can be exported as Excel or CSV and used in existing evaluations.
No internet connection is required. Sensors, server and browser communicate exclusively within the company's own network, and the data does not leave the company.
Why open source
We originally offered Foriq as a cloud platform with an annual licence. Such a service, however, permanently requires operating servers, providing customer support and taking responsibility for other companies' production data. For a drop forge, that is a separate line of business with little in common with our actual work. At the same time, production data is sensitive for many companies, so storage outside their own premises is often an objection to using such a system in the first place.
Publishing Foriq as an open-source project shifts this balance. Foriq runs entirely locally, which removes the objection to external data storage. Companies can use the system without licence fees, review the source code and adapt it to their own requirements. For our forge, the benefit of the project therefore lies not in selling software but in using it ourselves and in exchanging ideas with other companies facing similar questions.
Foriq is licensed under the AGPL-3.0. It permits use, modification and distribution. Anyone who passes on a modified version to others or makes it available to others over a network must, however, disclose its source code under the same licence. Improvements thus remain accessible to all users.
Adapting it with a coding agent
Every machine vibrates differently. Beyond that, the question of what should be counted at all also depends on the process. On a forging hammer, for example, several blows often fall on one part, so a detected stroke cannot be equated with a finished part. In other cases, a machine also counts while idling, or an ejector produces a second deflection.
For such adaptations, the project contains instructions for coding agents such as Claude Code or Codex. Such an agent is started in the project folder, and the machine is described to it in your own words, for example: "The forging hammer strikes three blows per part. I want to count parts, not blows." The instructions specify the order in which the agent proceeds. It first clarifies the machine type, cycle rate, idling and any reference counters. It then tries to solve the problem using the stroke period and sensitivity alone and checks the settings against the strokes already stored. Only if it turns out that no setting is sufficient does it change the detection itself.
A second set of instructions describes how the firmware can be ported to a different ESP32 microcontroller or a different acceleration sensor. A single command then builds the adapted app and firmware and installs them on the Mac; the sensors receive the new firmware over the network.
Requirements and limitations
The reference hardware is the M5Stack StickS3, a commercially available stick with an ESP32-S3 and an acceleration sensor on which Foriq runs without modification. Each machine needs one stick and one USB-C power supply; in addition, a Wi-Fi network in the 2.4 GHz band and a Mac with Apple silicon and macOS 13 or later as the server are required. Windows and Linux are not currently supported.
The app is not notarized by Apple. Installation is therefore done with a command in the terminal that checks the checksum of the download. The installation script can be reviewed in the repository beforehand. Questions and bug reports are collected via GitHub; we do not offer a support contract.
Measuring from the outside is a deliberate compromise. It makes installation simple and independent of the respective control system. In return, the count depends on the mounting position and the surroundings, for example when neighbouring machines also cause the sensor to vibrate. After setup, the count should therefore be compared once with a reference and readjusted if necessary.
Getting started
For companies with a machine park that has grown over the years, Foriq can be a simple way to start evaluating their own production. One sensor per machine and a Mac on the network are enough to make output, cycle rates and downtimes continuously visible. If you would rather not build the sensor yourself, you can obtain it from us on request, ready-assembled in a robust housing with a magnetic holder.
Installation, documentation and source code are available at foriq.de and at github.com/sschaefer-esn/foriq.
