In 2020 I built a digital glucose meter prototype: an Arduino, an INA219 current and voltage sensor on I²C, a 20×4 LCD also on I²C, and a few mechanical parts designed in CAD. The code is public on my GitHub. I describe it because, in a few hundred lines, it contains almost every problem of a real embedded system.
The principle is the one behind test strips: when the drop of blood reaches the strip, the reaction produces a small current whose size depends on the glucose concentration. The INA219 measures the voltage across a shunt, which is to say the current. To get more resolution on small currents I used the sensor's 16 V / 400 mA calibration instead of the default range.
The firmware is a state machine. First it detects that a strip has been inserted, from a shunt voltage that is very low but not zero, and asks on the display for blood to be applied. Then it waits for the reaction, finds the current peak and measures about 4.5 seconds after the peak, using millis() for timing. Finally it converts the reading to mg/dL with a calibration line, shows the result and waits.
Reading it again today, the code has the typical flaws of a prototype: the state machine is hidden in nested while loops, some thresholds are exact comparisons on analogue values, and the calibration's magic numbers are scattered through the code. Today I would write it with explicit states, a timeout on every wait, thresholds with hysteresis, and the calibration coefficients in one place, versioned and documented.
The most important lesson, though, is about calibration. A line fitted to a few reference measurements works for a demonstration, not for a person. Temperature, strip batch, haematocrit and reaction time all change the result. A real device needs reference samples, clinical validation and the certification required by the EU In Vitro Diagnostic Regulation (IVDR). This was a study prototype, not an instrument for measuring blood glucose.
Why write about it on a site about AI? Because the same discipline applies when you put an AI model on sensor data: knowing where every number comes from, how reliable it is, and what happens when it is wrong. That thread connects this prototype to the embedded and IoT projects I work on today.