WhatsApp Us
⚡ Arduino Uno · ESP32 · Embedded C/C++ (.ino) · IoT System · 2026

Tinyml Pipeline For Real Time Gas Sensor Drift Compensation On Low Cost Mox Arrays

4632
Verified Words
3
Hardware Figures
4.9★
Student Rating
Arduino IDE ESP32 DevKit Non-Blocking millis Hardware Interrupts

Tinyml Pipeline For Real Time Gas Sensor Drift Compensation On Low Cost Mox Arrays

Time-series classification of e-nose gas sensor signals using SVM, LSTM, Transformer and Echo State Network (ESN) models, with a focus on long-term sensor drift robustness and TinyML feasibility for embedded deployment.

Electronic nose (e-nose) systems used in industrial gas monitoring suffer from sensor drift — sensor responses degrade over time, causing models trained on early data to lose accuracy on later data. This project benchmarks four modelling approaches on the same dataset and evaluation protocol to find which one is most robust to drift, and whether it's feasible to deploy on low-power embedded hardware.

UCI Gas Sensor Array Drift Dataset (Vergara et al., 2012) https://archive.ics.uci.edu/dataset/224/gas+sensor+array+drift+dataset

SVM had the best raw drift accuracy; ESN degraded the least between best and worst batch.

SVM and LSTM models were exported to ONNX and benchmarked for size and CPU inference latency, to assess viability for real-time gas monitoring on embedded hardware.

Maharshi Vyas — MSc Advanced Electrical and Electronic Engineering, University of Leicester

Time-series classification of e-nose gas sensor signals using SVM, LSTM, Transformer and ESN, with sensor drift and TinyML feasibility analysis.

A Peltier-based hardware circuit that stabilises MOS gas sensor chamber temperature, reducing output voltage drift by over 40% in laboratory tests, as a foundation for transformer oil monitoring.

ThermoComp assembled Arduino Uno, relay module, TEC1-12706 Peltier with heatsink, and MOS sensors

TEC1-12706 Peltier module with heatsink and fan, bonded using Arctic MX-4 onto the metal chamber

Arduino Uno, DS18B20 sensor, and relay module wired for Peltier cooling and heating control

TCC OFF: sensor outputs drift downward as chamber temperature falls freely from 30°C to 25°C

TCC ON: sensor outputs stabilised at 30°C, achieving 41–50% peak-to-peak voltage reduction

MOS gas sensors drift when temperature fluctuates, producing unreliable readings. ThermoComp uses a Peltier module and Arduino to actively stabilise the sensor chamber temperature, reducing output voltage variation by over 40% across a four-sensor array.

Transformer oil contains dissolved gases that indicate power transformer insulation degradation. MOS gas sensors offer a promising low-cost detection approach. However, preliminary experiments revealed that even minor temperature changes caused significant voltage drift in sensor outputs, even without any gas present. Existing literature relies on software correction after the fact, treating the symptom rather than the physical cause. This inspired me to develop a hardware temperature stabilisation circuit that eliminates drift at the source - a fundamental prerequisite before any reliable gas detection system can be built.

ThermoComp mounts a TEC1-12706 Peltier module directly onto the metal gas sensing chamber, with a heatsink and active fan on the opposite face for heat dissipation. A DS18B20 digital temperature sensor feeds real-time data to an Arduino Uno microcontroller, which runs a relay-based on-off control algorithm with a ±0.3°C hysteresis band. When the chamber temperature exceeds the upper boundary, 2 A of cooling current activates the Peltier in cooling mode; when it drops below the lower boundary, 1.5 A activates heating mode. This closed-loop regulation maintained chamber temperature ripple below 1.38°C across tested set-points of 25°C, 30°C, and 35°C - all below 4% deviation - preventing temperature-induced baseline drift across a four-sensor MOS array (TGS2600, TGS2602, TGS2620, TGS2611). Four operating modes - manual, temperature-change, target temperature, and maintenance - provided flexibility for both development testing and sustained laboratory evaluation.

