This shows you the differences between two versions of the page.
pm:prj2025:eradu:stefan.dascalu2612 [2025/05/21 00:11] stefan.dascalu2612 [Photos and video of the eSafe project] |
pm:prj2025:eradu:stefan.dascalu2612 [2025/05/30 07:54] (current) stefan.dascalu2612 |
||
---|---|---|---|
Line 20: | 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 36: | 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 51: | Line 54: | ||
{{esafe3.jpeg?400x}} | {{esafe3.jpeg?400x}} | ||
- | {{ youtube>large:6ttbbS6FWxo }} | + | https://youtube.com/shorts/6ttbbS6FWxo |
==== Software Design ==== | ==== Software Design ==== | ||
=== Implementation Status === | === Implementation Status === | ||
- | * ~200 lines of custom C++ on Arduino Uno integrating all core features | + | * ~400 lines of custom C++ on Arduino Uno integrating all core features |
* PIN entry with 4×4 matrix scan, three-strike alarm, and time-based lockout fully tested | * PIN entry with 4×4 matrix scan, three-strike alarm, and time-based lockout fully tested | ||
* Live clock updates, non-blocking unlock/relock, and persistent last-unlock log verified in hardware | * Live clock updates, non-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 === | ||
Line 68: | Line 73: | ||
=== Novelty & Lab Integration === | === Novelty & Lab Integration === | ||
- | * **Non-blocking relock** (Lab 3 – Timers): replaced `delay(5000)` with a `millis()` timestamp so the 5 s unlock interval doesn’t freeze the clock display. | + | * **PWM servo control** (Lab 3 – Timers/PWM): SG90 latch driven at 50 Hz; non-blocking auto-relock with `millis()`. |
- | * **Interrupt-driven keypad** (Lab 2 – GPIO/Interrupts): uses pin-change interrupts on rows and Timer2 CTC for debounce to guarantee responsive PIN capture. | + | * **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. |
- | * **Shared I²C bus** (Lab 6 – I²C): demonstrates multi-device communication between the DS1307 RTC and the PCF8574-based LCD expander. | + | * **Shared I²C bus** (Lab 6 – I²C): DS1307 RTC and PCF8574 LCD expander operate on the same SDA/SCL lines. |
=== Architecture === | === Architecture === | ||
Line 88: | Line 93: | ||
- validated by toggling between allowed/outside hours and using a stopwatch for timing | - validated by toggling between allowed/outside hours and using a stopwatch for timing | ||
- | === Calibration & Optimizations === | + | === Calibration & Optimizations === |
- | * **Debounce tuning**: Timer2 CTC interval set to 60 ms based on oscilloscope measurements of switch bounce. | + | * **Keypad debounce** is handled inside the Keypad library (no Timer2 code needed). |
* **Servo angles**: adjusted to 20° (unlock) and 110° (lock) for mechanical reliability. | * **Servo angles**: adjusted to 20° (unlock) and 110° (lock) for mechanical reliability. | ||
* **Blocking calls minimized**: only a 1 s buzzer delay remains; all longer waits use non-blocking `millis()` logic. | * **Blocking calls minimized**: only a 1 s buzzer delay remains; all longer waits use non-blocking `millis()` logic. | ||
==== Conclusions ==== | ==== Conclusions ==== | ||
- | eSafe demonstrates integration of GPIO, interrupts, timers, PWM, and I²C into a user-friendly digital safe. Non-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 |