Engine hour meter for pumps and tractors
Build it step by step
0 of 6 doneSet the buck module
Feed 12 V to the LM2596 and adjust to 5.0 V on a multimeter.
Wire the electronics
Fuse, LM2596, Nano, SW-420 and TM1637 as in the table.
Bench-test the sensor
Tap the SW-420 and watch the on-board LED and D2 change.
Fix it to the engine
Bolt the sensor to the engine body or pump frame with the electronics box on a stable, clean place.
Tune sensitivity
With the engine running, turn the trimmer until the sensor pulses often. When off, it must stay quiet.
Check the count
Run the engine for 15 minutes and see the total rise by a quarter hour once it reaches the save interval.
How do you build an engine hour meter for pumps and tractors?
A vibration sensor tells when a diesel pump or tractor is running and adds up engine hours for oil changes, stored safely in EEPROM. You need Arduino Nano, Vibration sensor module (SW-420), TM1637 4-digit display, LM2596 Buck Module, ABS project box (100 × 60 × 25 mm), Fuse 1 A glass (5 × 20 mm), Fuse holder (panel, 5 × 20 mm) and Jumper wires male to male (40 pcs, 20 cm). It takes 6 steps and about 90 minutes.
- Level
- Beginner
- Time
- About 90 min
- Parts
- 8
Wiring
| From | To | Why |
|---|---|---|
| 12 V battery + | 1 A fuse, then LM2596 IN+ | Fused supply |
| 12 V battery - | LM2596 IN- and ground | Ground |
| LM2596 OUT+ (set to 5.0 V first) | Nano 5V pin | Regulated supply |
| LM2596 OUT- | Nano GND | Ground |
| SW-420 VCC and GND | Nano 5V and GND | Sensor supply |
| SW-420 DO | Nano D2 | Vibration pulse output |
| TM1637 CLK and DIO | Nano D4 and D5 | Display |
| TM1637 VCC and GND | Nano 5V and GND | Display supply |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "TM1637" by Avishay Orpaz. The meter adds a minute only when the sensor changes state at least 20 times in that minute, so a bump does not count. Hours are saved every 10 minutes, so up to 10 minutes can be lost if power fails. Adjust the sensor's trimmer so a running engine triggers it and a still one does not. Set the LM2596 to exactly 5.0 V before connecting the Nano.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <TM1637Display.h>
#include <EEPROM.h>
TM1637Display display(4, 5);
const byte VIB = 2;
const int MIN_TRANSITIONS = 20; // changes per minute that count as running
const byte SAVE_EVERY_MIN = 10;
uint32_t totalMin = 0;
byte minsSinceSave = 0;
unsigned long minuteStart = 0;
int transitions = 0;
bool last = false;
void setup() {
pinMode(VIB, INPUT);
display.setBrightness(5);
EEPROM.get(0, totalMin);
if (totalMin == 0xFFFFFFFF) totalMin = 0; // blank EEPROM
minuteStart = millis();
}
void loop() {
bool now = digitalRead(VIB);
if (now != last) { transitions++; last = now; }
if (millis() - minuteStart >= 60000UL) {
minuteStart = millis();
if (transitions >= MIN_TRANSITIONS) { // the engine shook the sensor this minute
totalMin++;
if (++minsSinceSave >= SAVE_EVERY_MIN) { EEPROM.put(0, totalMin); minsSinceSave = 0; }
}
transitions = 0;
}
uint32_t hours = totalMin / 60;
bool serviceDue = (hours % 250) < 2 && hours >= 250;
if (serviceDue && (millis() / 500) % 2) display.clear(); // blink for 2 hours after each 250 h
else display.showNumberDec(hours % 10000);
delay(5);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Engine off | No change in the total |
| Engine running 15 min | Total increases by 15 minutes |
| Power cycle | Total restored from EEPROM |
| After 250 hours | Display blinks for two hours |
If it does not work
Counts while the engine is off
The sensor is too sensitive or on a shared bench. Lower the trimmer.
Does not count
The engine does not shake the sensor enough. Mount it on a rigid part nearer the engine.
Total resets to zero
EEPROM write failed or was never saved. Run for at least 10 minutes.
Nano resets when starting the engine
Add a 470 µF capacitor at the buck input.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the engine hour meter for pumps and tractors?
Arduino Nano, Vibration sensor module (SW-420), TM1637 4-digit display, LM2596 Buck Module, ABS project box (100 × 60 × 25 mm), Fuse 1 A glass (5 × 20 mm), Fuse holder (panel, 5 × 20 mm) and Jumper wires male to male (40 pcs, 20 cm).
How long does the engine hour meter for pumps and tractors take to build?
About 90 minutes for a beginner maker, in 6 steps.
How do I know the engine hour meter for pumps and tractors works?
Engine off: No change in the total. Engine running 15 min: Total increases by 15 minutes. Power cycle: Total restored from EEPROM.
Counts while the engine is off: what should I check?
The sensor is too sensitive or on a shared bench. Lower the trimmer.
Does not count: what should I check?
The engine does not shake the sensor enough. Mount it on a rigid part nearer the engine.
Total resets to zero: what should I check?
EEPROM write failed or was never saved. Run for at least 10 minutes.
Nano resets when starting the engine: what should I check?
Add a 470 µF capacitor at the buck input.