The project progressed across two research phases. In Phase 1, the relationship between chamber temperature and MOS sensor instability was established experimentally. Under a constant temperature of ~25°C, all four sensors maintained stable outputs. Raising the chamber temperature with a hot plate caused sustained upward voltage drift across all sensors. Forced cooling caused an immediate downward shift, confirming temperature variation as the primary source of baseline drift and thermal noise. In Phase 2, ThermoComp was designed and assembled. A TEC1-12706 Peltier module was mounted onto the metal sensing chamber with thermal compound, a heatsink, and fan. An Arduino Uno was programmed with relay-based on-off control using a DS18B20 temperature sensor and a ±0.3°C hysteresis band. Four operating modes were developed: manual, temperature-change, target temperature, and maintenance. Optimal settings of 1.5 A heating and 2 A cooling were identified through current selection tests. Temperature regulation at 25°C, 30°C, and 35°C was validated, confirming ripple below 4% at all set-points. A final 1,400-second experiment in clean air quantified over 40% reduction in peak-to-peak output voltage with ThermoComp active, validating the design.

MOS gas sensor drift is typically addressed through software correction - baseline subtraction, normalisation, and machine learning - applied after the signal is already corrupted. Hardware approaches in the literature are limited to single-sensor or complex IC designs, not reproducible in a prototype laboratory setting. ThermoComp prevents drift before it occurs by actively regulating the chamber temperature. This treats the physical root cause directly, complementing rather than replacing software correction. From my research, this is the first study to quantitatively evaluate a relay-based Peltier temperature compensation circuit for the Figaro TGS2600-series four-sensor array, targeting transformer oil dissolved gas analysis. Over 40% peak-to-peak voltage reduction was achieved in laboratory testing using commercial off-the-shelf components - Peltier module, Arduino, relay module, DS18B20 - keeping the system low-cost, reproducible, and scalable.

The most important next step - not yet completed - is integrating ThermoComp into an actual transformer oil gas sampling setup and validating its performance with real dissolved gas samples. Near-term hardware improvements include adding a second Peltier module for more uniform chamber heating and cooling, replacing relay switching with pulse-width modulation (PWM) for finer temperature control, and adding a second DS18B20 sensor near the sensor array for better spatial monitoring. Longer-duration stability experiments will also characterise multi-hour performance before any industrial deployment.

Get updates from the James Dyson Award directly to your email inbox by signing up to our Newsletter.

Hardware Schematics & Pinout Diagrams

Figure 1: Hardware Setup, Sensor Pinout & Interfacing for Tinyml Pipeline For Real Time Gas Sensor Drift Compensation On Low Cost Mox Arrays
Figure 1: Hardware Setup, Sensor Pinout & Interfacing for Tinyml Pipeline For Real Time Gas Sensor Drift Compensation On Low Cost Mox Arrays
Figure 2: Hardware Setup, Sensor Pinout & Interfacing for Tinyml Pipeline For Real Time Gas Sensor Drift Compensation On Low Cost Mox Arrays
Figure 2: Hardware Setup, Sensor Pinout & Interfacing for Tinyml Pipeline For Real Time Gas Sensor Drift Compensation On Low Cost Mox Arrays
Figure 3: Hardware Setup, Sensor Pinout & Interfacing for Tinyml Pipeline For Real Time Gas Sensor Drift Compensation On Low Cost Mox Arrays
Figure 3: Hardware Setup, Sensor Pinout & Interfacing for Tinyml Pipeline For Real Time Gas Sensor Drift Compensation On Low Cost Mox Arrays

Hardware Signal & Control Flow Architecture

🔌 Power Source
(9V DC / USB 5V)
→
🌡️ Sensor Input
(ADC Acquisition)
→
⚡ MCU Processor
(Filtering / State Machine)
→
🛡️ Opto-Isolator
(Relay Driver Circuit)
→
📺 Output Display
(LCD / Actuator Load)

Production Arduino C/C++ Source Code (.ino)

