Community project

Museum Anti-Theft Security

Photo of Museum Anti-Theft Security
Generated with AI

TLICH AHMED YOUSSEF

Published December 1, 2026

This museum anti-theft security system uses weight sensing and servo-controlled barriers to protect valuable artifacts on display. Built around an ESP32 microcontroller, the system monitors a load cell to detect when an object is removed from its case, triggers visual and audible alarms, and activates servo-driven locking mechanisms to prevent unauthorized removal.

The guide provides a complete wiring diagram, parts list, and step-by-step assembly instructions for integrating the weight sensor, alarm indicators, push-button controls, and servo actuators. Firmware is included to handle the system's three operational states: commissioning, armed monitoring, and active alarm response.

Wiring diagram

Loading diagram…

Gather all the parts

QtyComponent
1

USB-C 5V Adapter

Regulated 5 V, 3 A

USB-C wall adapter delivering regulated 5 V to the board's USB or VBUS rail. Default wired power source for desktop / stationary projects.

1

MCP23017-E/SP DIP-28

Discrete through-hole component for the tabletop circuit

1

Resistor

4.7 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

4.7 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

LED

Green, low-current

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

220 Ω

Through-hole resistor (current-limiting in series with an LED)

1

LED

Red, low-current

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

220 Ω

Through-hole resistor (current-limiting in series with an LED)

1

LED

Blue, low-current

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

220 Ω

Through-hole resistor (current-limiting in series with an LED)

1

LED

Yellow, low-current

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

220 Ω

Through-hole resistor (current-limiting in series with an LED)

1

Reed Switch

Glass-encapsulated magnetic reed switch -- contacts close in the presence of a magnetic field. Standard door/window sensor for alarms. Wire as a digital input with internal pull-up; debounce in firmware.

1

Push Button

Momentary push button switch

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

HX711 Load Cell Amplifier

24-bit ADC front-end for strain-gauge load cells and weigh scales. DT/DOUT and SCK are MCU-facing pins; E+/E-/A+/A- connect to the load cell bridge.

1

Load Cell

Four-wire strain-gauge straight-bar load cell, common 5 kg hobby scale sensor. It produces a small bridge signal and should be read through a load-cell ADC/amplifier such as HX711 or NAU7802 rather than directly by a microcontroller GPIO.

1

74AHCT125 Quad Buffer / Level Shifter

Quad non-inverting buffer with 3-state outputs and active-low output enables, in a breadboard-friendly 14-pin DIP. Powered from 5 V, its TTL-level inputs accept 3.3 V logic, so it is a common one-way 3.3 V to 5 V level shifter for NeoPixel/WS2812 data and other fast digital signals; each output drives up to 8 mA.

1

SG90 Servo

Display case

Micro servo motor (SG90)

1

SG90 Servo

Tabletop model exit flag

Micro servo motor (SG90)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

NPN Transistor (2N2222 / BC547)

PN2222A

General-purpose NPN bipolar junction transistor (BJT) in TO-92 package. Used as a low-side switch to drive loads (e.g. buzzers) whose current exceeds ESP32 GPIO source capability (~12 mA). A ~1 kΩ base resistor is placed between the ESP32 GPIO and the transistor base. The collector connects to the load negative terminal (buzzer –), and the emitter connects to GND. When the GPIO goes HIGH (3.3 V), the transistor saturates and switches the load on. Compatible with both 2N2222/2N2222A and BC547/BC547B variants. Add a flyback diode (e.g. 1N4148) across inductive load terminals.

1

Resistor

1 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

100 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

5 V active piezo buzzer

Self-oscillating DC piezo, ≤15 mA at 5 V

Discrete through-hole component for the tabletop circuit

1

Ceramic Capacitor

100 nF

Through-hole ceramic capacitor bought by value, such as 22 pF, 10 nF or 100 nF (0.1 µF). It is non-polarised, so either lead can go to either net. Its most common job is decoupling: a 100 nF capacitor between an IC's supply pin and ground, placed as close to the chip as possible.

1

Ceramic Capacitor

100 nF

Through-hole ceramic capacitor bought by value, such as 22 pF, 10 nF or 100 nF (0.1 µF). It is non-polarised, so either lead can go to either net. Its most common job is decoupling: a 100 nF capacitor between an IC's supply pin and ground, placed as close to the chip as possible.

1

Electrolytic Capacitor

1000 µF / 10 V

Radial aluminium electrolytic capacitor bought by value and voltage rating, such as 10 µF, 100 µF or 1000 µF 10 V. It is polarised: the + lead goes to the higher voltage and the - lead, marked by the stripe on the sleeve, to the lower voltage or ground. It is mostly used for bulk filtering across a power rail, with a voltage rating comfortably above the rail.

