Cov txheej txheem:

Raspberry Pi Motion Sensor IFTTT: 4 Cov Kauj Ruam
Raspberry Pi Motion Sensor IFTTT: 4 Cov Kauj Ruam

Video: Raspberry Pi Motion Sensor IFTTT: 4 Cov Kauj Ruam

Video: Raspberry Pi Motion Sensor IFTTT: 4 Cov Kauj Ruam
Video: DIY Smart Home Motion Sensor with Raspberry Pi and IFTTT 2024, Hlis ntuj nqeg
Anonim
Raspberry Pi Motion Sensor IFTTT
Raspberry Pi Motion Sensor IFTTT
Raspberry Pi Motion Sensor IFTTT
Raspberry Pi Motion Sensor IFTTT

Nyob zoo. Kuv yog tus kawm qib 4 thiab niaj hnub no peb yuav ua IFTTT lub suab ntsuas

Khoom siv

1x lub thawv ntawv me me

1x raspberry pi qauv b+ lossis a+

1x PIR sensor https://www.amazon.com/gp/product/B07KZW86YR/ref=p… (Ntau yam) jumper xov hlau

1x lub teeb pom kev zoo (xaiv tau)

Cov kab xev (xaiv tau)

ifttt tus account

Kauj ruam 1: Txiav:

Txiav
Txiav

Txiav ib lub qhov me me nyob nruab nrab ntawm lub npov saum toj.

Kauj Ruam 2: Txuas PIR Sensor:

Txuas nrog PIR Sensor
Txuas nrog PIR Sensor
Txuas nrog PIR Sensor
Txuas nrog PIR Sensor

Txuas lub PIR sensor tus pin cim VCC mus rau 5V tus pin ntawm Raspberry Pi. Qhov no muab lub zog rau PIR sensor. C txuas ib daim ntawv sau npe GND rau tus pin hauv av ntawm Pi (tseem sau tias GND). Qhov no ua tiav qhov Circuit Court. Hauv qhov piv txwv no, peb tau xaiv GPIO 4. Tus pin OUT yuav tso tawm qhov hluav taws xob thaum lub ntsuas pom pom qhov txav mus los. Qhov voltage yuav tau txais los ntawm Raspberry Pi.

Kauj Ruam 3: Teeb Webhooks:

Teeb Webhooks
Teeb Webhooks

ua ib qho tshiab applet, thiab tom qab ntawd Xaiv Webhooks. thiab tom qab ntawd ua tib yam nrog cov ntawv ceeb toom.

Kauj ruam 4: Code:

Rau nab nab 3 lossis thonny

#! /usr/bin/nab nab # Importsimport RPi. GPIO raws li GPIOimport lub sijhawm thov thov # Teeb tsa GPIO lub npe kev sib tham GPIO.setmode (GPIO. BCM) # Tua GPIO cov lus ceeb toom GPIO.setwarnings (Tsis tseeb) # Teeb tus lej sib txawv los tuav GPIO Pin identitypinpir = 17 # Teeb GPIO tus pin raws li kev nkag GPGP.setup (pinpir, GPIO. IN) # Cov lej sib txawv los tuav lub xeev tam sim no thiab zaum kawg = tam sim no 0 ua ntej dhau los = 0 sim: luam tawm ("Tos rau PIR daws …") # Loop kom txog thaum PIR tso tawm yog 0 thaum GPIO.input (pinpir) == 1: currentstate = 0 print ("Ready") # Loop kom txog thaum cov neeg siv tawm nrog CTRL-C thaum Muaj Tseeb: # Nyeem PIR lub xeev tam sim no = GPIO.input (pinpir) # Yog PIR tau tshwm sim yog lub xeev tam sim no == 1 thiab lub xeev yav dhau los == 0: print ("Tsab ntawv tsa suab pom!") # Koj li IFTTT URL nrog lub npe txheej xwm, tus yuam sij thiab json tsis (qhov tseem ceeb) r = thov.post ('https://maker.ifttt.com/trigger /YOUR_EVENT_NAME/with/key/YOUR_KEY_HERE ', params = {"value1": "none", "value2": "none", "value3": "none"}) # Kaw lub xeev tshiab dhau los yav dhau los = 1 # Tos 120 vib nas this ua ntej looping ag ain luam tawm ("Tos 120 vib nas this") sijhawm.sleep (120) # Yog tias PIR tau rov qab los rau lub xeev tam sim no elif currentstate == 0 thiab lub xeev yav dhau los == 1: print ("Ready") yav dhau los state = 0 # Tos rau 10 milliseconds sijhawm.sleep (0.01) tshwj tsis yog KeyboardInterrupt: print ("Quit") # Reset GPIO settings GPIO.cleanup ()

Txaus siab rau!

Pom zoo: