pDomovoy (pD) - room intrusion detection system
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.
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'scontrol panel
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
Remote panel for whole system with buttons controls and oled display
- secure communication with
wardenover BLE with MAC addresses filtering warden'salarm state management & data preview (battery voltage & alarm state)- AHT20 humidity & temperature readings
- built in buzzer for alarm
- integrated with SSD1306 screen for data presentation
- home page
- aht20 based temperature & humidity
trumpet's&warden'sbattery voltage- alarm state
- time stats page
- time since boot
- time since
wardenhas been connected - time since alarm has been armed
- versions page
shows trumpet's & warden's version (if warden is connected)
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'salarm is triggeredwarden'salarm in in standby mode and it's connection withtrumpethas been lost
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
wardenbut 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
- 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
- initialize pico-sdk dependencies
cd ~/SDKs/pico-sdk/2.2.0
git submodule update --init
- initialize project dependencies
git submodule update --init
- config setup
cp config.cmake.template config.cmake
- 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
- open project in devcontainer
- setup project
cmake -S . -B build
or for debug mode
cmake -DDEBUG=1 -S . -B build
- build
cd build
make
- flash device with generated
.uf2file (trumpet/warden)
sh copy_uf2.sh ./build/warden.uf2 /Volumes/RPI-RP2
screen /dev/tty1
to exit
CTRL + A -> CTRL + \


