Alarm Protected Shelf

by Alex Li in Workshop > Shelves

234 Views, 1 Favorites, 0 Comments

Alarm Protected Shelf

Screenshot 2025-02-20 at 1.32.04 PM.png

I have a lot of rubik’s cubes. Some are big; some are small; some cost an absurd amount of money. Two years ago, my younger brother destroyed one of my cubes by throwing it on the ground, and since then I have spent $90 on security upgrades to prevent it from happening again. But even when he’s not destroying my cubes, he’s scrambling them when I have them on display. I just want to display my cubes without having them being touched. So, I spent a month building this shelf that rings an alarm whenever you remove an item from it.


Supplies

  1. Strobe light + piezo buzzer
  2. Arduino Uno
  3. 4x Load cells + HX711
  4. I2C LCD
  5. 4x4 Keypad
  6. Wires, breadboard, and transistor
  7. 2x 12V power supply


Optional if you are designing your own frame

  1. Frame pieces
  2. Screws and threaded inserts

Frame

Screenshot 2025-02-20 at 2.23.49 PM.png
2.24(2).png

I designed my frame in tinkercad and sent the files to Justway to produce.

Justway is an affordable online manufacturing service, with services such as 3d printing, cnc machining, and sheet metal forming. To place an order on Justway, click this link to open the menu page. Select the service you are using, and click upload your design. This will take you to a page where you can upload your design and pick your material, color, and other special requests. Once all selections have been made, submit your request and wait for it to be approved. Once approved, pay for the order and wait for the parts to arrive.

When I first used Justway for my 3d printed parts, I received an email shortly after the order about a design flaw in one of my models. The production team asked me if I wanted to continue with my original design or a modified version they had created. I opted for the original design because it wasn’t a major issue.

When I unboxed the parts, I was surprised by not only the quality and dimensional accuracy of the parts, but also the fact that I received extras for a bulk order presumably in case of shipping damage.

You can design your own frame, but if you want to use my frame, it is linked here.

Keypad and LCD

Screenshot 2025-02-20 at 1.57.10 PM.png

Using an I2C LCD, connect the ports as listed below and shown in the diagram

  1. VCC to 5V(ideally through breadboard)
  2. GND to GND(ideally through breadboard)
  3. SDA to A4
  4. SCL to A5

Using a 4x4 keypad, connect the ports as listed below and shown in the diagram

  1. Row 1 to 5
  2. Row 2 to 4
  3. Row 3 to 3
  4. Row 4 to 2
  5. Column 1 to 9
  6. Column 2 to 8
  7. Column 3 to 7
  8. Column 4 to 6

Load Cells

Screenshot 2025-02-20 at 2.07.02 PM.png
Screenshot 2025-02-20 at 2.07.14 PM.png

Tinkercad Circuits does not have a HX711, so I used a breadboard in the diagram.

Using four load cells and a HX711, connect the ports as listed below and shown in the diagram

  1. Place four load cells in corners of shelf
  2. Connect adjacent black and white wires
  3. Connect two opposite(diagonal) red wires to A+ and A-
  4. Connect other two opposite(diagonal) red wires to E+ and E-
  5. DO NOT CONNECT B+ AND B-
  6. VCC to 5V
  7. GND to GND
  8. DT to 12
  9. SCK to 11


Strobe Light and Buzzer

Screenshot 2025-02-20 at 2.11.17 PM.png

Connect Piezo's + to pin 13 and - to GND

Connect 12V power supply to strobe light through a mosfet transistor

  1. Gate to 10
  2. Drain to ground of power supply
  3. Source to negative of strobe light
  4. power of power supply to power of strobe light


Code

Screenshot 2025-02-20 at 2.15.23 PM.png

Example Code:

#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
#include <HX711_ADC.h>
//include libraries needed

#define calibration_factor -22233.33
#define LOADCELL_DOUT_PIN 12
#define LOADCELL_SCK_PIN 11
int alarmPin = 10;
int buzzerPin = 13;
//define pins used

const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};

byte colPins[ROWS] = {9, 8, 7, 6};
byte rowPins[COLS] = {5, 4, 3, 2};
//define keypad


Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd(0x27, 16, 2);
HX711_ADC scale(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
//initialize keypad, lcd, and load cells

char resetKey = '*';


String code = "1234#";
String input = "";
bool alarmActive = false;
float oldWeight;
int timeOff = 60;
//changable values

void setup() {
Serial.begin(9600);
scale.begin();
scale.start(2000);
scale.setCalFactor(calibration_factor);
scale.tare();
//initialize scale

lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SECURITY ON");
//initialize LCD

oldWeight = scale.getData();
//define initial weight

pinMode(buzzerPin, OUTPUT);
//initialize buzzer
}

void loop() {
scale.update();
char customKey = customKeypad.getKey();
//check for key presses
if (customKey) {
Serial.println(customKey);
if (customKey == resetKey) {
input = "";
lcd.clear();
//clear input if reset key pressed
}else {
input += customKey;
//add key press to input
}
lcd.setCursor(0, 1);
lcd.print(input);
}
if(input==code){
stopAlarm();
disableSecurity();
input = "";
//disable security if correct code entered
}
if (fabs(scale.getData() - oldWeight) > 0.2 && !alarmActive) {

soundAlarm();
//activate alarm if abnormal weight
}
}

void soundAlarm() {
alarmActive = true;
digitalWrite(alarmPin, HIGH);
tone(buzzerPin, 1200);
//activate strobe light and buzzer

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("ALARM ACTIVE");
lcd.setCursor(0, 1);
lcd.print(input);
//print alarm active on lcd
}

void stopAlarm(){
noTone(buzzerPin);
alarmActive = false;
digitalWrite(alarmPin, LOW);
//turn off strobe light and buzzer
}

void disableSecurity() {
if (input == code) {
for (int i = timeOff; i > 0; i--) {
//if code is correct
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SECURITY OFF FOR");
lcd.setCursor(0, 1);
lcd.print(String(i) + " SECONDS");
delay(1000);
scale.update();
oldWeight = scale.getData();
//disable security and show countdown on LCD
}
scale.update();
oldWeight = scale.getData();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SECURITY ON");
//change oldWeight to after
}
}


Note that the calibration factor is for my load cells. You will have to calibrate yours by yourself using the calibration example in the HX711_ADC library.