📝 Adds README and circuit diagrams

This commit is contained in:
Daniel Svitan 2025-05-08 14:21:45 +02:00
parent 484d01c95f
commit d851d0a740
5 changed files with 146 additions and 2 deletions

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# door-alarm
This is a simple, home-made door alarm based on ultrasound sensor distance measurements
The peripheral device is powered by a Raspberry Pi Pico W, with the following diagram
![door alarm peripheral device circuit diagram](circuit.svg "Circuit Diagram")

BIN
circuit.cddx Normal file

Binary file not shown.

137
circuit.svg Normal file
View File

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Circuit Diagram, cdlibrary.dll 4.0.0.0 -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" width="300" height="460" xmlns="http://www.w3.org/2000/svg">
<line x1="260" y1="250" x2="280" y2="250" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="280" y1="250" x2="280" y2="290" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="250" y1="290" x2="280" y2="290" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="170" y1="290" x2="220" y2="290" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="170" y1="290" x2="170" y2="350" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="30" y1="350" x2="170" y2="350" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="30" y1="360" x2="200" y2="360" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="40" y1="390" x2="200" y2="390" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="50" y1="380" x2="200" y2="380" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="60" y1="370" x2="200" y2="370" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="40" y1="330" x2="120" y2="330" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="50" y1="100" x2="50" y2="380" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="50" y1="100" x2="140" y2="100" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="40" y1="80" x2="40" y2="390" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="40" y1="80" x2="140" y2="80" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="60" y1="90" x2="60" y2="370" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="60" y1="90" x2="140" y2="90" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="30" y1="30" x2="30" y2="360" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="30" y1="30" x2="280" y2="30" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="280" y1="30" x2="280" y2="100" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="260" y1="100" x2="280" y2="100" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="120" y1="250" x2="140" y2="250" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="120" y1="250" x2="120" y2="255" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="120" y1="295" x2="120" y2="300" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<path d="M 120,255 L 120,257 L 113,260 L 127,266 L 113,272 L 127,278 L 113,284 L 127,290 L 120,293 L 120,295" style="fill-opacity:0;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="106" y="275" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 106, 275)">230 Ω</text>
<line x1="220" y1="290" x2="221" y2="290" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="249" y1="290" x2="250" y2="290" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<ellipse cx="224" cy="290" rx="3" ry="3" style="fill-opacity:0;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-width:2" />
<ellipse cx="246" cy="290" rx="3" ry="3" style="fill-opacity:0;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-width:2" />
<line x1="223" y1="282" x2="247" y2="282" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="229" y1="276" x2="241" y2="276" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="235" y1="276" x2="235" y2="282" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="120" y1="300" x2="120" y2="330" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<path d="M 120,322 M 112,322 L 128,322 M 120,322 L 128,307 L 112,307 L 120,322" style="fill-opacity:0;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<path d="M 120,320 M 131,318 L 139,326 M 140,327 L 138,323 L 136,325 L 140,327 L 138,323" style="fill-opacity:0;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<path d="M 120,320 M 124,324 L 132,332 M 133,333 L 131,329 L 129,331 L 133,333 L 131,329" style="fill-opacity:0;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<rect x="210" y="310" width="50" height="130" style="fill-opacity:0;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-width:2" />
<line x1="200" y1="360" x2="210" y2="360" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="200" y1="370" x2="210" y2="370" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="200" y1="380" x2="210" y2="380" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<line x1="200" y1="390" x2="210" y2="390" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<ellipse cx="235" cy="332" rx="14" ry="14" style="fill-opacity:0;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-width:2" />
<ellipse cx="235" cy="418" rx="14" ry="14" style="fill-opacity:0;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-width:2" />
<text x="214" y="360" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 214, 360)">VCC</text>
<text x="214" y="370" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 214, 370)">TRIG</text>
<text x="214" y="380" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 214, 380)">ECHO</text>
<text x="214" y="390" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 214, 390)">GND</text>
<text x="200" y="40" style="font-family:Arial;font-size:11px;text-anchor:middle" dominant-baseline="middle" transform="rotate(0, 200, 40)">Raspberry Pi Pico</text>
<rect x="150" y="50" width="100" height="210" style="fill-opacity:0;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-width:2" />
<line x1="140" y1="60" x2="150" y2="60" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="60" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 60)">GP0</text>
<line x1="250" y1="60" x2="260" y2="60" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="60" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 60)">VBUS</text>
<line x1="140" y1="70" x2="150" y2="70" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="70" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 70)">GP1</text>
<line x1="250" y1="70" x2="260" y2="70" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="70" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 70)">VSYS</text>
<line x1="140" y1="80" x2="150" y2="80" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="80" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 80)">GND</text>
<line x1="250" y1="80" x2="260" y2="80" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="80" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 80)">GND</text>
<line x1="140" y1="90" x2="150" y2="90" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="90" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 90)">GP2</text>
<line x1="250" y1="90" x2="260" y2="90" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="90" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 90)">3V3_EN</text>
<line x1="140" y1="100" x2="150" y2="100" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="100" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 100)">GP3</text>
<line x1="250" y1="100" x2="260" y2="100" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="100" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 100)">3V3_OUT</text>
<line x1="140" y1="110" x2="150" y2="110" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="110" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 110)">GP4</text>
<line x1="250" y1="110" x2="260" y2="110" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="110" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 110)">ADC_VREF</text>
<line x1="140" y1="120" x2="150" y2="120" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="120" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 120)">GP5</text>
<line x1="250" y1="120" x2="260" y2="120" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="120" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 120)">GP28</text>
<line x1="140" y1="130" x2="150" y2="130" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="130" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 130)">GND</text>
<line x1="250" y1="130" x2="260" y2="130" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="130" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 130)">GND</text>
<line x1="140" y1="140" x2="150" y2="140" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="140" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 140)">GP6</text>
<line x1="250" y1="140" x2="260" y2="140" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="140" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 140)">GP27</text>
<line x1="140" y1="150" x2="150" y2="150" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="150" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 150)">GP7</text>
<line x1="250" y1="150" x2="260" y2="150" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="150" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 150)">GP26</text>
<line x1="140" y1="160" x2="150" y2="160" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="160" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 160)">GP8</text>
<line x1="250" y1="160" x2="260" y2="160" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="160" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 160)">RUN</text>
<line x1="140" y1="170" x2="150" y2="170" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="170" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 170)">GP9</text>
<line x1="250" y1="170" x2="260" y2="170" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="170" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 170)">GP22</text>
<line x1="140" y1="180" x2="150" y2="180" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="180" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 180)">GND</text>
<line x1="250" y1="180" x2="260" y2="180" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="180" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 180)">GND</text>
<line x1="140" y1="190" x2="150" y2="190" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="190" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 190)">GP10</text>
<line x1="250" y1="190" x2="260" y2="190" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="190" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 190)">GP21</text>
<line x1="140" y1="200" x2="150" y2="200" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="200" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 200)">GP11</text>
<line x1="250" y1="200" x2="260" y2="200" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="200" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 200)">GP20</text>
<line x1="140" y1="210" x2="150" y2="210" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="210" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 210)">GP12</text>
<line x1="250" y1="210" x2="260" y2="210" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="210" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 210)">GP19</text>
<line x1="140" y1="220" x2="150" y2="220" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="220" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 220)">GP13</text>
<line x1="250" y1="220" x2="260" y2="220" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="220" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 220)">GP18</text>
<line x1="140" y1="230" x2="150" y2="230" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="230" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 230)">GND</text>
<line x1="250" y1="230" x2="260" y2="230" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="230" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 230)">GND</text>
<line x1="140" y1="240" x2="150" y2="240" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="240" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 240)">GP14</text>
<line x1="250" y1="240" x2="260" y2="240" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="240" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 240)">GP17</text>
<line x1="140" y1="250" x2="150" y2="250" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="154" y="250" style="font-family:Arial;font-size:11px;text-anchor:start" dominant-baseline="middle" transform="rotate(0, 154, 250)">GP15</text>
<line x1="250" y1="250" x2="260" y2="250" style="stroke:rgb(0, 0, 0);stroke-linecap:square;stroke-width:2" />
<text x="246" y="250" style="font-family:Arial;font-size:11px;text-anchor:end" dominant-baseline="middle" transform="rotate(0, 246, 250)">GP16</text>
<ellipse cx="30" cy="350" rx="2" ry="2" style="fill-opacity:1;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-width:2" />
<ellipse cx="40" cy="330" rx="2" ry="2" style="fill-opacity:1;fill:rgb(0, 0, 0);stroke:rgb(0, 0, 0);stroke-width:2" />
</svg>

View File

@ -76,7 +76,7 @@ def connect():
def send_req(opened: bool):
print("Updating state...", end="\r")
data = {"opened": opened}
raw = ujson.dumps(data)
r = requests.post(f"{server}/write",

View File

@ -216,7 +216,7 @@ func sendAlert(action string) {
to := fmt.Sprintf("%s/message?token=%s", gotifyURL, gotifyToken)
what := echo.Map{
"title": fmt.Sprintf("Your door has been %s", action),
"priority": 1,
"priority": 5,
"message": fmt.Sprintf("Your locked door has been %s at %s", action, time.Now().Format(TimeFormat)),
}
b, err := json.Marshal(&what)