Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2025:eradu:stefan.dascalu2612 [2025/05/20 23:29]
stefan.dascalu2612
pm:prj2025:eradu:stefan.dascalu2612 [2025/05/30 07:54] (current)
stefan.dascalu2612
Line 6: Line 6:
 ==== Introduction ====  ​ ==== Introduction ====  ​
 **eSafe** is a digital lockbox implemented on an **Arduino Uno**. It uses a 4×4 matrix keypad for PIN entry, an SG90 servo for a mechanical latch, a DS1307 real-time clock (I²C) to enforce access windows, and a 16×2 I²C LCD to display status and time. Three wrong PIN attempts trigger an alarm tone and flashing red LED; valid entries drive the servo to unlock, light a green LED, and display “UNLOCKED.” **eSafe** is a digital lockbox implemented on an **Arduino Uno**. It uses a 4×4 matrix keypad for PIN entry, an SG90 servo for a mechanical latch, a DS1307 real-time clock (I²C) to enforce access windows, and a 16×2 I²C LCD to display status and time. Three wrong PIN attempts trigger an alarm tone and flashing red LED; valid entries drive the servo to unlock, light a green LED, and display “UNLOCKED.”
- 
-**This project integrates functionalities from three labs:** 
-  * **Lab 2 (Interrupts & GPIO):** keypad row-change detection  ​ 
-  * **Lab 3 (Timers):** debounce via Timer 2 CTC and alarm timing  ​ 
-  * **Lab 6 (I²C):** shared bus for LCD and RTC  ​ 
- 
  
 {{schema77.png?​650x}} {{schema77.png?​650x}}
Line 26: Line 20:
  
 ==== Hardware Functionality ====  ​ ==== Hardware Functionality ====  ​
-  * **Keypad**: ​row-interrupt + Timer 2 CTC debounce ​  +  * **Keypad**: ​polled via Keypad library on GPIO
   * **Buzzer**: tone/noTone alarm, driven directly from Arduino pin  ​   * **Buzzer**: tone/noTone alarm, driven directly from Arduino pin  ​
   * **LEDs**: status indicators with resistors ​   ​   * **LEDs**: status indicators with resistors ​   ​
   * **Servo**: 50 Hz PWM; relocked non-blocking after 5 s   * **Servo**: 50 Hz PWM; relocked non-blocking after 5 s
   * **LCD/​RTC**:​ HD44780 via PCF8574; DS1307 battery-backed timekeeper  ​   * **LCD/​RTC**:​ HD44780 via PCF8574; DS1307 battery-backed timekeeper  ​
 +  * **ADC**: internal 1.1 V band-gap → VCC monitor every 5 s; red LED blinks below 4.6 V
   * **Power**: on-board 5 V regulator (~500 mA); peak draw ~270 mA  ​   * **Power**: on-board 5 V regulator (~500 mA); peak draw ~270 mA  ​
  
 ==== Pin-out Detail ====  ​ ==== Pin-out Detail ====  ​
 ^ Component ​         ^ Interface ​     ^ Arduino pin  ^ Direction ​ ^ Rationale ​                                     ^  ​ ^ Component ​         ^ Interface ​     ^ Arduino pin  ^ Direction ​ ^ Rationale ​                                     ^  ​
-| Keypad row/​col ​    | GPIO           | D2–D9 ​       | input      | Pin-change ISR on D2–D5; columns polled on D6–D9 ​|  ​+| Keypad row/​col ​    | GPIO           | D2–D9 ​       | input      | Scanned periodically by Keypad library (no interrupts) ​|  ​
 | Passive buzzer ​    | GPIO           | D11          | output ​    | direct drive with tone()/​noTone() ​               |  ​ | Passive buzzer ​    | GPIO           | D11          | output ​    | direct drive with tone()/​noTone() ​               |  ​
 | Red LED            | GPIO           | D13          | output ​    | Built-in LED pin                                 ​|  ​ | Red LED            | GPIO           | D13          | output ​    | Built-in LED pin                                 ​|  ​
Line 42: Line 37:
 | LCD I²C            | I²C (TWI)      | A4/A5        | bidir      | Hardware Wire bus                                |  ​ | LCD I²C            | I²C (TWI)      | A4/A5        | bidir      | Hardware Wire bus                                |  ​
 | RTC DS1307 ​        | I²C (TWI)      | A4/A5        | bidir      | Shares same TWI bus                              |  ​ | RTC DS1307 ​        | I²C (TWI)      | A4/A5        | bidir      | Shares same TWI bus                              |  ​
 +| ADC (VCC monitor) ​ | internal ch 14 |   ​— ​         | input      | 1.1 V band-gap reference ​                        |
 +
  
 ==== Bill Of Materials ====  ​ ==== Bill Of Materials ====  ​
Line 52: Line 49:
 | Breadboard + jumper wires + LEDs + resistors ​ | https://​www.optimusdigital.ro/​ro/​kituri/​12026-kit-plusivo-pentru-introducere-in-electronica-0721248990075.html ​                                                       |  ​ | Breadboard + jumper wires + LEDs + resistors ​ | https://​www.optimusdigital.ro/​ro/​kituri/​12026-kit-plusivo-pentru-introducere-in-electronica-0721248990075.html ​                                                       |  ​
  
-==== Photos of the eSafe project ====+==== Photos ​and video of the eSafe project ====
 {{esafe1.jpeg?​400x}} {{esafe1.jpeg?​400x}}
 {{esafe2.jpeg?​400x}} {{esafe2.jpeg?​400x}}
 {{esafe3.jpeg?​400x}} {{esafe3.jpeg?​400x}}
  
