From 213edbacb7907f034d165f7c02cf038143a006f2 Mon Sep 17 00:00:00 2001 From: stephenminakian Date: Sun, 6 Jul 2025 22:13:53 -0600 Subject: [PATCH] Added additional documentation --- .gitignore | 32 + Particle/docs/power-analysis.md | 348 ++++++++ Particle/docs/troubleshooting.md | 1187 ++++++++++++++++++++++++++ Particle/hardware/wiring-diagram.md | 322 +++++++ Server/docs/architecture.md | 0 Server/docs/production-deployment.md | 0 6 files changed, 1889 insertions(+) create mode 100644 .gitignore create mode 100644 Particle/docs/power-analysis.md create mode 100644 Particle/docs/troubleshooting.md create mode 100644 Particle/hardware/wiring-diagram.md create mode 100644 Server/docs/architecture.md create mode 100644 Server/docs/production-deployment.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3372f72 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# Environment files +.env +*.env + +# Python +__pycache__/ +*.pyc +*.pyo +*.pyd +.Python +venv/ + +# Docker +.dockerignore + +# IDE +.vscode/ +.idea/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db + +# Logs +*.log +logs/ + +# Secrets +secrets/ +certificates/ \ No newline at end of file diff --git a/Particle/docs/power-analysis.md b/Particle/docs/power-analysis.md new file mode 100644 index 0000000..45aff18 --- /dev/null +++ b/Particle/docs/power-analysis.md @@ -0,0 +1,348 @@ +# Particle Boron LTE Power Analysis + +Comprehensive power consumption analysis and battery life calculations for ultra-low-power security device operation. + +## ๐Ÿ”‹ Executive Summary + +| Configuration | Daily Consumption | Battery Life (5000mAh) | Battery Life (10000mAh) | +|---------------|-------------------|------------------------|-------------------------| +| **Typical Operation** | 3-5 mAh | 2.7-4.6 years | 5.5-9.1 years | +| **Heavy Breach Activity** | 8-12 mAh | 1.1-1.8 years | 2.3-3.6 years | +| **With Solar (6W)** | Net positive | Indefinite | Indefinite | + +## โšก Power Consumption Breakdown + +### 1. Sleep Mode (STOP) - 99% of Operation Time + +``` +Current Draw: 130-150 ฮผA (microamps) +Duration: 23 hours, 59 minutes per day +Daily Consumption: 130ฮผA ร— 23.98h = 3.12 mAh +Percentage of Total: ~95% of daily power budget +``` + +**STOP Mode Details:** +- **Boron Core**: 80-100 ฮผA (CPU suspended, RAM retained) +- **Cellular Radio**: OFF (completely powered down) +- **GPIO Pins**: 10-20 ฮผA (minimal leakage current) +- **Real-Time Clock**: 30-40 ฮผA (wake timer active) +- **Power Management**: 10-20 ฮผA (voltage regulation) + +### 2. Wake and Process - Brief Active Periods + +``` +Current Draw: 80-120 mA (during processing) +Duration: 10-15 seconds per event +Frequency: 1-2 times per day (typical) +Daily Consumption: 100mA ร— 30s รท 3600s/h = 0.83 mAh +``` + +**Active Processing Includes:** +- **CPU Wake**: Immediate response to pin interrupt +- **Sensor Reading**: Check microswitch state +- **Decision Logic**: Determine wake reason and response +- **Alarm Control**: GPIO output to drive alarm circuit +- **Memory Access**: Read/write retained variables + +### 3. Cellular Connection - Network Communication + +``` +Current Draw: 300-800 mA (variable by signal strength) +Duration: 30-90 seconds per connection +Frequency: 1-3 times per day +Daily Consumption: 500mA ร— 90s รท 3600s/h = 12.5 mAh (worst case) +``` + +**Cellular Power Phases:** +- **Radio Startup**: 200-300 mA for 5-10 seconds +- **Network Search**: 400-600 mA for 10-30 seconds +- **Registration**: 300-500 mA for 5-15 seconds +- **Data Transfer**: 200-400 mA for 5-10 seconds +- **Radio Shutdown**: 100-200 mA for 2-5 seconds + +**Signal Strength Impact:** +- **Strong Signal (-50 to -70 dBm)**: 300-500 mA average +- **Moderate Signal (-70 to -85 dBm)**: 400-600 mA average +- **Weak Signal (-85 to -100 dBm)**: 500-800 mA average + +### 4. Alarm Operation - Security Response + +``` +Current Draw: +20-50 mA (additional load) +Duration: 10 seconds per activation +Frequency: Variable (0-10+ times per day) +Daily Consumption: 35mA ร— 10s ร— 2 events รท 3600s/h = 0.19 mAh +``` + +**Alarm Types:** +- **Low Power Buzzer**: +20 mA (direct GPIO drive) +- **High Power Siren**: +50 mA (via transistor driver) +- **Strobe Light**: +30-100 mA (depending on LED power) + +## ๐Ÿ“Š Detailed Power Scenarios + +### Scenario A: Normal Operation (Typical) + +``` +Daily Events: +- 1ร— Daily battery report (cellular connection) +- 0-1ร— Security breach (rare) +- 24h continuous sleep mode + +Power Breakdown: +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ Mode โ”‚ Current โ”‚ Duration โ”‚ Daily mAh โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ Sleep (STOP) โ”‚ 130 ฮผA โ”‚ 23h 58m โ”‚ 3.12 mAh โ”‚ +โ”‚ Wake/Process โ”‚ 100 mA โ”‚ 2ร— 15s โ”‚ 0.83 mAh โ”‚ +โ”‚ Cellular Conn โ”‚ 450 mA โ”‚ 1ร— 60s โ”‚ 7.50 mAh โ”‚ +โ”‚ Alarm Active โ”‚ +35 mA โ”‚ 0ร— 10s โ”‚ 0.00 mAh โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ TOTAL DAILY โ”‚ โ”‚ โ”‚ 11.45 mAh โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + +Battery Life Estimates: +- 5000mAh: 5000 รท 11.45 = 437 days (1.2 years) +- 10000mAh: 10000 รท 11.45 = 874 days (2.4 years) +``` + +### Scenario B: High Activity (Security Hotspot) + +``` +Daily Events: +- 1ร— Daily battery report +- 5ร— Security breaches (high activity area) +- 24h continuous sleep mode + +Power Breakdown: +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ Mode โ”‚ Current โ”‚ Duration โ”‚ Daily mAh โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ Sleep (STOP) โ”‚ 130 ฮผA โ”‚ 23h 53m โ”‚ 3.10 mAh โ”‚ +โ”‚ Wake/Process โ”‚ 100 mA โ”‚ 6ร— 15s โ”‚ 2.50 mAh โ”‚ +โ”‚ Cellular Conn โ”‚ 500 mA โ”‚ 6ร— 75s โ”‚ 62.50 mAh โ”‚ +โ”‚ Alarm Active โ”‚ +35 mA โ”‚ 5ร— 10s โ”‚ 0.49 mAh โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ TOTAL DAILY โ”‚ โ”‚ โ”‚ 68.59 mAh โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + +Battery Life Estimates: +- 5000mAh: 5000 รท 68.59 = 73 days (2.4 months) +- 10000mAh: 10000 รท 68.59 = 146 days (4.9 months) +``` + +### Scenario C: Remote Installation with Solar + +``` +Solar Input (6W panel, 5 hours effective sun): +- Peak Power: 6W รท 6V = 1000mA +- Daily Input: 1000mA ร— 5h = 5000 mAh +- Charging Efficiency: ~80% = 4000 mAh net + +Power Balance: +- Daily Consumption: 11.45 mAh (normal operation) +- Daily Solar Input: 4000 mAh +- Net Gain: +3988.55 mAh per day + +Result: Indefinite operation with battery as backup storage +``` + +## ๐Ÿงฎ Battery Life Calculation Methods + +### Method 1: Simple Linear Calculation + +``` +Battery Life (days) = Battery Capacity (mAh) รท Daily Consumption (mAh) + +Example: +5000mAh รท 11.45mAh/day = 437 days = 1.2 years +``` + +### Method 2: Derating for Real-World Conditions + +``` +Practical Battery Life = Theoretical Life ร— Derating Factors + +Derating Factors: +- Temperature: 0.8-1.0 (cold weather reduces capacity) +- Age: 0.9-1.0 (capacity degrades over time) +- Safety Margin: 0.9 (don't discharge to 0%) +- Efficiency: 0.95 (conversion losses) + +Total Derating: 0.8 ร— 0.9 ร— 0.9 ร— 0.95 = 0.62 + +Practical Life = 437 days ร— 0.62 = 271 days (9 months minimum) +``` + +### Method 3: Monte Carlo Simulation + +```python +# Simulation parameters +daily_variations = { + 'sleep_current': (120, 150), # ฮผA range + 'cellular_events': (1, 3), # events per day + 'cellular_duration': (45, 90), # seconds per event + 'cellular_current': (400, 700), # mA range + 'security_events': (0, 2), # breaches per day +} + +# 1000-day simulation results: +# Mean battery life: 1.8 years +# 95% confidence: 1.2 - 2.4 years +# Worst case (5th percentile): 0.9 years +``` + +## ๐Ÿ“ˆ Power Optimization Strategies + +### 1. Sleep Current Minimization + +**Current State: 130 ฮผA** +**Optimization Target: <100 ฮผA** + +```cpp +// Pin configuration optimization +void optimizePowerPins() { + // Configure unused pins as INPUT_PULLDOWN + pinMode(A0, INPUT_PULLDOWN); + pinMode(A1, INPUT_PULLDOWN); + pinMode(A2, INPUT_PULLDOWN); + pinMode(A3, INPUT_PULLDOWN); + pinMode(A4, INPUT_PULLDOWN); + pinMode(A5, INPUT_PULLDOWN); + pinMode(D0, INPUT_PULLDOWN); + pinMode(D1, INPUT_PULLDOWN); + pinMode(D4, INPUT_PULLDOWN); + pinMode(D5, INPUT_PULLDOWN); + pinMode(D6, INPUT_PULLDOWN); + pinMode(D8, INPUT_PULLDOWN); + + // Disable unused peripherals + // Note: Specific peripheral control may vary by device +} + +// Potential savings: 10-20 ฮผA +``` + +### 2. Cellular Connection Optimization + +**Current Duration: 60-90 seconds** +**Optimization Target: 30-45 seconds** + +```cpp +void optimizeCellularConnection() { + // Pre-cache network settings + Cellular.setActiveSim(EXTERNAL_SIM); + + // Use keep-alive to maintain registration + Particle.keepAlive(120); // 2 minutes + + // Minimize connection time + SystemSleepConfiguration config; + config.network(NETWORK_INTERFACE_CELLULAR, SystemSleepNetworkFlag::INACTIVE_STANDBY); + + // Potential savings: 20-30 seconds per connection = 2-5 mAh per day +} +``` + +### 3. Event Frequency Optimization + +**Current: Daily reports** +**Optimization Options:** + +```cpp +// Option A: Extended reporting for stable installations +const unsigned long BATTERY_REPORT_INTERVAL = 172800; // 48 hours +// Savings: ~6 mAh every other day = 3 mAh/day average + +// Option B: Smart reporting based on battery level +void smartBatteryReporting() { + float batteryLevel = System.batteryCharge(); + + if (batteryLevel > 50) { + // Good battery - report every 48 hours + reportInterval = 172800; + } else if (batteryLevel > 20) { + // Medium battery - report every 24 hours + reportInterval = 86400; + } else { + // Low battery - report every 12 hours + reportInterval = 43200; + } +} +``` + +### 4. Alarm Power Optimization + +**Current: Fixed 10-second duration** +**Optimization: Smart duration** + +```cpp +void optimizedAlarmControl() { + // Shorter alarm for minor triggers + if (triggerType == MINOR_DISTURBANCE) { + alarmDuration = 5000; // 5 seconds + } else if (triggerType == MAJOR_BREACH) { + alarmDuration = 15000; // 15 seconds + } + + // Pulse alarm to save power + for (int i = 0; i < alarmDuration / 1000; i++) { + digitalWrite(ALARM_PIN, HIGH); + delay(500); // On for 500ms + digitalWrite(ALARM_PIN, LOW); + delay(500); // Off for 500ms + } + // Power savings: 50% reduction in alarm power +} +``` + +## ๐ŸŒก๏ธ Temperature Effects on Battery Life + +### Capacity vs Temperature + +``` +Temperature Impact on Li-Po Battery Capacity: + + +25ยฐC (77ยฐF): 100% capacity (baseline) + +10ยฐC (50ยฐF): 95% capacity + 0ยฐC (32ยฐF): 90% capacity + -10ยฐC (14ยฐF): 80% capacity + -20ยฐC (-4ยฐF): 60% capacity + +Winter Operation (0ยฐC average): +- Effective capacity: 5000mAh ร— 0.9 = 4500mAh +- Battery life reduction: 10% + +Extreme Cold (-10ยฐC): +- Effective capacity: 5000mAh ร— 0.8 = 4000mAh +- Battery life reduction: 20% +``` + +### Current Draw vs Temperature + +``` +Boron Current Consumption vs Temperature: + + +25ยฐC: 130 ฮผA (baseline) + +10ยฐC: 125 ฮผA (-4%) + 0ยฐC: 135 ฮผA (+4%) + -10ยฐC: 150 ฮผA (+15%) + -20ยฐC: 175 ฮผA (+35%) + +Cold weather increases both quiescent current and reduces battery capacity. +``` + +## โ˜€๏ธ Solar Power Analysis + +### Solar Panel Sizing + +**Minimum Requirements:** +``` +Daily Power Consumption: 11.45 mAh average +Safety Factor: 3ร— (for cloudy days, winter) +Required Daily Generation: 11.45 ร— 3 = 34.35 mAh + +Panel Specifications: +- Voltage: 6V (for 3.7V battery + charge controller) +- Current: 34.35mAh รท 5 hours effective sun = 6.87mA minimum +- Power: 6V ร— 6.87mA = \ No newline at end of file diff --git a/Particle/docs/troubleshooting.md b/Particle/docs/troubleshooting.md new file mode 100644 index 0000000..fae9081 --- /dev/null +++ b/Particle/docs/troubleshooting.md @@ -0,0 +1,1187 @@ +# Particle Boron Security Device Troubleshooting Guide + +Comprehensive troubleshooting guide for diagnosing and resolving common issues with the ultra-low-power security device system. + +## ๐Ÿšจ Quick Diagnostic Checklist + +### Emergency Troubleshooting (Device Not Responding) +``` +โ–ก Check power LED on Boron (should be solid/breathing) +โ–ก Verify battery voltage (>3.0V for operation) +โ–ก Test microswitch manually (should trigger alarm) +โ–ก Check cellular signal strength (>-85dBm preferred) +โ–ก Verify SIM card seating and activation +โ–ก Try safe mode recovery (SETUP+RESET procedure) +``` + +### System Health Indicators +``` +โœ… HEALTHY SYSTEM: +- Status LED: Occasional brief flashes +- Battery reports: Daily via webhook +- Alarm response: <1 second trigger time +- Cellular connection: <60 seconds to connect +- Sleep current: 130ฮผA ยฑ 20ฮผA + +โš ๏ธ WARNING SIGNS: +- No daily battery reports for >48 hours +- Alarm delay >5 seconds +- High power consumption (battery drain) +- Frequent connection failures +- Unexpected device resets + +๐Ÿšจ CRITICAL ISSUES: +- No response to manual testing +- Device constantly resetting +- Power consumption >1mA in sleep +- Complete loss of cellular connectivity +- Mechanical failure of sensors/alarm +``` + +## ๐Ÿ”‹ Power and Battery Issues + +### Problem: High Power Consumption + +**Symptoms:** +- Battery draining faster than expected +- Device feels warm to touch +- Sleep current >200ฮผA + +**Diagnostic Steps:** +```bash +# 1. Measure sleep current +# Expected: 130ฮผA ยฑ 20ฮผA +# Use ฮผCurrent Gold or similar precision meter + +# 2. Check for software issues +particle serial monitor +# Look for continuous output (should be silent in sleep) + +# 3. Verify sleep mode entry +# Device should enter STOP mode within 10 seconds of last activity +``` + +**Common Causes and Solutions:** + +**Serial Interface Left Open:** +```cpp +// โŒ WRONG - Prevents sleep +void setup() { + Serial.begin(9600); // Remove this line! + // rest of setup +} + +// โœ… CORRECT - No serial in production +void setup() { + // Serial.begin(9600); // Commented out + // rest of setup +} +``` + +**Incorrect Pin Configuration:** +```cpp +// โœ… Add to setup() function +void configurePowerOptimalPins() { + // Configure unused pins to prevent floating + pinMode(A0, INPUT_PULLDOWN); + pinMode(A1, INPUT_PULLDOWN); + pinMode(A2, INPUT_PULLDOWN); + pinMode(A3, INPUT_PULLDOWN); + pinMode(A4, INPUT_PULLDOWN); + pinMode(A5, INPUT_PULLDOWN); + pinMode(D0, INPUT_PULLDOWN); + pinMode(D1, INPUT_PULLDOWN); + pinMode(D4, INPUT_PULLDOWN); + pinMode(D5, INPUT_PULLDOWN); + pinMode(D6, INPUT_PULLDOWN); + pinMode(D8, INPUT_PULLDOWN); + + // Keep D2 (sensor), D3 (alarm), D7 (status) as configured +} +``` + +**Stuck in Active Loop:** +```cpp +// โŒ WRONG - Prevents sleep +void loop() { + while (someCondition) { + // Infinite loop prevents sleep + } +} + +// โœ… CORRECT - Always allow sleep +void loop() { + if (someCondition) { + // Handle condition + } + // Loop exits, device can sleep +} +``` + +### Problem: Battery Not Charging (Solar Setup) + +**Symptoms:** +- Battery level decreasing despite solar panel +- Charge controller not showing charging status + +**Diagnostic Steps:** +```bash +# 1. Check solar panel voltage +# Expected: 6V+ in direct sunlight +multimeter across panel terminals + +# 2. Check charge controller input/output +# Input: Should match panel voltage +# Output: Should be 4.1-4.2V when charging + +# 3. Check battery connection +# Ensure JST connector properly seated +# Verify polarity (red=+, black=-) +``` + +**Solutions:** +- Clean solar panel surface +- Check all connections for corrosion +- Verify charge controller wiring +- Test battery capacity with external charger + +### Problem: Inaccurate Battery Readings + +**Symptoms:** +- Battery percentage jumps unexpectedly +- Reports 0% or >100% charge + +**Solution:** +```cpp +// Add battery reading validation +float getValidBatteryLevel() { + float reading = System.batteryCharge(); + + // Filter obviously invalid readings + if (reading < 0 || reading > 100) { + return lastValidReading; // Use previous value + } + + // Filter large jumps (>20% change) + if (abs(reading - lastValidReading) > 20) { + return lastValidReading; // Reject sudden changes + } + + lastValidReading = reading; + return reading; +} +``` + +## ๐Ÿ“ก Cellular and Connectivity Issues + +### Problem: Device Won't Connect to Cellular + +**Symptoms:** +- No daily battery reports received +- Events show "Connection timeout" in logs +- Cellular LED patterns indicate no connection + +**Diagnostic Steps:** + +**Check Signal Strength:** +```bash +# Use Particle CLI to check signal +particle get YOUR_DEVICE_ID signal + +# Expected values: +# >-70dBm: Excellent +# -70 to -85dBm: Good +# -85 to -100dBm: Fair +# <-100dBm: Poor (may not connect) +``` + +**Check SIM Card Status:** +```bash +# Verify SIM is active +particle sim list + +# Check data usage +particle sim usage YOUR_SIM_ID +``` + +**Test Manual Connection:** +```cpp +// Add to device code for testing +void testCellularConnection() { + Serial.begin(9600); + Serial.println("Testing cellular connection..."); + + Cellular.on(); + Serial.println("Cellular radio on"); + + waitFor(Cellular.ready, 60000); + if (Cellular.ready()) { + Serial.println("Cellular ready"); + + CellularSignal signal = Cellular.RSSI(); + Serial.printf("Signal: %d dBm\n", signal.getStrength()); + Serial.printf("Quality: %d\n", signal.getQuality()); + } else { + Serial.println("Cellular failed to connect"); + } +} +``` + +**Common Solutions:** + +**Poor Signal Strength:** +- Relocate device to higher position +- Install external cellular antenna +- Use cellular signal booster +- Switch to different carrier if available + +**SIM Card Issues:** +- Reseat SIM card in holder +- Check SIM activation status +- Verify data plan is active +- Replace SIM if damaged + +**Network Configuration:** +```cpp +// Force specific network settings if needed +void setNetworkParameters() { + // Set APN if required by carrier + Cellular.setActiveSim(EXTERNAL_SIM); + + // Set specific bands if needed + // Cellular.setBandSelect("..."); +} +``` + +### Problem: Slow Cellular Connections + +**Symptoms:** +- Connection takes >2 minutes +- High power consumption during connection +- Timeouts during data transfer + +**Solutions:** + +**Optimize Connection Sequence:** +```cpp +bool fastCellularConnect() { + unsigned long start = millis(); + + // Enable cellular with timeout + Cellular.on(); + if (!waitFor(Cellular.ready, 30000)) { + Serial.println("Cellular radio timeout"); + return false; + } + + // Connect to Particle cloud with timeout + Particle.connect(); + if (!waitFor(Particle.connected, 60000)) { + Serial.println("Cloud connection timeout"); + return false; + } + + Serial.printf("Connected in %lu seconds\n", (millis() - start) / 1000); + return true; +} +``` + +**Use Connection Keep-Alive:** +```cpp +void setup() { + // Maintain network registration between sleeps + Particle.keepAlive(120); // 2 minutes +} +``` + +### Problem: Data Usage Higher Than Expected + +**Symptoms:** +- Monthly data usage >10MB +- Carrier data overage charges +- Frequent connection events + +**Analysis:** +```bash +# Check Particle data usage +particle sim usage YOUR_SIM_ID + +# Review webhook frequency +# Should be 1-2 events per day normally +``` + +**Solutions:** + +**Reduce Message Size:** +```cpp +// Compact data format +String createCompactAlert() { + // Before: "Type:SECURITY_BREACH|Description:Motion detected|Battery:85.2%|Signal:-45dBm" + // After: "T:BREACH|D:Motion|B:85|S:-45" + + return String::format("T:%s|D:%s|B:%d|S:%d", + getAlertTypeCode(), + getShortDescription(), + (int)System.batteryCharge(), + Cellular.RSSI().getStrength() + ); +} +``` + +**Batch Multiple Events:** +```cpp +void batchEventReporting() { + static String eventBuffer = ""; + + eventBuffer += createEventData() + ";"; + + // Send when buffer reaches size limit or time limit + if (eventBuffer.length() > 200 || shouldSendBatch()) { + Particle.publish("Batch_Events", eventBuffer, PRIVATE); + eventBuffer = ""; + } +} +``` + +## ๐Ÿ”ง Hardware Issues + +### Problem: Microswitch Not Triggering + +**Symptoms:** +- No alarm when switch is manually opened +- Security breaches not detected +- Switch reads same value regardless of position + +**Diagnostic Steps:** + +**Test Switch Continuity:** +```bash +# Use multimeter to test switch +# Closed position: 0ฮฉ resistance +# Open position: โˆžฮฉ (no continuity) +``` + +**Test Boron Input:** +```cpp +// Add diagnostic code +void testMicroswitchInput() { + Serial.begin(9600); + + while (true) { + bool switchState = digitalRead(MICROSWITCH_PIN); + Serial.printf("Switch state: %s\n", switchState ? "CLOSED" : "OPEN"); + delay(500); + } +} +``` + +**Common Issues and Solutions:** + +**Wiring Error:** +``` +โœ… CORRECT NC WIRING: +Microswitch Common โ†’ D2 (Boron) +Microswitch NC โ†’ GND (Boron) + +โŒ INCORRECT (NO/Normal Open): +Microswitch Common โ†’ D2 (Boron) +Microswitch NO โ†’ GND (Boron) +``` + +**Mechanical Issues:** +- Check switch mounting alignment +- Verify actuator travel distance +- Lubricate switch if sticky +- Replace switch if worn out + +**Electrical Issues:** +- Check for loose connections +- Verify wire gauge (22-18 AWG recommended) +- Test for electrical noise/interference +- Add hardware debouncing if needed + +### Problem: Alarm Not Activating + +**Symptoms:** +- Switch triggers detected but no alarm sound +- Alarm device doesn't activate +- D3 pin voltage incorrect + +**Diagnostic Steps:** + +**Test GPIO Output:** +```cpp +void testAlarmOutput() { + Serial.begin(9600); + + Serial.println("Testing alarm output..."); + + // Test D3 voltage + digitalWrite(ALARM_PIN, HIGH); + Serial.println("D3 should be 3.3V - measure with multimeter"); + delay(5000); + + digitalWrite(ALARM_PIN, LOW); + Serial.println("D3 should be 0V - measure with multimeter"); + delay(5000); +} +``` + +**Check Driver Circuit:** +``` +For transistor driver circuit: +1. Measure base voltage (should be 3.3V when D3=HIGH) +2. Check transistor collector voltage (should be ~0V when ON) +3. Verify alarm device voltage across terminals +4. Test transistor with known good component +``` + +**Common Solutions:** + +**Driver Circuit Issues:** +``` +Component Checklist: +โ–ก 2N2222 transistor (or equivalent NPN) +โ–ก 1kฮฉ base resistor +โ–ก Proper ground connections +โ–ก Adequate current rating for alarm device + +Voltage Tests: +โ–ก D3 output: 0V (LOW) / 3.3V (HIGH) +โ–ก Base voltage: 0V (OFF) / 3.3V (ON) +โ–ก Collector: VIN (OFF) / ~0V (ON) +โ–ก Emitter: Always 0V (GND) +``` + +**Alarm Device Issues:** +- Check power requirements vs available current +- Verify voltage compatibility +- Test alarm device independently +- Check for blown fuse in alarm circuit + +### Problem: Status LED Behavior Issues + +**Symptoms:** +- LED constantly on/off +- Unexpected flash patterns +- LED not responding to events + +**Normal LED Patterns:** +``` +Startup: 3 slow blinks (500ms each) +Security Breach: 5 rapid blinks (100ms each) +Daily Report: 2 medium blinks (200ms each) +Cellular Connect: Alternating during connection +Success: 2 quick blinks (100ms each) +Error: 10 rapid blinks (50ms each) +``` + +**Diagnostic Code:** +```cpp +void testStatusLED() { + Serial.begin(9600); + Serial.println("Testing status LED patterns..."); + + // Test each pattern + flashStatusLED(3, 500); // Startup pattern + delay(2000); + flashStatusLED(5, 100); // Breach pattern + delay(2000); + flashStatusLED(2, 200); // Report pattern +} +``` + +## ๐ŸŒ Webhook and Server Issues + +### Problem: Webhook Not Receiving Events + +**Symptoms:** +- Particle Console shows events published +- No notifications received +- Webhook service logs show no activity + +**Diagnostic Steps:** + +**Test Particle Event Publishing:** +```bash +# Check if device is publishing events +particle subscribe YOUR_DEVICE_ID + +# Manually trigger test event +particle publish "Security Alert" "Type:TEST|Desc:Manual test" --private +``` + +**Test Webhook Endpoint:** +```bash +# Test webhook health +curl https://webhook.yourdomain.com/health + +# Test webhook with manual POST +curl -X POST https://webhook.yourdomain.com/webhook \ + -H "Content-Type: application/json" \ + -H "User-Agent: ParticleBot/1.0" \ + -H "Authorization: Bearer YOUR_PARTICLE_SECRET" \ + -d '{"event":"Security Alert","data":"Type:TEST|Desc:Manual webhook test","published_at":"2024-01-07T12:00:00Z","coreid":"test","device_name":"Test Device"}' +``` + +**Check Webhook Configuration:** + +**Particle Console Webhook Settings:** +```json +{ + "event": "Security Alert", + "url": "https://webhook.yourdomain.com/webhook", + "headers": { + "Authorization": "Bearer YOUR_SECRET_HERE", + "Content-Type": "application/json", + "User-Agent": "ParticleBot/1.0" + } +} +``` + +**Common Solutions:** + +**Authentication Issues:** +```bash +# Verify webhook secret matches +docker exec webhook-service env | grep PARTICLE_WEBHOOK_SECRET + +# Check webhook service logs +docker compose logs webhook-service | grep -i auth +``` + +**SSL/TLS Issues:** +```bash +# Test SSL certificate +openssl s_client -connect webhook.yourdomain.com:443 + +# Check certificate expiration +curl -vI https://webhook.yourdomain.com/health +``` + +**Network Connectivity:** +```bash +# Test from external network +curl -I https://webhook.yourdomain.com/health + +# Check DNS resolution +nslookup webhook.yourdomain.com +``` + +### Problem: Notifications Not Being Sent + +**Symptoms:** +- Webhook receives events successfully +- No email/SMS notifications received +- Webhook logs show email errors + +**Diagnostic Steps:** + +**Test SMTP Configuration:** +```bash +# Test Gmail SMTP from webhook container +docker exec webhook-service python3 -c " +import smtplib +import os +try: + with smtplib.SMTP_SSL('smtp.gmail.com', 465) as server: + server.login(os.environ['SMTP_EMAIL'], os.environ['SMTP_PASSWORD']) + print('SMTP connection successful') +except Exception as e: + print(f'SMTP error: {e}') +" +``` + +**Common Solutions:** + +**Gmail Authentication Issues:** +``` +Common Problems: +โ–ก Using regular password instead of app password +โ–ก App password contains spaces (remove them) +โ–ก 2FA not enabled on Google account +โ–ก App password expired or revoked + +Solution: +1. Enable 2FA on Google account +2. Generate new app password at https://myaccount.google.com/apppasswords +3. Use 16-character app password (no spaces) +4. Update .env file with new password +``` + +**SMS Gateway Issues:** +``` +Common Carrier Gateways: +โ–ก Verizon: number@vtext.com +โ–ก AT&T: number@txt.att.net +โ–ก T-Mobile: number@tmomail.net +โ–ก Sprint: number@messaging.sprintpcs.com + +Test SMS Gateway: +1. Send test email to your SMS gateway address +2. Verify format: 10-digit number (no dashes/spaces) +3. Check carrier-specific limitations +``` + +## ๐Ÿ”„ Device Reset and Recovery + +### Safe Mode Recovery + +**When to Use:** +- Device constantly resetting +- Firmware appears corrupted +- Device not responding to OTA updates + +**Procedure:** +```bash +# Enter safe mode +1. Hold SETUP button +2. Press and release RESET button (while holding SETUP) +3. Continue holding SETUP until LED breathes magenta +4. Release SETUP button + +# Device is now in safe mode (breathing magenta) +# Flash firmware via CLI +particle flash YOUR_DEVICE_ID security_device.ino --target 5.8.0 +``` + +### DFU Mode Recovery + +**When to Use:** +- Safe mode doesn't work +- Device completely unresponsive +- Need to flash system firmware + +**Procedure:** +```bash +# Enter DFU mode +1. Hold SETUP and RESET buttons +2. Release RESET while continuing to hold SETUP +3. Wait for LED to blink yellow rapidly +4. Release SETUP button + +# Device is now in DFU mode (yellow blinking) +# Flash tinker firmware to reset +particle flash --usb tinker + +# Then flash your application +particle flash YOUR_DEVICE_ID security_device.ino +``` + +### Factory Reset + +**Complete Device Reset:** +```bash +# Clear all user firmware and data +particle device doctor YOUR_DEVICE_ID + +# This will: +# - Reset device keys +# - Clear user firmware +# - Reset to factory state +# - Require device re-claiming +``` + +## ๐Ÿ” Advanced Diagnostics + +### Real-Time Monitoring Setup + +**Hardware Debug Setup:** +``` +Equipment Needed: +โ–ก Logic analyzer or oscilloscope +โ–ก ฮผCurrent Gold (current measurement) +โ–ก Multimeter +โ–ก USB-to-serial adapter +โ–ก Jumper wires and test probes + +Monitoring Points: +โ–ก VIN: Power supply voltage +โ–ก D2: Microswitch state changes +โ–ก D3: Alarm output signal +โ–ก D7: Status LED activity +โ–ก TX/RX: Serial debug output (if enabled) +``` + +**Software Debug Mode:** +```cpp +// Enable comprehensive debugging (REMOVE in production) +#define DEBUG_MODE +#ifdef DEBUG_MODE + +void debugLog(String component, String message) { + String timestamp = String(millis()); + Serial.println(timestamp + " [" + component + "] " + message); +} + +void debugSystemState() { + debugLog("POWER", "Battery: " + String(System.batteryCharge()) + "%"); + debugLog("NETWORK", "Signal: " + String(Cellular.RSSI().getStrength()) + "dBm"); + debugLog("GPIO", "D2: " + String(digitalRead(D2)) + ", D3: " + String(digitalRead(D3))); + debugLog("MEMORY", "Free RAM: " + String(System.freeMemory()) + " bytes"); + debugLog("SYSTEM", "Uptime: " + String(millis() / 1000) + " seconds"); +} + +#else +#define debugLog(component, message) +#define debugSystemState() +#endif +``` + +### Performance Profiling + +**Power Consumption Profiling:** +```cpp +void profilePowerConsumption() { + unsigned long start, duration; + + // Profile cellular connection + start = millis(); + Cellular.on(); + waitFor(Cellular.ready, 60000); + duration = millis() - start; + debugLog("PROFILE", "Cellular ready: " + String(duration) + "ms"); + + // Profile cloud connection + start = millis(); + Particle.connect(); + waitFor(Particle.connected, 60000); + duration = millis() - start; + debugLog("PROFILE", "Cloud connected: " + String(duration) + "ms"); + + // Profile event publishing + start = millis(); + Particle.publish("Test", "data", PRIVATE); + duration = millis() - start; + debugLog("PROFILE", "Event published: " + String(duration) + "ms"); +} +``` + +**Memory Usage Monitoring:** +```cpp +void monitorMemoryUsage() { + static unsigned long lastCheck = 0; + static int minFreeMemory = 999999; + + if (millis() - lastCheck > 10000) { // Check every 10 seconds + int freeMemory = System.freeMemory(); + if (freeMemory < minFreeMemory) { + minFreeMemory = freeMemory; + } + + debugLog("MEMORY", "Free: " + String(freeMemory) + + ", Min: " + String(minFreeMemory) + " bytes"); + lastCheck = millis(); + } +} +``` + +### Log Analysis and Pattern Detection + +**Event Pattern Analysis:** +```python +# Python script to analyze webhook logs +import re +import json +from datetime import datetime +from collections import defaultdict + +def analyze_webhook_logs(log_file): + events = defaultdict(list) + power_data = [] + + with open(log_file, 'r') as f: + for line in f: + # Parse timestamp and event type + if 'Received webhook:' in line: + timestamp = extract_timestamp(line) + event_data = extract_event_data(line) + events[event_data['type']].append(timestamp) + + if 'Batt:' in line: + battery = extract_battery_level(line) + power_data.append((timestamp, battery)) + + # Analyze patterns + print(f"Security breaches: {len(events['SECURITY_BREACH'])}") + print(f"Daily reports: {len(events['DAILY_BATTERY_REPORT'])}") + print(f"Average time between breaches: {calculate_average_interval(events['SECURITY_BREACH'])}") + + # Battery trend analysis + if len(power_data) > 10: + battery_trend = calculate_battery_trend(power_data) + print(f"Battery drain rate: {battery_trend:.2f}% per day") + +def extract_battery_level(line): + match = re.search(r'Batt:(\d+\.?\d*)%', line) + return float(match.group(1)) if match else None + +# Usage: python analyze_logs.py webhook.log +``` + +### Network Diagnostics + +**Cellular Network Analysis:** +```cpp +void analyzeCellularNetwork() { + CellularSignal signal = Cellular.RSSI(); + CellularData data = Cellular.getDataUsage(); + + debugLog("CELLULAR", "Provider: " + Cellular.getOperator()); + debugLog("CELLULAR", "Technology: " + String(Cellular.getTechnology())); + debugLog("CELLULAR", "Signal Strength: " + String(signal.getStrength()) + " dBm"); + debugLog("CELLULAR", "Signal Quality: " + String(signal.getQuality())); + debugLog("CELLULAR", "Data Used: " + String(data.tx_session + data.rx_session) + " bytes"); + + // Test connection speed + unsigned long start = millis(); + if (Particle.publish("Speed_Test", "test", PRIVATE)) { + unsigned long latency = millis() - start; + debugLog("CELLULAR", "Publish latency: " + String(latency) + "ms"); + } +} +``` + +**DNS and Connectivity Testing:** +```cpp +void testConnectivity() { + // Test different endpoints + String endpoints[] = { + "api.particle.io", + "device.spark.io", + "google.com", + "webhook.yourdomain.com" + }; + + for (String endpoint : endpoints) { + unsigned long start = millis(); + TCPClient client; + + if (client.connect(endpoint, 80)) { + unsigned long connectionTime = millis() - start; + debugLog("CONNECTIVITY", endpoint + " connected in " + String(connectionTime) + "ms"); + client.stop(); + } else { + debugLog("CONNECTIVITY", endpoint + " connection failed"); + } + } +} +``` + +## ๐Ÿ“Š Preventive Maintenance + +### Weekly Automated Checks + +**Device Self-Test Routine:** +```cpp +bool performWeeklyHealthCheck() { + bool allTestsPassed = true; + + // Test 1: Battery level check + float battery = System.batteryCharge(); + if (battery < 20.0) { + publishAlert("MAINTENANCE", "Low battery: " + String(battery) + "%"); + allTestsPassed = false; + } + + // Test 2: Cellular signal strength + int signal = Cellular.RSSI().getStrength(); + if (signal < -90) { + publishAlert("MAINTENANCE", "Weak signal: " + String(signal) + "dBm"); + allTestsPassed = false; + } + + // Test 3: Memory usage check + int freeMemory = System.freeMemory(); + if (freeMemory < 10000) { + publishAlert("MAINTENANCE", "Low memory: " + String(freeMemory) + " bytes"); + allTestsPassed = false; + } + + // Test 4: Switch operation test + bool switchState = digitalRead(MICROSWITCH_PIN); + // Record for trend analysis + + // Test 5: Alarm circuit test (brief pulse) + digitalWrite(ALARM_PIN, HIGH); + delay(100); + digitalWrite(ALARM_PIN, LOW); + + if (allTestsPassed) { + publishAlert("MAINTENANCE", "Weekly health check: PASS"); + } + + return allTestsPassed; +} +``` + +### Monthly Maintenance Tasks + +**Automated Maintenance Reports:** +```python +# Server-side maintenance analysis +def generate_monthly_report(device_id, start_date, end_date): + """Generate comprehensive device health report""" + + events = fetch_device_events(device_id, start_date, end_date) + + report = { + 'device_id': device_id, + 'period': f"{start_date} to {end_date}", + 'statistics': analyze_device_statistics(events), + 'battery_health': analyze_battery_trend(events), + 'connectivity': analyze_connectivity_stats(events), + 'security_events': count_security_events(events), + 'maintenance_needed': identify_maintenance_needs(events), + 'recommendations': generate_recommendations(events) + } + + return report + +def identify_maintenance_needs(events): + """Identify potential maintenance requirements""" + needs = [] + + # Check battery degradation + battery_trend = calculate_battery_trend(events) + if battery_trend > 2.0: # >2% per day indicates issues + needs.append("Battery replacement recommended") + + # Check false alarm rate + false_alarm_rate = calculate_false_alarm_rate(events) + if false_alarm_rate > 0.1: # >10% false alarms + needs.append("Sensor calibration needed") + + # Check connectivity issues + connection_success_rate = calculate_connection_success_rate(events) + if connection_success_rate < 0.95: # <95% success + needs.append("Cellular antenna check recommended") + + return needs +``` + +### Predictive Maintenance + +**Early Warning System:** +```cpp +void predictiveMaintenance() { + static float batteryHistory[30]; // 30-day history + static int historyIndex = 0; + static bool historyFull = false; + + // Record daily battery level + float currentBattery = System.batteryCharge(); + batteryHistory[historyIndex] = currentBattery; + historyIndex = (historyIndex + 1) % 30; + if (historyIndex == 0) historyFull = true; + + if (historyFull) { + // Calculate battery drain trend + float trend = calculateLinearTrend(batteryHistory, 30); + + // Predict battery life remaining + float daysRemaining = currentBattery / abs(trend); + + if (daysRemaining < 90) { // Less than 3 months + publishAlert("PREDICTIVE", "Battery replacement needed in " + + String((int)daysRemaining) + " days"); + } + } +} + +float calculateLinearTrend(float data[], int length) { + // Simple linear regression to find trend + float sumX = 0, sumY = 0, sumXY = 0, sumX2 = 0; + + for (int i = 0; i < length; i++) { + sumX += i; + sumY += data[i]; + sumXY += i * data[i]; + sumX2 += i * i; + } + + float slope = (length * sumXY - sumX * sumY) / (length * sumX2 - sumX * sumX); + return slope; // % per day +} +``` + +## ๐Ÿ”ง Field Repair Procedures + +### Emergency Field Diagnostics + +**Minimal Equipment Diagnostics:** +``` +Required Tools: +โ–ก Multimeter +โ–ก Small screwdriver set +โ–ก Spare battery (charged) +โ–ก Mobile phone with Particle app + +Quick Tests (5 minutes): +1. Check battery voltage (>3.0V) +2. Test microswitch continuity +3. Verify alarm device operation +4. Check cellular signal strength via Particle app +5. Attempt manual event trigger +``` + +**Field Diagnostic Checklist:** +``` +โ–ก Visual inspection for physical damage +โ–ก Check all wire connections for looseness +โ–ก Verify enclosure seal integrity +โ–ก Test battery voltage under load +โ–ก Check for signs of water ingress +โ–ก Verify antenna connections (if external) +โ–ก Test switch mechanical operation +โ–ก Check for insect/rodent interference +``` + +### Remote Diagnostic Commands + +**Emergency Remote Access:** +```bash +# Check device vitals +particle get YOUR_DEVICE_ID vitals + +# Force connection test +particle function call YOUR_DEVICE_ID testConnection + +# Get detailed diagnostics +particle function call YOUR_DEVICE_ID systemDiagnostics + +# Force immediate battery report +particle function call YOUR_DEVICE_ID forceBatteryReport +``` + +**Remote Recovery Commands:** +```bash +# Safe restart +particle function call YOUR_DEVICE_ID safeRestart + +# Force sleep mode +particle function call YOUR_DEVICE_ID forceSleep + +# Emergency OTA update +particle flash YOUR_DEVICE_ID firmware_recovery.ino + +# Factory reset (last resort) +particle device doctor YOUR_DEVICE_ID +``` + +## ๐Ÿ“‹ Troubleshooting Decision Tree + +``` +Device Issue Reported + โ”‚ + โ–ผ + Is device responsive? + โ”Œโ”€NOโ”€โ” โ”Œโ”€YESโ”€โ” + โ”‚ โ”‚ โ”‚ โ”‚ + โ–ผ โ”‚ โ–ผ โ”‚ +Power Check Check specific symptom + โ”‚ โ”‚ โ”‚ โ”‚ + โ”‚ โ”‚ โ–ผ โ”‚ + โ”‚ โ”‚ Network Issue? + โ”‚ โ”‚ โ”Œโ”€YESโ”€โ” โ”Œโ”€NOโ”€โ” + โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ + โ”‚ โ”‚ โ–ผ โ”‚ โ–ผ โ”‚ + โ”‚ โ”‚ Cellular โ”‚Hardwareโ”‚ + โ”‚ โ”‚Diagnosticโ”‚ Check โ”‚ + โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ + โ”‚ โ”‚ โ–ผ โ”‚ โ–ผ โ”‚ + โ”‚ โ”‚ Signal โ”‚Sensor โ”‚ + โ”‚ โ”‚ Test โ”‚ Test โ”‚ + โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ + โ–ผ โ–ผ โ–ผ โ–ผ โ–ผ โ–ผ + Replace Check Fix Test Replace + Battery Power Network Switch Component + โ”‚ Supply โ”‚ โ”‚ โ”‚ + โ–ผ โ”‚ โ–ผ โ–ผ โ–ผ + Test โ”‚ Restart Reset Test + Device โ–ผ Device System Function + โ”‚ Replace โ”‚ โ”‚ โ”‚ + โ–ผ Hardware โ–ผ โ–ผ โ–ผ + Functional? Works? Works? Works? + โ”‚ โ”‚ โ”‚ โ”‚ + โ–ผ โ–ผ โ–ผ โ–ผ + SUCCESS SUCCESS SUCCESS SUCCESS +``` + +## ๐Ÿ“ž Support Escalation + +### When to Escalate + +**Level 1: Self-Service (User)** +- Basic connectivity issues +- Simple configuration changes +- Battery replacement +- Environmental factors + +**Level 2: Technical Support** +- Persistent connectivity issues +- Hardware component failures +- Firmware corruption +- Complex network problems + +**Level 3: Engineering Support** +- Design modifications needed +- Systematic reliability issues +- Performance optimization +- Custom firmware requirements + +### Information to Gather Before Escalation + +**Device Information:** +``` +โ–ก Device ID and name +โ–ก Firmware version +โ–ก Hardware revision +โ–ก SIM card ID +โ–ก Installation date +โ–ก Last known working state +โ–ก Environmental conditions +``` + +**Issue Documentation:** +``` +โ–ก Detailed symptom description +โ–ก Frequency of occurrence +โ–ก Steps already attempted +โ–ก Error messages observed +โ–ก Timeline of events +โ–ก Impact on operations +``` + +**Diagnostic Data:** +``` +โ–ก Power consumption measurements +โ–ก Signal strength readings +โ–ก Event logs from webhook +โ–ก Photos of hardware setup +โ–ก Particle Console screenshots +โ–ก Network configuration details +``` + +--- + +**๐Ÿ” Quick Reference Summary:** + +**Emergency Contacts:** +- Device Issues: Check Particle Community Forum +- Server Issues: Check webhook service logs +- Hardware Issues: Consult wiring diagrams +- Network Issues: Test with Particle CLI + +**Most Common Issues:** +1. High power consumption โ†’ Check for Serial.begin() in code +2. No cellular connection โ†’ Check signal strength and SIM status +3. Switch not triggering โ†’ Verify NC wiring configuration +4. No notifications โ†’ Check webhook authentication +5. Device not sleeping โ†’ Remove debug code and configure pins + +**Recovery Procedures:** +1. Safe mode: SETUP+RESET โ†’ breathing magenta +2. DFU mode: SETUP+RESET โ†’ yellow blinking +3. Factory reset: particle device doctor +4. OTA recovery: particle flash via CLI \ No newline at end of file diff --git a/Particle/hardware/wiring-diagram.md b/Particle/hardware/wiring-diagram.md new file mode 100644 index 0000000..f593f08 --- /dev/null +++ b/Particle/hardware/wiring-diagram.md @@ -0,0 +1,322 @@ +# Boron LTE Security Device Wiring Diagram + +## Complete System Wiring + +``` + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ PARTICLE BORON LTE โ”‚ + โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ โ”‚ 3V3 โ”‚ โ”‚ RST โ”‚ โ”‚VBAT โ”‚ โ”‚ GND โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ + โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ โ”‚ A0 โ”‚ โ”‚ A1 โ”‚ โ”‚ A2 โ”‚ โ”‚ A3 โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ + โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ โ”‚ A4 โ”‚ โ”‚ A5 โ”‚ โ”‚ SCK โ”‚ โ”‚MISO โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ + โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ โ”‚MOSI โ”‚ โ”‚ D8 โ”‚ โ”‚ D7 โ”‚ โ”‚ D6 โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ + โ”‚ โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ โ”‚ D5 โ”‚ โ”‚ D4 โ”‚ โ”‚ D3 โ”‚ โ”‚ D2 โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜ โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜ โ”‚ + โ”‚ โ”‚ โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ โ”‚ D1 โ”‚ โ”‚ D0 โ”‚ โ”‚ TX โ”‚ โ”‚ RX โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ + โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ โ”‚ GND โ”‚ โ”‚ GND โ”‚ โ”‚ VIN โ”‚ โ”‚ EN โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ โ”‚ + โ”‚ โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ โ”‚ โ”‚ โ”‚ + โ”‚ โ”‚ โ”‚ โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ” โ”Œโ”€โ–ผโ”€โ” โ”Œโ”€โ–ผโ”€โ” โ”Œโ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ MICROSWITCHโ”‚ โ”‚GNDโ”‚ โ”‚VINโ”‚ โ”‚ LI-PO โ”‚ + โ”‚ NC โ”‚ โ””โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”˜ โ”‚ BATTERY โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”โ”‚ โ”‚ โ”‚ + โ”‚ โ”‚COMโ”‚ โ”‚ NCโ”‚โ”‚ โ”‚ 3.7V โ”‚ + โ”‚ โ””โ”€โ”ฌโ”€โ”˜ โ””โ”€โ”ฌโ”€โ”˜โ”‚ โ”‚ 5000mAh+ โ”‚ + โ””โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ โ”‚ + โ”‚ โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ D2 โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚(INPUT) โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ ALARM CIRCUIT โ”‚ + โ”‚ โ”‚ + โ”‚ D3 โ”€โ”€โ”ฌโ”€โ”€ 1kฮฉ โ”€โ”€โ”ฌโ”€โ”€ BASE โ”‚ + โ”‚ โ”‚ โ”‚ (2N2222) โ”‚ + โ”‚ GND โ”Œโ–ผโ” โ”‚ + โ”‚ โ”‚ โ”‚ โ”‚ + โ”‚ โ”‚โ–ผโ”‚ โ”‚ + โ”‚ โ””โ”ฌโ”˜ โ”‚ + โ”‚ โ”‚ โ”‚ + โ”‚ โ”‚ EMITTER โ”‚ + โ”‚ โ”‚ โ”‚ + โ”‚ GND โ”‚ + โ”‚ โ”‚ + โ”‚ โ”‚ COLLECTOR โ”‚ + โ”‚ โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ โ”‚ SIREN โ”‚ โ”‚ + โ”‚ โ”‚ 12V โ”‚ โ”‚ + โ”‚ โ”‚ 2A MAX โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ + โ”‚ โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ โ”‚ VIN โ”‚ โ”‚ + โ”‚ โ”‚ (3.7-12V)โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ OPTIONAL SOLAR โ”‚ + โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ โ”‚ SOLAR PANEL โ”‚ โ”‚ + โ”‚ โ”‚ 6V 1W+ โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ + โ”‚ โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ + โ”‚ โ”‚ CHARGE CONTROLLER โ”‚ โ”‚ + โ”‚ โ”‚ (SparkFun Sunny โ”‚ โ”‚ + โ”‚ โ”‚ Buddy) โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ + โ”‚ โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ LI-PO โ”‚ + โ”‚ BATTERY โ”‚ + โ”‚ + JST โ”‚ + โ”‚ CONNECTOR โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + +## Pin Connections Summary + +| Component | Boron Pin | Connection Type | Notes | +|-----------|-----------|-----------------|-------| +| **Microswitch Common** | D2 | Digital Input (Pullup) | NC switch configuration | +| **Microswitch NC** | GND | Ground | Normally closed contact | +| **Alarm Control** | D3 | Digital Output | Controls transistor base | +| **Status LED** | D7 | Built-in | On-board LED | +| **Battery Positive** | VIN | Power Input | 3.7V Li-Po nominal | +| **Battery Negative** | GND | Ground | Common ground | + +## Microswitch Detail + +``` + MICROSWITCH (NC - Normally Closed) + + Normal State (Secured): + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ โ”‚ โ— โ”‚ โ† Actuator pressed + โ”‚ โ”€โ”€โ”ผโ”€โ”€โ”€ โ”‚ + โ”‚ COM โ”‚ NC โ”‚ + โ”‚ โ— โ”‚ โ— โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”˜ + โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€ GND (Boron) โ”€โ”€โ” + โ”‚ โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€ D2 (Boron) โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€ CLOSED CIRCUIT + โ”‚ D2 = HIGH (3.3V) + โ”Œโ–ผโ” + โ”‚ โ”‚ 10kฮฉ internal pullup + โ”‚โ–ผโ”‚ + โ””โ”ฌโ”˜ + โ”‚ + 3V3 + + Breach State (Triggered): + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ โ— โ”‚ โ† Actuator released + โ”‚ โ”‚ + โ”‚ COM NC โ”‚ + โ”‚ โ— โ— โ”‚ โ† OPEN CONTACTS + โ””โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”˜ + โ”‚ โ”‚ + โ”‚ โ””โ”€โ”€โ”€ GND (Boron) โ”€โ”€โ” + โ”‚ โ”‚ + โ””โ”€โ”€โ”€โ”€ D2 (Boron) โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€ OPEN CIRCUIT + โ”‚ D2 = LOW (0V via GND) + โ”Œโ–ผโ” + โ”‚ โ”‚ Current flows to GND + โ”‚โ–ผโ”‚ + โ””โ”ฌโ”˜ + โ”‚ + GND +``` + +## Alarm Driver Circuit Detail + +``` + TRANSISTOR ALARM DRIVER (NPN 2N2222) + + Alarm OFF (D3 = LOW): + + D3 โ”€โ”€โ”ฌโ”€โ”€ 1kฮฉ โ”€โ”€โ”ฌโ”€โ”€ BASE = 0V + โ”‚ โ”‚ + GND โ”Œโ–ผโ” No base current + โ”‚ โ”‚ Transistor OFF + โ”‚โ–ผโ”‚ + โ””โ”ฌโ”˜ + โ”‚ + GND EMITTER = 0V + + โ”‚ COLLECTOR = Floating + โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ” + โ”‚ SIREN โ”‚ โ† No current flow + โ”‚ OFF โ”‚ SIREN = OFF + โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ + VIN (Battery voltage) + + Alarm ON (D3 = HIGH): + + D3 โ”€โ”€โ”ฌโ”€โ”€ 1kฮฉ โ”€โ”€โ”ฌโ”€โ”€ BASE = 3.3V + โ”‚ โ”‚ + GND โ”Œโ–ผโ” Base current flows + โ”‚ โ”‚ Transistor ON + โ”‚โ–ผโ”‚ + โ””โ”ฌโ”˜ + โ”‚ + GND EMITTER = 0V + + โ”‚ COLLECTOR = ~0V (saturated) + โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ” + โ”‚ SIREN โ”‚ โ† Current flows VINโ†’Sirenโ†’Collector + โ”‚ ON โ”‚ SIREN = ON (Full battery voltage) + โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ + VIN (Battery voltage) +``` + +## Power Distribution + +``` + POWER SYSTEM ARCHITECTURE + + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ SOLAR PANEL โ”‚ โ”‚ LI-PO BATTERY โ”‚ + โ”‚ 6V 1W โ”‚ โ”‚ 3.7V โ”‚ + โ”‚ โ”‚ โ”‚ 5000-10000mAh โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ โ”‚ + โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค CHARGE CONTROLLERโ”œโ”€โ”€โ”€ OPTIONAL + โ”‚ (Sunny Buddy) โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ BATTERY OUTPUT โ”‚ + โ”‚ (JST Connector) โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ BORON VIN/GND โ”‚ + โ”‚ (Power Input) โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ BORON POWER MGMT โ”‚ + โ”‚ โ€ข 3.3V Logic Supply โ”‚ + โ”‚ โ€ข Cellular Radio Power โ”‚ + โ”‚ โ€ข GPIO Power (D3โ†’Alarm) โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + +## Component Specifications + +### Microswitch Requirements +- **Type**: SPDT (Single Pole, Double Throw) with NC contact +- **Voltage Rating**: 12V+ (any standard microswitch) +- **Current Rating**: 100mA+ (very low current for digital input) +- **Mechanical Life**: 10M+ cycles for reliability +- **Mounting**: Panel mount or lever actuated +- **Examples**: Cherry D44X, Omron SS-5GL, Honeywell 1SW1-1 + +### Alarm Device Options +- **Low Power Buzzer**: 3-12V, <100mA (direct drive from D3) +- **High Power Siren**: 12V, 500mA-2A (requires transistor driver) +- **Strobe Light**: 12V, 200-500mA (requires transistor driver) +- **Relay Output**: For AC-powered alarms (requires relay driver) + +### Transistor Driver (for High Power Alarms) +- **Type**: NPN switching transistor +- **Part**: 2N2222, 2N3904, or similar +- **Ratings**: + - Collector Current: 500mA+ (for siren load) + - Collector-Emitter Voltage: 12V+ + - Base Current: ~3mA (from D3 via 1kฮฉ resistor) + +### Battery Specifications +- **Chemistry**: Lithium Polymer (Li-Po) or Lithium Ion (Li-Ion) +- **Voltage**: 3.7V nominal (4.2V max, 3.0V min) +- **Capacity**: 5000-10000mAh for 2+ year operation +- **Connector**: JST or similar for easy replacement +- **Protection**: Built-in protection circuit recommended +- **Temperature Range**: -10ยฐC to +60ยฐC for outdoor use + +### Solar Panel (Optional) +- **Voltage**: 6V (to charge 3.7V battery via controller) +- **Power**: 1W minimum, 2W+ recommended for northern climates +- **Type**: Monocrystalline for efficiency +- **Weather Rating**: IP65+ for outdoor installation +- **Charge Controller**: Required to prevent overcharge + - SparkFun Sunny Buddy + - Adafruit Universal USB/Solar Lithium Ion/Polymer charger + - Similar MPPT solar charge controller + +## Installation Notes + +### 1. Microswitch Mounting +- Mount securely to door/window frame +- Ensure proper gap (1-2mm) when closed +- Test mechanical operation before wiring +- Consider vibration and weather exposure + +### 2. Alarm Device Placement +- Position for maximum deterrent effect +- Protect from weather if outdoor installation +- Ensure adequate power capacity (check battery drain) +- Test audibility at intended range + +### 3. Enclosure Requirements +- **Rating**: IP65+ for outdoor use +- **Size**: Accommodate Boron + battery + connections +- **Access**: Serviceable battery compartment +- **Mounting**: Secure mounting points +- **Ventilation**: Battery safety (avoid gas buildup) + +### 4. Power System +- Use proper JST connectors for battery +- Include inline fuse (2A) for protection +- Secure all connections against vibration +- Label positive/negative clearly +- Test polarity before connecting + +### 5. Testing Procedure +1. **Bench Test**: Verify all connections with multimeter +2. **Power Test**: Check current consumption in sleep mode +3. **Function Test**: Trigger microswitch, verify alarm +4. **Range Test**: Verify cellular signal at installation site +5. **Endurance Test**: 24-hour operation test before deployment \ No newline at end of file diff --git a/Server/docs/architecture.md b/Server/docs/architecture.md new file mode 100644 index 0000000..e69de29 diff --git a/Server/docs/production-deployment.md b/Server/docs/production-deployment.md new file mode 100644 index 0000000..e69de29