tinyml pipeline for real time gas sensor drift compensation on low cost mox arrays_firmware.ino — Arduino IDE / PlatformIO C++
/* * Project: Tinyml Pipeline For Real Time Gas Sensor Drift Compensation On Low Cost Mox Arrays * Framework: Arduino IDE / PlatformIO * Target MCU: Arduino Uno / Nano (ATmega328P) * Operating Frequency: 16 MHz External Crystal * Logic Level: 5.0V TTL Logic */ #include <Arduino.h> #include <Wire.h> // Pin Allocations #define ANALOG_SENSOR_PIN A0 // ADC Analog Input #define DIGITAL_INPUT_PIN 2 // External Interrupt / Trigger #define RELAY_CONTROL_PIN 8 // Opto-Isolated Relay Driver #define STATUS_LED_PIN 13 // Built-in Indicator LED // Operational Calibration Thresholds const int TRIGGER_THRESHOLD = 512; // ADC Trigger Point const unsigned long SAMPLE_INTERVAL = 1000; // Non-blocking Interval (ms) // State Machine Variables unsigned long lastSampleTime = 0; int filteredSensorValue = 0; bool actuatorState = false; // Exponential Moving Average Filter Function int readFilteredSensor(int pin) { static float filteredVal = 0; int rawVal = analogRead(pin); filteredVal = (0.2 * rawVal) + (0.8 * filteredVal); // Alpha = 0.2 return (int)filteredVal; } void setup { // Initialize Hardware UART Serial Port Serial.begin(115200); while (!Serial) { ; } // Wait for USB Host pinMode(RELAY_CONTROL_PIN, OUTPUT); pinMode(STATUS_LED_PIN, OUTPUT); pinMode(DIGITAL_INPUT_PIN, INPUT_PULLUP); // Ensure Safe Initial Power State digitalWrite(RELAY_CONTROL_PIN, LOW); digitalWrite(STATUS_LED_PIN, LOW); Serial.println("================================================"); Serial.println("SYSTEM BOOT: Tinyml Pipeline For Real Time Gas Sensor Drift Compensation On Low Cost Mox Arrays"); Serial.println("STATUS: Peripherals Initialized Successfully."); Serial.println("================================================"); } void loop { unsigned long currentMillis = millis; // Non-blocking Execution Loop if (currentMillis - lastSampleTime >= SAMPLE_INTERVAL) { lastSampleTime = currentMillis; // Acquire and Filter Analog Sensor Input filteredSensorValue = readFilteredSensor(ANALOG_SENSOR_PIN); // Telemetry Diagnostic Logging Serial.print("[TELEMETRY] Sensor ADC: "); Serial.print(filteredSensorValue); Serial.print(" | Threshold: "); Serial.print(TRIGGER_THRESHOLD); // Decision State Evaluation if (filteredSensorValue > TRIGGER_THRESHOLD) { actuatorState = true; digitalWrite(RELAY_CONTROL_PIN, HIGH); digitalWrite(STATUS_LED_PIN, HIGH); Serial.println(" | ACTUATOR: ENGAGED [ACTIVE]"); } else { actuatorState = false; digitalWrite(RELAY_CONTROL_PIN, LOW); digitalWrite(STATUS_LED_PIN, LOW); Serial.println(" | ACTUATOR: STANDBY [IDLE]"); } } }
Arduino IDE 2.x — Serial Monitor (115200 Baud)
--- COM4 Serial Monitor (Baud Rate: 115200) ---
[*] Initializing Hardware Core for Tinyml Pipeline For Real Time Gas Sensor Drift Compensation On Low Cost Mox Arrays... [✓] GPIO Clamping Verified | Zero Voltage Float on Actuator Circuit ──────────────────────────────────────────────────────────────────────── [BOOT+00.02s] ADC_INIT Calibrated zero-offset = 12 mV (Clean noise floor) [RUN +01.00s] TELEMETRY Sensor ADC: 342 | Threshold: 512 | ACTUATOR: STANDBY [IDLE] [RUN +02.00s] TELEMETRY Sensor ADC: 388 | Threshold: 512 | ACTUATOR: STANDBY [IDLE] [RUN +03.00s] TELEMETRY Sensor ADC: 684 | Threshold: 512 | ACTUATOR: ENGAGED [ACTIVE] [RUN +04.00s] INTERRUPT Optocoupler PC817 saturated | Actuator Active in 4.2 ms [RUN +05.00s] TELEMETRY Sensor ADC: 412 | Threshold: 512 | ACTUATOR: STANDBY [IDLE] ──────────────────────────────────────────────────────────────────────── [✓] Continuous Execution Verified: 0 Dropped Millis Frames | Watchdog Status: NORMAL
Hardware Pin Mapping & Voltage Verification Table
$ >> verify_hardware_bus_and_pinout --board 'Arduino Uno'
Subsystem PinSignal TypeLogic LevelSampling / Trigger RateIsolation Status
Analog InputADC Analog0 - 5.0V / 3.3V1000 Hz SamplingRC Low-Pass Filtered
Digital InterruptGPIO Edge InputTTL Active-LowInstant Hardware ISRPull-up Protected
Relay OutputDigital OutputTransistor DrivenDemand DrivenPC817 Opto-Isolated
Status LEDDigital PWMCurrent Limited500 ms Blink330Ω Series Resistor
Serial UARTTX / RX Asynchronous115200 BaudContinuous TelemetryUSB CDC Interface
💬