-==== Software Design ====  +https://​youtube.com/​shorts/​6ttbbS6FWxo 
 + 
 +==== Software Design ====
  
 === Implementation Status ===  ​ === Implementation Status ===  ​
-  * Full feature set in ~200 lines of C++ on Arduino Uno   +  * ~400 lines of custom ​C++ on Arduino Uno integrating all core features ​  
-  * PIN entry, ​servo latch, LEDs, buzzer, I²C LCD & RTC, time window, unlock log   +  * PIN entry with 4×4 matrix scanthree-strike alarmand time-based lockout fully tested ​  
-  * Stable on hardware; manual end-to-end tests completed  ​+  * Live clock updatesnon-blocking unlock/​relock,​ and persistent last-unlock log verified in hardware ​  
 +  * Real-time VCC reading via ADC; value streamed ​to Serial Monitor and low-battery LED alert 
  
 === Library Choices ===  ​ === Library Choices ===  ​
-Library ​              ^ Purpose ​                    Justification ​                                 ​^  ​ +Library ​            | Purpose ​                    Justification ​                                   | 
-| Wire / RTClib ​        ​| I²C DS1307 ​               Adafruit’s ​proven RTC driver ​                    +| Wire / RTClib ​      ​| I²C bus & DS1307 ​driver ​    | proven ​reliability,​ minimal API for RTC access ​  
-| LiquidCrystal_I2C ​    ​| I²C LCD                      ​Minimal ​wiring, easy print interface ​            +| LiquidCrystal_I2C ​  ​HD44780 LCD over I²C        reduces ​wiring ​and boilerplate, easy print() API 
-| Keypad ​               4×4 scan debounce ​         handles interrupts + debouncing ​               ​  +| Keypad ​             matrix ​scan debounce ​     built-in interrupt support and debounce logic    ​
-| Servo                 ​| SG90 control ​                ​| official Arduino, ​simple API                   ​| ​ +| Servo               ​| SG90 control ​               | official Arduino, ​handles PWM timing internally ​ |
  
-=== Novelty ​Element ​===   +=== Novelty ​& Lab Integration ​===   
-  * Time-lock feature enforcing business hours  ​ +  * **PWM servo control** (Lab 3 – Timers/​PWM):​ SG90 latch driven at 50 Hz; non-blocking auto-relock with `millis()`. 
-  * Unlock log on LCD  ​ +  * **Supply-voltage monitor** (Lab 4 – ADC): reads the 1.1 V band-gap ​on channel 14 every 5 s, prints VCC on Serial Monitor, blinks red LED when VCC < 4.6 V. 
-  * Integration of multiple lab modules into one device  ​+  * **Shared I²C bus** (Lab 6 – I²C): DS1307 RTC and PCF8574 LCD expander operate on the same SDA/SCL lines.
  
-=== Development ​=== +=== Architecture ​===   
-  * Arduino IDE PlatformIO+1. **updateDisplay()** ​  
 +   - called once per second (via `millis()`),​ updates HH:MM:SS, renders PIN asterisks or “Last HH:​MM” ​  
 +   - never blocks, so UI remains responsive ​  
 +2. **handleKey()** ​  
 +   - ‘C’ clears entry, digits append to buffer (with asterisks), ‘D’ validates PIN   
 +   - on correct PIN, calls `unlockDoor()`;​ on wrong, increments counter or triggers alarm   
 +3. **unlockDoor()** ​  
 +   - moves servo to unlock angle, lights green LED + buzzer for 1 s   
 +   - sets `lockRestoreMs = millis() + 5000` for non-blocking relock in `loop()` ​  
 +   - logs timestamp in `lastUnlock` for display ​  
 +4. **loop()** ​  
 +   - checks `millis()` vs. `lockRestoreMs` to relock servo without pausing ​  
 +   - updates display every second and polls keypad  
 +   - validated by toggling between allowed/outside hours and using a stopwatch for timing  ​
  
-=== Core modules ​===  +=== Calibration & Optimizations ​=== 
-  * `updateDisplay()`: live clock, PIN prompt/​asterisks,​ last-unlock  ​ +  * **Keypad debounce** is handled inside the Keypad library ​(no Timer2 code needed). 
-  * `handleKey()`: ‘C’ clear, digit entry, ‘D’ submit with window check   +  * **Servo angles**: adjusted to 20° (unlockand 110° (lockfor mechanical reliability. ​  
-  * `unlockDoor()`: unlock sequence + schedule non-blocking relock ​  +  * **Blocking calls minimized**: only a 1 s buzzer delay remains; all longer waits use non-blocking `millis()` logic.
-=== Libraries === +
-  * Wire/​RTClib +
-  ​LiquidCrystal_I2C +
-  ​Keypad +
-  ​Servo   +
- +
-==== Safety & Build Quality ====   +
-neat wiring on breadboard +
- +
-- LEDs have 330 Ω current-limiting resistors+
  
 ==== Conclusions ====  ​ ==== Conclusions ====  ​
-eSafe demonstrates ​integration of GPIOinterrupts, timers, PWM, and I²C into a user-friendly digital safeNon-blocking ​design ensures smooth UI and reliable timekeeping. +eSafe showcases the seamless ​integration of three core microcontroller features: PWM (servo latch)ADC (live VCC monitoring), and I²C (RTC + LCD)All time-sensitive tasks are handled with non-blocking ​`millis()` logic, so the user interface stays responsive while the clock remains accurate.
 ==== Bibliography & Resources ====  ​ ==== Bibliography & Resources ====  ​
   * ATmega328P Datasheet   * ATmega328P Datasheet
pm/prj2025/eradu/stefan.dascalu2612.1747772981.txt.gz · Last modified: 2025/05/20 23:29 by stefan.dascalu2612
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0