Electronic tamper-evident seal
Build it step by step
0 of 7 doneProgram the chip
Use Arduino as ISP.
Test the loop
Hold the pin low and watch the LED stay off.
Break the loop
The LED starts blinking.
Wire the seal
Fine wire through the lid seam.
Read the EEPROM
Dump it with the programmer.
Measure the sleep current
A few microamps.
Test the lid
Open it a few times in a dry run.
How do you build an electronic tamper-evident seal?
A seal for a box logs when it was opened, by breaking a fine wire loop. You need ATtiny85-20PU microcontroller, Enamelled copper wire (magnet wire, 0.3 mm), CR2032 coin cell, CR2032 coin cell holder, LED 5 mm red and Resistor 220 Ω. It takes 7 steps and about 150 minutes.
- Level
- Intermediate
- Time
- About 150 min
- Parts
- 6
Parts list
- Integrated CircuitsBuy
- Cables & Wires
- BatteriesBuyCR2032 coin cell × 1
- PowerBuy
- SemiconductorsBuyLED 5 mm red × 1
- PassivesBuyResistor 220 Ω × 1
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Coin cell plus | ATtiny85 pin 8 | Power |
| Coin cell minus | ATtiny85 pin 4 | Ground |
| Fine wire loop | ATtiny85 PB1 (pin 6) to ground, with the internal pull-up | Loop intact reads low |
| Red LED | ATtiny85 PB0 (pin 5) through 220 Ω to ground | Opened indicator |
Code
A hair-thin enamelled wire runs through the lid seam in a loop; when someone opens the box the loop snaps, the input goes high through the pull-up, and the chip stores how long it had been armed, counted in 8-second watchdog ticks, then blinks a red LED every 8 seconds from then on. Strip the enamel only at the two ends you connect. Read the stored count by dumping the EEPROM through the programmer: byte 0 is the opened flag and bytes 1 to 4 hold the ticks since arming. Sleep current is a few microamps, so a CR2032 lasts a long time. This is a tamper-evident seal for your own boxes, such as sample or equipment cases, not a lock: a patient person can repair a broken wire, and it does not stop anyone, it only tells you something happened. Coin cells are dangerous to swallow, so keep the seal and spare cells away from young children.
Runs on a virtual ATtiny85 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).
// Tamper seal: counts 8-second ticks, saves the count when the wire loop breaks. Board: ATtiny85 (ATTinyCore, 1 MHz).
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
#include <EEPROM.h>
const int LOOP_PIN = 1, LED = 0;
volatile unsigned long ticks = 0; // 8 seconds per tick, about 100 years of range
ISR(WDT_vect) { ticks++; }
ISR(PCINT0_vect) {}
void watchdog8s() {
MCUSR &= ~_BV(WDRF);
WDTCR |= _BV(WDCE) | _BV(WDE);
WDTCR = _BV(WDIE) | _BV(WDP3) | _BV(WDP0); // interrupt only, 8 s period
}
void sleepNow() {
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable(); sei(); sleep_cpu(); sleep_disable();
}
void setup() {
pinMode(LOOP_PIN, INPUT_PULLUP); pinMode(LED, OUTPUT);
GIMSK |= _BV(PCIE); PCMSK |= _BV(PCINT1);
watchdog8s();
if (EEPROM.read(0) != 0xA5 && digitalRead(LOOP_PIN) == LOW) ticks = 0; // armed: loop intact
}
void loop() {
if (EEPROM.read(0) == 0xA5) { // already opened: blink every 8 seconds
digitalWrite(LED, HIGH); delay(30); digitalWrite(LED, LOW);
sleepNow();
return;
}
if (digitalRead(LOOP_PIN) == HIGH) { // loop broken
unsigned long t = ticks;
EEPROM.put(1, t); // ticks since arming, 8 s each
EEPROM.write(0, 0xA5);
return;
}
sleepNow(); // wake on the watchdog tick or the pin change
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Loop intact | LED stays off |
| Loop broken | LED blinks every 8 seconds |
| EEPROM | Opened flag and tick count saved |
| Battery | Months or years of life |
If it does not work
Opens by itself
Check the wire joint and its pull-up.
No blink
Check LED polarity and the 220 Ω resistor.
Count wrong
Use the correct fuse and clock settings.
Chip never sleeps
Check the watchdog setup.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the electronic tamper-evident seal?
ATtiny85-20PU microcontroller, Enamelled copper wire (magnet wire, 0.3 mm), CR2032 coin cell, CR2032 coin cell holder, LED 5 mm red and Resistor 220 Ω.
How long does the electronic tamper-evident seal take to build?
About 150 minutes for a intermediate maker, in 7 steps.
How do I know the electronic tamper-evident seal works?
Loop intact: LED stays off. Loop broken: LED blinks every 8 seconds. EEPROM: Opened flag and tick count saved.
Opens by itself: what should I check?
Check the wire joint and its pull-up.
No blink: what should I check?
Check LED polarity and the 220 Ω resistor.
Count wrong: what should I check?
Use the correct fuse and clock settings.
Chip never sleeps: what should I check?
Check the watchdog setup.