Assemble it in 4 steps

1. Separate the two supplies

With all power off, use USB for the NodeMCU and a regulated 5 V 3 A adapter with a suitable wire-output breakout for the actuator rail. Join the grounds, not the positive rails. Run the servo power and ground wires directly to the adapter distribution point. Put C3 across the servo feed, minus to ground.

2. Wire the indicators and switches

Place U2 across the breadboard gap. On its DIP package VDD is pin 9, VSS 10, SCL 12, SDA 13, A0–A2 pins 15–17, RESET 18, and GPA0–GPA6 pins 21–27. Fit C1 beside pins 9 and 10. Connect the LEDs through their individual resistors, short legs to ground. Fit the reed magnet so the contacts close when the case is shut. Place the reset button on the staff side of the model.

3. Mount the weighing platform

Bolt one end of the load cell to a rigid base and the other to the artifact platform with spacers. Leave the bending section clear. Match bridge leads by their terminal names, not by insulation colour. Use a 3.3 V capable HX711 board with single VCC input.

4. Wire the sounder and model servos

Check the PN2222A lead order against its datasheet. Mount C2 near U4 power pins. Check servo connector polarity before applying 5 V. Test the horns unloaded, then fit M1 to the miniature case latch and M2 to a model exit indicator flag only.

  • Do not connect this circuit to any occupied room exit. Keep fingers clear of moving horns.

Review all connections

1. Connections between "PS1" and "ESP32"

FunctionPS1ESP32
power+5V5V
groundGNDGND

2. Connections between "U2" and "ESP32"

FunctionU2ESP32
powerVDD3V3
groundVSSGND
i2cSDAGPIO 4
i2cSCLGPIO 5
powerRESET3V3
groundA0GND
groundA1GND
groundA2GND

3. Connections between "R1" and "ESP32"

FunctionR1ESP32
digitalP1 → MCP23017-E/SP DIP-28 SDAEXT
powerP23V3

4. Connections between "R2" and "ESP32"

FunctionR2ESP32
digitalP1 → MCP23017-E/SP DIP-28 SCLEXT
powerP23V3

5. Connections between "D1" and "ESP32"

FunctionD1ESP32
digitalANODE → Resistor P2EXT
groundGNDGND

6. Connections between "R3" and "ESP32"

FunctionR3ESP32
digitalP1 → MCP23017-E/SP DIP-28 GPA0EXT

7. Connections between "D2" and "ESP32"

FunctionD2ESP32
digitalANODE → Resistor P2EXT
groundGNDGND

8. Connections between "R4" and "ESP32"

FunctionR4ESP32
digitalP1 → MCP23017-E/SP DIP-28 GPA1EXT

9. Connections between "D3" and "ESP32"

FunctionD3ESP32
digitalANODE → Resistor P2EXT
groundGNDGND

10. Connections between "R5" and "ESP32"

FunctionR5ESP32
digitalP1 → MCP23017-E/SP DIP-28 GPA2EXT

11. Connections between "D4" and "ESP32"

FunctionD4ESP32
digitalANODE → Resistor P2EXT
groundGNDGND

12. Connections between "R6" and "ESP32"

FunctionR6ESP32
digitalP1 → MCP23017-E/SP DIP-28 GPA3EXT

13. Connections between "SW1" and "ESP32"

FunctionSW1ESP32
dataPIN1 → MCP23017-E/SP DIP-28 GPA5EXT
groundPIN2GND

14. Connections between "SW2" and "ESP32"

FunctionSW2ESP32
digitalSIGNAL → MCP23017-E/SP DIP-28 GPA6EXT
groundGNDGND

15. Connections between "R7" and "ESP32"

FunctionR7ESP32
digitalP1 → MCP23017-E/SP DIP-28 GPA5EXT
powerP23V3

16. Connections between "R8" and "ESP32"

FunctionR8ESP32
digitalP1 → MCP23017-E/SP DIP-28 GPA6EXT
powerP23V3

17. Connections between "U3" and "ESP32"

FunctionU3ESP32
powerVCC3V3
groundGNDGND
digitalDTGPIO 12
digitalSCKGPIO 14

18. Connections between "LC1" and "ESP32"

FunctionLC1ESP32
powerE+ → HX711 Load Cell Amplifier E+EXT
groundE- → HX711 Load Cell Amplifier E-EXT
analogA+ → HX711 Load Cell Amplifier A+EXT
analogA- → HX711 Load Cell Amplifier A-EXT

19. Connections between "U4" and "ESP32"

