Skip to content

zNitche/pDomovoy

Repository files navigation

pDomovoy

pDomovoy (pD) - room intrusion detection system

Description

Some time ago I built a sleepwalking detection and prevention system. It served its purpose good but extensive setup (smartwatch + raspberry Pi 4 + wiring) and the fact that in previous years I've traveled a lot and stayed at many different hotels made me rethink that design.

Then this idea came to my mind, dedicated devices, with long lasting battery life, travel safe (no strong magnets, detachable battery), that serves as sleepwalker did but also provides a way to make sure your room's doors stays closed when you sleep (in short nobody enters and leaves without triggering the alarm).

So let's build 2 devices system connected via BLE using C and pico-sdk.

both

Modules breakdown

Warden

Description

Heavy lifting device, after initialization (by button push or Trumpet) placed against the door, if device's position / orientation changes (or if paired with trumpet and connection is lost), the alarm will be activated.

Triggered alarm can by disabled by:

  • pushing button 5 times
  • using Trumpet's control panel
Assembly

Setup is quite simple, but due to lack of my PCB production capacities, everything had to be assembled using prototype boards + point to point wiring, anyway it looks like this:

  • 2x 30x70 mm prototype 2-side boards, some wires, socket for glass tube fuse and cell holder for 18650 battery

  • TP4056 (with DW01a for cell protection) for 18650 LI-ION charging (connected via 1A fuse)

  • LED and buzzer connected via BC337 transistor for 5V supply and 3.3V control line, connected via 440R resistor to Raspberry Pi Pico W (probably should add 3.3V zener diode to logic line as a extra protection, but due to reasons mentioned earlier I did not)

  • Button connected via 440R resistor to MCU

  • 2k2 + 2k2 resistors as voltage divider (with ratio 1/2) connected to battery and MCU ADC as voltmeter used for checking battery level

  • ADXL345 accelerometer connected to RPI Pico's 3.3V line and I2C 1

  • MCU powered via 5V step-up DC converter

  • 220uF capacitors added to Pico's 5V input & step-up converter's input

  • 1uF capacior added in parrel to the buzzer for eliminating voltage spikes while generating tone

  • 3D printed case, circuit boards mounted using 4x 2mm and 4x 3mm screws

  • 2x 2mm screws for case closing

Photos

warden_open

Trumped

Description

Remote panel for whole system with buttons controls and oled display

Features
  • secure communication with warden over BLE with MAC addresses filtering
  • warden's alarm state management & data preview (battery voltage & alarm state)
  • AHT20 humidity & temperature readings
  • built in buzzer for alarm
  • integrated with SSD1306 screen for data presentation
Display pages
  1. home page
  • aht20 based temperature & humidity
  • trumpet's & warden's battery voltage
  • alarm state
  1. time stats page
  • time since boot
  • time since warden has been connected
  • time since alarm has been armed
  1. versions page

shows trumpet's & warden's version (if warden is connected)

trumpet's alarm

trumpet is equiped with built in buzzer serving as alarm (the same 5v powered buzzer as in warden), it will be activated in below cases:

  • warden's alarm is triggered
  • warden's alarm in in standby mode and it's connection with trumpet has been lost
Assembly

the same situation as in warden's case, good old prototype boards + point to point wiring, setup looks like this:

  • 1x 60x80 mm + 1x 20x80 mm prototype 2-side boards, some wires, socket for glass tube fuse and cell holder for 18650 battery

  • TP4056 (with DW01a for cell protection) for 18650 LI-ION charging (connected via 1A fuse)

  • Alarm buzzer connected via BC337 transistor for 5V supply and 3.3V control line, connected via 330R resistor to MCU

  • 10uF capacior (should be 1uF as in warden but due to mistake it is what it is) added in parrel to the buzzer for eliminating voltage spikes while generating tone

  • Buttons connected via 330R resistors to MCU

  • display & temperature sensor connected to i2c0 and powered via MCU's internal 3.3v

  • 1k + 3k3 resistors as voltage divider (with ratio 0.75) connected to battery and MCU ADC as voltmeter used for checking battery level

  • MCU powered via 5V step-up DC converter

  • 220uF capacitors added to Pico's 5V input & step-up converter's input

  • 3D printed case, circuit boards mounted using 10x 2mm and 2x 3mm screws

Photos

trumpet_open

Setup

  1. get pico-sdk
mkdir -p ~/SDKs/pico-sdk
cd ~/SDKs/pico-sdk
git clone -b "2.2.0" --single-branch https://github.com/raspberrypi/pico-sdk.git 2.2.0
  1. initialize pico-sdk dependencies
cd ~/SDKs/pico-sdk/2.2.0
git submodule update --init
  1. initialize project dependencies
git submodule update --init
  1. config setup
create config.cmake
cp config.cmake.template config.cmake
fill it's content (if using warden & trumpet)
  • set PD_WARDEN_BT_MODE_ENABLED to true
  • set PD_WARDEN_BT_MAC to warden's MAC address
  • set PD_TRUMPET_BT_MAC to warden's MAC address
  1. open project in devcontainer
  2. setup project
cmake -S . -B build

or for debug mode

cmake -DDEBUG=1 -S . -B build
  1. build
cd build
make
  1. flash device with generated .uf2 file (trumpet / warden)

Extra

auto copying of .uf2 file to MCU.

sh copy_uf2.sh ./build/warden.uf2 /Volumes/RPI-RP2

Connect to device

screen /dev/tty1

to exit

CTRL + A -> CTRL + \

Dependencies

About

pDomovoy (pD) - room intrusion detection system

Resources

License

Stars

Watchers

Forks

Contributors

Languages