DIY Smart Mailbox Validator (OTA-Ready)

Parts List & Smart Mailbox API v1.0

ComponentSuggested Model / Notes
MicrocontrollerESP32 or Raspberry Pi Pico W (Wi-Fi + BLE)
Lid Position SensorReed switch + magnet or Hall effect sensor
Mail Detection SensorIR breakbeam sensor or weight sensor pad
Locking MechanismServo motor or solenoid latch
Power Supply5V USB or battery pack (w/ solar trickle optional)
Optional Camera ModuleESP32-CAM or USB camera (for photo capture/logging)
Weatherproof EnclosureIP65-rated plastic box
QR Code LabelFor validator scan/onboarding
Optional: LoRa moduleFor off-grid message relay (RFM95/96)

Assembly Instructions

  1. Mount the Lid Sensor
    Place the reed switch inside the mailbox lid and affix the magnet to the top edge so it triggers when opened.
  2. Install Mail Sensor
    Position the IR sensor where mail will break the beam when inserted or rest on the weight pad.
  3. Connect the Microcontroller
    Wire sensors to GPIO pins, enable input pull-up/down as needed.
  4. Add Lock/Servo (Optional)
    Wire a servo or latch to allow locking/unlocking remotely.
  5. Enclose Components
    Mount all components securely in the enclosure. Route cables through sealed grommets.
  6. Power Supply
    Use a USB battery bank or solar-powered battery charger. ESP32 sleep modes recommended for efficiency.

Software Features

  • Wi-Fi or BLE pairing to OTAwallet
  • CID logging of each open event
  • Remote lock control (via OTAwallet or QR command)
  • Validator scan logs (e.g., /device/verify)
  • Optional: take photo on open + upload to IPFS

IPFS Logging + CID Example

Each event (lid open, mail drop, access attempt) can be logged as:

json{
"device_id": "mailbox-trusted-01",
"event": "mail_inserted",
"timestamp": "2025-05-29T15:03:42Z",
"cid": "bafy...xyz",
"validator": "relay1",
"signature": "..."
}

Integration Hooks

  • /device/verify from alias_api_server.py
  • /device/eventlog/:id
  • /cid/push
  • OTAwallet “Trusted Mailbox” badge display

Optional Add-ons

  • NFC tag to identify mail carriers
  • QR tag for trusted guest access
  • External LoRa radio for off-grid relay
  • Integration with SafeSignal for alerts

DIY Smart Mailbox Validator (LoRa + Web3 MAC Auth Gateway)

Architecture Overview

  • Smart Mailbox Node (Outdoor)
    • Battery-powered
    • Detects mail, door open, tamper events
    • Broadcasts LoRa packets with MAC and CID payloads
  • LoRa Gateway Node (Indoor)
    • Receives LoRa packets from mailbox
    • Signs and forwards them to OTAwallet or IPFS
    • Maps mailbox MAC → validator wallet address
    • Runs lightweight Web3 MAC Gateway (e.g., mac_gateway.py)

🔧 Outdoor Mailbox Node – Parts List

ComponentExample / Notes
MicrocontrollerSeeeduino Xiao + RFM95 LoRa (or ESP32 w/ LoRa)
LoRa ModuleHope RFM95 (868/915MHz)
Door SensorReed switch or Hall sensor
Mail SensorLoad cell, IR sensor, or capacitive pad
Tamper SwitchOptional micro switch or accelerometer
Battery Pack18650 w/ TP4056 charger (solar optional)
EnclosureWeatherproof IP65 case
QR Tag / LabelFor scan-based validator registration

Indoor LoRa Gateway Node – Parts List

ComponentExample / Notes
Raspberry PiPi 3/4 or Zero 2W
LoRa Hat/ModuleDragino LoRa HAT, RFM95 on SPI
MAC Auth Softwaremac_gateway.py with CID builder + IPFS push
OTAwallet WalletInstalled & linked to this gateway
OptionalOLED screen for real-time CID logs

Data Flow

  1. 📬 Mail is inserted → sensor triggers
  2. 📡 LoRa packet broadcast: json{ "mac": "B8:27:EB:12:34:56", "event": "mail_inserted", "ts": 1688230093, "sig": "<optional sig>" }
  3. 🏠 Gateway receives packet:
    • Verifies MAC
    • Maps to relay1 validator alias
    • Pushes event log to IPFS
    • Logs CID locally or to the OTA ledger

Web3 MAC Gateway Logic

python# mac_gateway.py (simplified)
def handle_packet(packet):
mac = packet["mac"]
if mac in known_devices:
cid = ipfs_add(json.dumps(packet))
log_to_ledger(mac, cid)
  • known_devices from mac_registry.json
  • IPFS log includes timestamp + validator alias
  • All mailbox devices must be pre-registered (or dynamically onboarded via QR scan)

Example IPFS Log Output

json{
"device": "smart_mailbox_001",
"mac": "B8:27:EB:12:34:56",
"event": "door_opened",
"timestamp": "2025-05-29T16:20:54Z",
"cid": "bafy...123",
"verified_by": "relay1"
}

Example OTA gateway

Example Mailbox_node

Mailbox Node Firmware

U.S.-Based LoRa Module Manufacturers

1. Microchip Technology

  • Modules: RN2483 (868 MHz) and RN2903 (915 MHz)
  • Features: Integrated LoRaWAN stack, UART interface, low power consumption
  • Use Case: Ideal for projects requiring reliable LoRaWAN connectivityAmazon+8CDEByte+8Tindie+8

2. MultiTech Systems

  • Modules: xDot® and mDot™
  • Features: ARM Cortex-M3, LoRaWAN certified, robust for industrial applications
  • Use Case: Suitable for large-scale deployments and enterprise solutionseBay+3CDEByte+3Tesswave Technology Limited+3

3. Laird Connectivity

  • Modules: RM1xx series
  • Features: Combines LoRa and Bluetooth Low Energy (BLE), flexible integration
  • Use Case: Great for applications needing both LoRa and BLE connectivityPiShopCDEByte

Development Boards & HATs Compatible with Raspberry Pi

1. Waveshare SX1262 LoRa HAT (915 MHz)

2. Adafruit LoRa Radio Bonnet

  • Features: Built-in OLED display, based on Semtech SX1276, supports 915 MHz
  • Availability: Sold by Adafruit, a U.S.-based company
  • Use Case: Ideal for developers seeking a compact solution with display capabilitiesPoshmark+11Embedded+11Tindie+11

Integration Tips for Your Smart Mailbox Project

  • Frequency Compliance: Ensure the module operates at 915 MHz to comply with U.S. regulations.
  • Power Considerations: Opt for modules with low power consumption to extend battery life.
  • Antenna Selection: Use appropriate antennas to maximize range and signal quality.
  • Firmware Support: Choose modules with robust firmware support and community resources.

Authentication

All endpoints are scoped by the mac_address of the mailbox.
On-chain mapping via validator-signed registration (MAC → Wallet).


POST /mailbox/event

Log mailbox events (e.g., mail inserted, door opened).

json{
"mac": "B8:27:EB:12:34:56",
"event": "mail_inserted",
"timestamp": "2025-05-29T17:45:00Z"
}

Returns:

json{
"cid": "bafybeigdxyz...",
"verified_by": "relay1"
}

POST /mailbox/register

Register a new mailbox and assign it to a tenant or unit.

json{
"mac": "B8:27:EB:12:34:56",
"tenant_id": "apt_204",
"wallet": "osmo1xyz...",
"permissions": ["unlock", "guest_access"]
}

GET /mailbox/tenant/:tenant_id/mailboxes

List all mailboxes assigned to a tenant.

Returns:

json[
{
"mac": "B8:27:EB:12:34:56",
"alias": "apt_204_box",
"status": "locked",
"last_event": "door_opened"
}
]

POST /mailbox/photo

Capture and upload a snapshot (if equipped).

json{
"mac": "B8:27:EB:12:34:56"
}

Returns:

json
"cid": "bafy...img",
"timestamp": "2025-05-29T17:45:12Z"
}

POST /mailbox/guest_access

Share a guest passcode for delivery or temporary access.

json{
"tenant_id": "apt_204",
"mac": "B8:27:EB:12:34:56",
"code": "5147",
"valid_for": 600
}

GET /mailbox/logs/:tenant_id

Fetch mailbox access history (IPFS-backed log).

Returns:

json[
{
"event": "mail_inserted",
"cid": "bafy...xyz",
"timestamp": "2025-05-29T17:30:12Z"
}
]

🔒 POST /mailbox/lock

Lock or unlock a mailbox.

json{
"mac": "B8:27:EB:12:34:56",
"action": "unlock",
"method": "temp_passcode",
"passcode": "5147"
}

🛠️ POST /mailbox/admin/override

Admin override with signed validator authorization.

json{
"mac": "B8:27:EB:12:34:56",
"reason": "lost_key",
"admin_sig": "validator-signed-hash"
}

📊 GET /mailbox/status/:mac

Real-time status of the mailbox.

Returns:

json{
"door": "closed",
"flag": "down",
"lock": "locked",
"temperature_c": 23.5,
"battery_percent": 88
}

🧪 POST /mailbox/simulate

Send a fake packet for testing purposes (dev only).

json{
"mac": "B8:27:EB:12:34:56",
"event": "test_flag_up"
}