FunctionU4ESP32
powerVCC5V
groundGNDGND
ground1OEGND
ground2OEGND
power3OE5V
power4OE5V
digital1AGPIO 13
digital2AGPIO 16
ground3AGND
ground4AGND

20. Connections between "M1" and "ESP32"

FunctionM1ESP32
powerVCC5V
groundGNDGND
pwmSIGNAL → 74AHCT125 Quad Buffer / Level Shifter 1YEXT

21. Connections between "M2" and "ESP32"

FunctionM2ESP32
powerVCC5V
groundGNDGND
pwmSIGNAL → 74AHCT125 Quad Buffer / Level Shifter 2YEXT

22. Connections between "R9" and "ESP32"

FunctionR9ESP32
digitalP1 → 74AHCT125 Quad Buffer / Level Shifter 1AEXT
groundP2GND

23. Connections between "R10" and "ESP32"

FunctionR10ESP32
digitalP1 → 74AHCT125 Quad Buffer / Level Shifter 2AEXT
groundP2GND

24. Connections between "Q1" and "ESP32"

FunctionQ1ESP32
groundEMITTERGND
digitalBASE → Resistor P2EXT

25. Connections between "R11" and "ESP32"

FunctionR11ESP32
digitalP1 → MCP23017-E/SP DIP-28 GPA4EXT

26. Connections between "R12" and "ESP32"

FunctionR12ESP32
digitalP1 → NPN Transistor (2N2222 / BC547) BASEEXT
groundP2GND

27. Connections between "BZ1" and "ESP32"

FunctionBZ1ESP32
powerPOS5V
groundNEG → NPN Transistor (2N2222 / BC547) COLLECTOREXT

28. Connections between "C1" and "ESP32"

FunctionC1ESP32
power13V3
ground2GND

29. Connections between "C2" and "ESP32"

FunctionC2ESP32
power15V
ground2GND

30. Connections between "C3" and "ESP32"

FunctionC3ESP32
power+5V
ground-GND

Deploy the firmware

#include <Arduino.h>
#include <Wire.h>
#include <Servo.h>
#include <HX711.h>
HX711 scale;
Servo displayCase, exitFlag;
constexpr uint8_t address=0x20;
bool wr(uint8_t reg,uint8_t value){Wire.beginTransmission(address);Wire.write(reg);Wire.write(value);return Wire.endTransmission()==0;}
int ports(){Wire.beginTransmission(address);Wire.write(0x12);if(Wire.endTransmission(false)||Wire.requestFrom(address,uint8_t(1))!=1)return -1;return Wire.read();}
enum State {Commission, Armed, Alarm};
State state=Commission;
uint32_t lastSample, opened, held, lastOutput;
long baseline; int misses; bool released;
// Set from the serial readings: threshold should exceed idle drift but be
// comfortably smaller than the raw change measured when lifting the artifact.
constexpr long threshold=50000;
void enter(State s){state=s;held=opened=0;released=false;misses=0;
 displayCase.write(s==Alarm?75:20); exitFlag.write(s==Alarm?75:20);
 wr(0x14,s==Alarm?0x1f:s==Armed?1:0);
 Serial.println(s==Alarm?"ALARM":s==Armed?"ARMED":"COMMISSION: close case with artifact fitted and hold reset");}
void setup(){Serial.begin(115200);Wire.begin(4,5);Wire.setClock(100000);
 wr(0x14,0);wr(0x00,0xe0);scale.begin(12,14);lastSample=millis();
 displayCase.attach(13,1000,2000);exitFlag.attach(16,1000,2000);enter(Commission);}
void loop(){uint32_t now=millis();int io=ports();bool closed=io>=0&&!(io&0x20), pressed=io>=0&&!(io&0x40);
 static long sample=0;static bool sampled=false;
 if(scale.is_ready()){sample=scale.read();lastSample=now;sampled=true;
  if(now-lastOutput>=500){lastOutput=now;Serial.printf("Raw %ld; baseline %ld\n",sample,baseline);}
  if(state==Armed){if(labs(sample-baseline)>threshold){if(++misses>=2)enter(Alarm);}else misses=0;}}
 bool fresh=sampled&&now-lastSample<800;
 if(state==Armed){if(closed)opened=0;else if(!opened)opened=now;
  if(!fresh||(opened&&now-opened>=50))enter(Alarm);}
 if(state==Alarm)wr(0x14,0x1f);
 if(!pressed){held=0;released=io>=0;}
 if(state!=Armed&&released&&pressed&&closed&&fresh&&(state==Commission||labs(sample-baseline)<threshold/2)){
  if(!held)held=now;else if(now-held>=1500){if(state==Commission)baseline=sample;enter(Armed);}
 }else held=0;
 delay(5);
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik