Cov txheej txheem:

Tswb PIR rau WiFi (thiab Tsev Automation): 7 Kauj Ruam (nrog Duab)
Tswb PIR rau WiFi (thiab Tsev Automation): 7 Kauj Ruam (nrog Duab)

Video: Tswb PIR rau WiFi (thiab Tsev Automation): 7 Kauj Ruam (nrog Duab)

Video: Tswb PIR rau WiFi (thiab Tsev Automation): 7 Kauj Ruam (nrog Duab)
Video: Интернет-маркетинг и SEO Советы | Как получить отличный ... 2024, Kaum ib hlis
Anonim
Image
Image
Tswb PIR rau WiFi (thiab Tsev Automation)
Tswb PIR rau WiFi (thiab Tsev Automation)

Txheej txheem cej luam

Cov lus qhia no yuav muab peev xwm rau koj kom saib hnub/sijhawm kawg (thiab xaiv tau keeb kwm ntawm lub sijhawm) ntawm thaum koj lub Tsev Tswb PIRs (passive infrared sensors) tau tshwm sim, hauv koj lub tsev siv tshuab software. Hauv txoj haujlwm no, kuv yuav tham txog yuav siv OpenHAB (software dawb hauv tsev siv lub tshuab, uas kuv tus kheej siv) txawm hais tias nws yuav ua haujlwm nrog lwm lub software hauv tsev siv lossis siv daim ntawv thov uas txhawb MQTT (kuj tau piav qhia tom qab hauv kab lus no). Cov lus qhia no yuav ua rau koj hla cov kauj ruam tsim nyog yuav ua li cas xaim kab hluav taws xob hauv Circuit Court thiab Wemos D1 mini (IOT board uas siv ESP8266 nti) uas ntxig rau hauv lub tswb tswb hauv koj lub tswb tswj lub thawv kom thaum ntawd ib cheeb tsam (uas muaj ib lossis ntau PIRs) tau tshwm sim, Wemos xa xov tsis siv lub MQTT raws tu qauv rau koj lub tshuab siv tshuab hauv tsev uas tig los, qhia hnub kawg/sijhawm ntawm qhov ua rau. Arduino code rau program Wemos kuj tseem muaj.

Taw qhia

Cov duab saum toj no yog qhov kuv pom ntawm ib qho ntawm cov ntxaij vab tshaus ntawm OpenHAB app ntawm kuv iPhone. Hnub/sijhawm ntawv yog xim xim txhawm rau muab tus sawv cev nrawm dua thaum PIR tau tshwm sim - nws yuav qhia liab (tshwm sim hauv 1 feeb kawg), txiv kab ntxwv (ua rau tsis pub dhau 5 feeb kawg), ntsuab (tshwm sim hauv 30 feeb kawg), xiav (ua rau tsis pub dhau ib teev dhau los) lossis lwm yam, dub. Nyem rau hnub/sijhawm, yuav tso saib keeb kwm ntawm PIR ua rau, qhov twg 1 txhais tau tias ua rau, thiab 0 tsis ua haujlwm. Muaj ntau qhov siv rau qhov no, piv txwv li nws tuaj yeem ntxiv koj li kev daws teeb meem hauv tsev, nws tuaj yeem txheeb xyuas kev txav chaw yog tias koj nyob deb thiab ntawm OpenHAB cov cai, xa ntawv ceeb toom rau koj lub xov tooj, koj tuaj yeem siv nws zoo li kuv ua los saib yog tias kuv cov menyuam sawv hauv nruab nrab hmo ntuj, ua rau muaj PIR uas nyob sab nraum lawv chav pw!

OpenHAB tsuas yog lub tshuab siv hluav taws xob hauv tsev uas kuv siv, muaj ntau yam ntxiv - thiab yog tias lawv txhawb nqa MQTT ces koj tuaj yeem hloov kho txoj haujlwm no kom haum rau cov software koj siv.

Kev xav

Cov lus qhia no xav tias koj twb muaj (lossis yuav teeb tsa):

  • Pom tseeb lub tswb hauv tsev nrog PIRs (passive infrared sensors) thiab koj tau nkag mus rau lub tswb tswj lub thawv kom txuas mus rau qhov tsim nyog thaiv
  • OpenHAB (pub dawb qhib qhov cuab yeej siv hauv tsev automation) ua haujlwm, txawm hais tias tau tham txog nws yuav tsum ua haujlwm nrog txhua lub tsev siv tshuab software uas tuaj yeem suav nrog MQTT khi. Hloov pauv, koj tuaj yeem hloov tus lej koj tus kheej kom haum rau koj tus kheej xav tau.
  • Mosquitto MQTT (lossis zoo sib xws) tus tswv lag luam tau teeb tsa thiab teeb tsa teeb tsa nrog OpenHAB (MQTT yog kev xa xov xa tawm/tshaj tawm hom kev cai raws li lub teeb yuag thiab zoo rau kev sib txuas lus ntawm cov khoom siv)

Yog tias koj tsis khiav OpenHAB thiab MQTT tus broker, saib kab lus no zoo heev ntawm MakeUseOf lub vev xaib

Kuv xav tau dab tsi?

Txhawm rau tsim lub wireless tswj, koj yuav tsum tau muab cov hauv qab no:

  • Wemos D1 mini V2 (muaj ESP8266 wireless CHIP built-in)
  • Ib tus LM339 sib piv (qhov no yuav ua qhov kev tshuaj xyuas ntawm PIR tsis ua haujlwm vs ua rau)
  • 5V DC lub zog siv hluav taws xob rau Wemos (LOSSIS, DC-DC buck converter. Nco tseg: LM7805 tus tswj hluav taws xob yuav tsis ua haujlwm rau daim ntawv thov no raws li tau tham tom qab hauv qhov haujlwm no)
  • Ob tus tiv thaiv rau qhov faib hluav taws xob (qhov loj yuav nyob ntawm koj lub tswb hluav taws xob, sib tham tom qab hauv txoj haujlwm)
  • Ib qho 1K ohm resistor los ua lub zog rub tawm rau kev tswj LM339 lub zog
  • Ib qho 2N7000 (lossis zoo sib xws) MOSFET txhawm rau qhib qhov LM339 (tejzaum nws xaiv tau, tham tom qab hauv qhov haujlwm)
  • Qhov tsim nyog me me rau ntawm daim phiaj rau kev teeb tsa thiab ntsuas
  • Ib pawg ntawm cov xov hluav taws xob txuas los txuas txhua yam ua ke
  • Cov cuab yeej xav tau: sab txiav, ib leeg tub ntxhais hlau
  • DC ntau lub ntsuas (yuav tsum tau!)

Kauj Ruam 1: Lub Tswb System Tswj Lub Thawv

Lub Tswb System Tswj Lub Thawv
Lub Tswb System Tswj Lub Thawv

Thawj zaug ceeb toom thiab tsis lees paub

Tus kheej, Kuv muaj lub tswb ceeb toom Bosch. Kuv xav pom zoo kom koj rub phau ntawv muaj feem cuam tshuam rau koj lub tswb ceeb toom tshwj xeeb thiab paub koj tus kheej nrog nws ua ntej koj pib thaum koj yuav xav tau lub zog tswb tswb txhawm rau xaim xov tooj. Kuv kuj yuav pom zoo kom koj nyeem kab ntawv no tag nrho ua ntej koj pib!

Hauv qab no yog cov npe ntawm ob peb yam uas koj yuav tsum paub ua ntej koj pib - xyuas kom koj nyeem thiab nkag siab txhua ntawm lawv ua ntej mus! Kuv tsis muaj lub luag haujlwm yog tias koj ntsia koj lub tswb nrov thiab/lossis yuav tsum tau them koj lub installer los kho nws. Yog tias koj nyeem thiab nkag siab cov hauv qab no tab sis ua raws li qhov yuav tsum tau ceev faj, koj yuav tsum ua zoo:

1. Kuv lub tswb ceeb toom muaj lub roj teeb thaub qab sab hauv lub thawv thiab tseem muaj qhov hloov pauv tamper ntawm sab hauv ntawm lub hau (uas muab kev nkag mus rau lub tswb tswb system) yog li txawm tias ua kom lub tswb tawm sab nraud, thaum tshem lub vaj huam sib luag pem hauv ntej ntawm kev tswj hwm lub thawv nws ua rau lub tswb! Txhawm rau kom nyob ib puag ncig qhov no thaum kuv ua haujlwm ntawm txoj haujlwm, Kuv hla dhau qhov kev tiv thaiv tamper los ntawm kev tshem tawm tom qab ntawd luv luv hla kev hloov tamper (cov kab liab liab tuab raws li qhia hauv daim duab saum toj no)

2. Thaum ua kom lub tswb ceeb toom rov qab, tom qab kwv yees li ~ 12 teev lub tswb tswj vaj huam sib luag pib ntsais nrog cov lej ua txhaum. Tom qab txiav txim qhov ua txhaum cai ntawm phau ntawv qhia, kuv pom nws tau ceeb toom kuv tias:

  • Hnub/sijhawm tsis tau teeb tsa (Kuv xav tau tus lej tus lej thiab ntu tseem ceeb los ntawm phau ntawv los teeb tsa dua)
  • Tias lub roj teeb thaub qab tsis txuas nrog (kho tau yooj yim, Kuv tsuas yog tsis nco qab los ntsaws lub roj teeb rov qab)

3. Hauv kuv lub tswb, muaj 4 x thaj chaw sib txuas sib txuas (sau npe Z1 -Z4) rau PIR's los xaim rau ntawm lub rooj ceeb toom tseem ceeb, txawm li cas los xij - kuv lub tswb nrov muaj peev xwm ua tau ntawm 8 thaj chaw. Txhua qhov kev sib txuas hauv cheeb tsam tuaj yeem ua haujlwm 2 x zones txhua (Z1 ua Z1 thiab Z5, Z2 ua Z2 thiab Z6 thiab ntxiv rau). Lub tswb ceeb toom tau teeb tsa kev tiv thaiv kom tsis txhob muaj leej twg hais, qhib lub hau rau lub tswb ceeb toom raws li tau hais los saum no, lossis txiav cov xov hlau mus rau PIR. Nws txawv ntawm txhua cheeb tsam tamper ntawm EOL (kawg ntawm kab) resistors. Cov no yog cov ntsuas tshwj xeeb uas nyob ntawm "qhov kawg ntawm kab" - hauv lwm lo lus, sab hauv PIR (lossis tswj lub thawv tamper hloov, lossis lub thawv siren lossis ib qho twg yog xaim rau cheeb tsam ntawd) kev tiv thaiv ' - thev naus laus zis, yog tias ib tus neeg txiav cov kab hluav taws xob mus rau PIR - vim tias lub tswb ceeb toom tau cia siab tias yuav pom qee qhov kev tiv thaiv los ntawm PIR ntawd, tom qab ntawd yuav tsum muaj kev hloov pauv, nws xav tias ib tus neeg tau cuam tshuam nrog lub kaw lus thiab yuav ua rau lub tswb nrov.

Piv txwv li:

Ntawm kuv lub tswb, Cheeb Tsam "Z4" muaj 2 lub xov hlau nyob hauv nws, ib qho tawm mus rau PIR hauv kuv txoj kev hauv tsev thiab ib qho tawm mus rau lub tswb tswj lub thawv tamper hloov. Sab hauv txoj kev PIR, nws muaj 3300 ohm resistor. Lwm cov hlau uas khiav mus rau lub thawv tswj tamper hloov, muaj 6800 ohm resistor wired hauv kab. Nov yog yuav ua li cas lub tswb nrov (qhov laj thawj) qhov txawv ntawm "Z4" thiab "Z8" tampers. Ib yam nkaus, thaj tsam "Z3" muaj PIR (nrog 3300 ohm resistor hauv nws) thiab tseem muaj lub suab hloov pauv siren (nrog 6800 ohm resistor hauv nws) uas ua rau "Z7". Lub tswb teeb tsa yuav tau teeb tsa lub tswb ceeb toom ua ntej yog li nws paub lub cuab yeej txuas nrog rau txhua cheeb tsam (thiab hloov qhov loj ntawm EOL resistor kom haum, vim tias lub tswb system tau teeb tsa kom paub qhov sib txawv EOL resistors sib txawv li cas. tsis muaj xwm txheej twg koj yuav tsum hloov tus nqi ntawm cov neeg tawm tsam no!)

Yog li ua raws li cov lus sau saum toj no, vim tias txhua cheeb tsam yuav muaj ntau yam khoom siv txuas nrog nws ib yam (nrog qhov sib txawv ntawm qhov tsis sib xws), thiab nco qab tus qauv V = IR (qhov hluav taws xob = amps x tsis kam) ces qhov ntawd kuj tseem txhais tau tias txhua cheeb tsam yuav muaj qhov sib txawv. Uas coj peb mus rau kauj ruam tom ntej, ntsuas txhua thaj tsam IDLE vs TRIGGERED voltage …

Kauj Ruam 2: Ntsuas Lub Tswb Tswb Voltage

Xeem Tswb Tswb Voltage
Xeem Tswb Tswb Voltage
Xeem Tswb Tswb Voltage
Xeem Tswb Tswb Voltage

Thaum koj tau nkag mus rau lub rooj tsav xwm tseem ceeb ntawm koj lub tswb ceeb toom (thiab hla dhau qhov hloov pauv tamper yog tias koj muaj ib qho; raws li cov kauj ruam dhau los) ua kom koj lub tswb nrov rov qab los. Tam sim no peb yuav tsum ntsuas txhua qhov cheeb tsam qhov hluav taws xob thaum nws IDLE (tsis muaj kev txav mus los ntawm PIR) vs TRIGGERED (PIR tau kuaj pom qhov txav mus) Nqa tus cwj mem thiab ntawv kom koj tuaj yeem sau koj qhov kev nyeem hluav taws xob.

CEEB TOOM: Feem ntau ntawm koj lub tswb ceeb toom feem ntau yuav ua haujlwm ntawm 12V DC, txawm li cas los xij nws yuav muaj nws thawj lub zog pub ntawm 220V (lossis 110V) AC, nrog lub tshuab hloov hluav taws xob los ntawm AC rau DC. Nyeem phau ntawv qhia thiab ua kev ceev faj ntxiv kom ntseeg tau tias koj tsis ntsuas ib qho twg hauv AC !!! Raws li qhov screenshot ntawm kuv lub tswb ceeb toom ntawm nplooj ntawv no, koj tuaj yeem pom tias hauv qab ntawm daim duab yog AC fais fab hauv, hloov mus rau 12V DC. Peb tab tom ntsuas 12V DC hauv cov thawv liab uas tau hais tseg. Tsis txhob kov lub zog AC. Ua tib zoo saib xyuas!

Ntsuas PIR Voltage

Kuv muaj 4 x PIR txuas nrog Z1 txog Z4. Ntsuas txhua qhov ntawm koj thaj chaw raws li hauv qab no.

  1. Ua ntej, txheeb xyuas GND lub davhlau ya nyob twg thiab thaj chaw dav dav ntawm lub tswb vaj huam sib luag. Kuv tau hais qhia cov no hauv daim duab qhia los ntawm phau ntawv qhia ntawm kuv lub tswb Bosch.
  2. Lob koj lub multimeter thiab teeb tsa koj qhov ntsuas hluav taws xob rau 20V DC. Txuas cov kab dub (COM) los ntawm koj lub multimeter mus rau GND davhlau ya nyob twg ntawm lub tswb. Muab cov liab (+) coj los ntawm koj lub ntsuas cua ntawm thawj cheeb tsam - hauv kuv cov ntawv sau tias "Z1". Sau qhov kev nyeem qhov hluav taws xob. Ua tib cov kauj ruam rau thaj chaw seem. Kuv qhov ntsuas hluav taws xob muaj raws li hauv qab no:
  • Z1 = 6.65V
  • Z2 = 6.65V
  • Z3 = 7.92V
  • Z4 = 7.92V

Raws li tau hais los saum no, kuv thawj ob thaj chaw tsuas yog muaj PIR txuas nrog lawv ib yam nkaus. Ob cheeb tsam tom kawg muaj ob PIRs thiab tamper tiv thaiv txuas rau hauv lawv (Z3 tswj lub thawv tamper, Z4 siren tamper) Nco tseg qhov sib txawv ntawm qhov hluav taws xob.

3. Koj yuav xav tau 2 tus neeg rau cov kauj ruam tom ntej no. Koj kuj tseem yuav tsum paub PIR nyob hauv cheeb tsam twg. Rov qab mus thiab nyeem qhov hluav taws xob ntawm thawj cheeb tsam. Tam sim no tau txais ib tus neeg hauv koj lub tsev taug kev pem hauv ntej ntawm PIR, qhov hluav taws xob yuav tsum poob. Nco tseg ntawm kev nyeem qhov hluav taws xob tshiab. Hauv kuv qhov xwm txheej, qhov ntsuas hluav taws xob nyeem raws li hauv qab no thaum PIRs tau tshwm sim:

  • Z1 = 0V
  • Z2 = 0V
  • Z3 = 4.30V
  • Z4 = 4.30V

Raws li qhov tau hais los saum no, kuv tuaj yeem pom tias thaum thaj tsam 1 thiab 2 tau ua rau muaj qhov hluav taws xob poob los ntawm 6.65V txog 0V. Txawm li cas los xij thaum thaj tsam 3 thiab 4 tau tshwm sim, qhov hluav taws xob poob los ntawm 7.92V txog 4.30V.

Kev ntsuas hluav taws xob 12V

Peb yuav siv 12V DC lub davhlau ya nyob twg los ntawm lub tswb tswj lub thawv kom txhawb peb txoj haujlwm. Peb yuav tsum ntsuas qhov hluav taws xob los ntawm 12V DC pub ntawm lub tswb. Txawm hais tias nws twb tau hais 12V, peb yuav tsum paub nyeem kom raug dua. Hauv kuv qhov xwm txheej, nws yeej nyeem 13.15V. Sau qhov no, koj yuav xav tau tus nqi no hauv cov kauj ruam tom ntej.

Vim li cas peb thiaj ntsuas qhov hluav taws xob?

Qhov laj thawj peb xav tau los ntsuas qhov ntsuas hluav taws xob rau txhua PIR yog vim lub Circuit Court peb yuav tsim. Peb yuav siv LM339 quad sib piv sib piv nti (lossis quad op-amp sib piv) ua cov khoom siv hluav taws xob tseem ceeb rau txoj haujlwm no. LM339 muaj 4 qhov sib piv qhov ntsuas hluav taws xob ywj pheej (4 raws) qhov twg txhua qhov channel siv 2 x cov khoom siv hluav taws xob (ib qho hloov pauv (-) thiab ib qho tsis hloov pauv (+) cov tswv yim, saib daim duab) Yog tias qhov hluav taws xob ntawm qhov hloov pauv qhov hluav taws xob yuav tsum qis dua qhov tsis hloov pauv qhov hluav taws xob, tom qab ntawd nws cov txiaj ntsig cuam tshuam yuav raug kos rau hauv av. Ib yam nkaus, yog tias qhov tsis hloov pauv qhov hluav taws xob poob qis dua qhov hloov pauv tswv yim, tom qab ntawd cov zis raug rub mus rau Vcc. Yooj yim, hauv kuv lub tsev kuv muaj 4 x tswb PIR's/aav - yog li txhua cheeb tsam yuav txuas mus rau txhua lub channel ntawm tus sib piv. Yog tias koj muaj ntau dua 4 x PIRs, koj yuav xav tau tus sib piv nrog ntau txoj hauv kev, lossis lwm LM339!

Nco tseg: LM339 siv lub zog hauv nano-amps, yog li yuav tsis cuam tshuam rau EOL tsis kam ntawm lub tswb uas twb muaj lawm.

Yog tias qhov no tsis meej pem, txuas ntxiv mus rau cov kauj ruam tom ntej no nws yuav pib nkag siab ntau dua thaum peb xaim nws!

Kauj Ruam 3: Tsim Voltage Divider

Image
Image

Dab tsi yog qhov faib hluav taws xob?

Qhov faib hluav taws xob yog ib qho Circuit Court nrog 2 x resistors (lossis ntau dua) hauv koob. Peb muab qhov hluav taws xob hauv (Vin) rau thawj tus tiv thaiv (R1) Lwm ceg ntawm R1 txuas rau thawj ceg ntawm tus tiv thaiv thib ob (R2), thiab lwm qhov kawg ntawm R2 txuas rau GND. Peb mam li coj qhov hluav taws xob tso tawm (Vout) los ntawm kev sib txuas ntawm R1 thiab R2. Qhov hluav taws xob ntawd yuav dhau los ua peb qhov ntsuas hluav taws xob rau LM339. Yog xav paub ntxiv txog kev faib hluav taws xob ua haujlwm li cas, saib Adohms youtube video

(Nco tseg: resistors tsis muaj polarity, yog li lawv tuaj yeem txuas rau ob txoj hauv kev ib puag ncig)

Xam peb qhov ntsuas hluav taws xob

Piv txwv tias qhov hluav taws xob poob qis thaum koj PIR tau tshwm sim (qhov no yuav tsum yog rooj plaub rau ntau lub tswb) tom qab ntawd peb tab tom sim ua kom tiav, yog kom tau txais qhov ntsuas hluav taws xob nyeem uas zoo nkauj npaum li ib nrab ntawm peb qhov qis qis qis thiab peb qhov ua rau siab tshaj plaws, qhov no yuav dhau los ua peb qhov siv hluav taws xob.

Ua kuv lub tswb ua piv txwv…

Lub cheeb tsam tsis ua haujlwm yog Z1 = 6.65V, Z2 = 6.65V, Z3 = 7.92V, Z4 = 7.92V. Qhov qis qis qis tshaj yog li 6.65V

Lub cheeb tsam ua rau muaj hluav taws xob yog: Z1 = 0V, Z2 = 0V, Z3 = 4.30V, Z4 = 4.30V. Qhov siab tshaj plaws ua rau muaj hluav taws xob yog li 4.30V

Yog li peb yuav tsum xaiv tus lej ib nrab ntawm 4.30V thiab 6.65V (tsis tas yuav yog qhov tseeb, tsuas yog ntxhib) Hauv kuv qhov xwm txheej, kuv qhov ntsuas hluav taws xob xav tau yuav tsum nyob ib puag ncig 5.46V. Nco tseg: Yog tias qis dua qis tshaj plaws thiab ua rau muaj hluav taws xob ntau nyob ze rau ib leeg vim muaj ntau thaj chaw ua rau muaj qhov sib txawv ntawm qhov hluav taws xob, koj yuav xav tsim 2 lossis ntau qhov faib hluav taws xob.

Xam peb qhov ntsuas tus nqi rau qhov faib hluav taws xob

Tam sim no peb muaj qhov ntsuas hluav taws xob siv, peb xav tau los suav qhov loj me resistors peb xav tau los tsim qhov faib hluav taws xob uas yuav muab peb qhov ntsuas hluav taws xob siv. Peb yuav siv 12V DC qhov hluav taws xob qhov hluav taws xob (Vs) los ntawm lub tswb. Txawm li cas los xij, raws li cov kauj ruam dhau los thaum peb ntsuas 12V DC pub peb tau txais 13.15V. Peb yuav tsum tau suav qhov faib hluav taws xob siv tus nqi no ua qhov chaw.

Xam Vout siv txoj cai ohms…

Vout = Vs x R2 / (R1 + R2)

… Lossis siv lub tshuab xam zauv faib hluav taws xob online:-)

Koj yuav tsum tau sim nrog tus nqi tiv thaiv kom txog thaum koj ua tiav qhov koj xav tau. Hauv kuv qhov xwm txheej, nws ua haujlwm nrog R1 = 6.8k ohm thiab R2 = 4.7K ohm, suav ua daim ntawv ntev raws li hauv qab no:

Vout = Vs x R2 / (R1 + R2)

Vout = 13.15 x 4700 / (6800 + 4700)

Vout = 61, 805 /11, 500

Vout = 5.37 V

Kauj Ruam 4: Hlau LM339

Txuas Txuas Wemos D1 Mini
Txuas Txuas Wemos D1 Mini

Voltage Divider rau LM339 inverting inputs

Raws li tau tham ua ntej hais txog LM339 tus sib piv, nws yuav siv 2 x cov tswv yim. Ib qho yuav yog qhov hluav taws xob los ntawm txhua PIR rau txhua txoj hauv kev uas tsis hloov pauv (+) davhlau ya nyob twg, lwm qhov yuav yog peb qhov ntsuas hluav taws xob rau peb qhov hloov pauv (-) davhlau ya nyob twg. Qhov ntsuas hluav taws xob xav tau pub rau txhua 4 tus sib piv hloov pauv cov tswv yim. Fais fab koj lub tswb ua ntej ua cov kauj ruam no.

  • Khiav ib txoj hlua hlau los ntawm 12V DC thaiv ntawm lub tswb ceeb toom rau + tsheb nqaj hlau ntawm koj lub khob cij *
  • Khiav ib txoj hlua hlau los ntawm GND thaiv ntawm lub tswb nrov mus rau - tsheb nqaj hlau ntawm koj lub khob cij **
  • Nruab LM339 tus sib piv nyob hauv nruab nrab ntawm lub khob cij (lub thais qhia tias ze tshaj rau tus pin 1)
  • Nruab 2 x resistors los tsim qhov faib hluav taws xob faib hluav taws xob thiab xaim rau faib qhov hluav taws xob tawm
  • Khiav cov xov hlau los ntawm 'qhov faib hluav taws xob' Vout rau txhua LM339 hloov pauv lub davhlau ya nyob twg

* TSWV YIM: siv tus nab kuab rau lub zog yog tias ua tau, vim qhov no ua rau nws yooj yim dua los muab ON/OFF lub zog rau koj txoj haujlwm ** TSEEM CEEB! MOSFET yuav xav tau yog tias koj tab tom ua lub zog Wemos los ntawm Lub Tswb Tswb! Hauv kuv qhov xwm txheej, LM339, Wemos thiab Tswb txhua tus tau txais lub zog los ntawm tib lub hauv paus (piv txwv li: lub tswb nrov nws tus kheej) Qhov no tso cai rau kuv tig lub zog rau txhua yam nrog kev siv fais fab nkaus xwb. Txawm li cas los xij, los ntawm lub neej ntawd GPIO tus pin ntawm Wemos tau txhais tias yog "INPUT" pins - txhais tau tias lawv siv qhov hluav taws xob twg los xij pov rau ntawm lawv thiab tso siab rau qhov ntawd los muab qib raug ntawm qhov hluav taws xob (min/max qib) kom Wemos yeej ' t tsoo lossis hlawv tawm. Hauv kuv qhov xwm txheej lub tswb tau txais nws lub zog thiab pib ua nws lub khau raj ua ntu zus nrawm heev - qhov tseeb tiag, nws ua qhov no ua ntej Wemos tuaj yeem khau raj thiab tshaj tawm GPIO pins li "INPUT_PULLUP" (qhov hluav taws xob rub tawm sab hauv nti). Qhov no tsis yog qhov sib txawv ntawm qhov hluav taws xob yuav ua rau Wemos tsoo thaum tag nrho cov kab ke tau txais lub zog. Tib txoj hauv kev ib puag ncig nws yuav tsum yog lub zog tua tus kheej thiab ntawm Wemos. Txhawm rau daws qhov no, MOSFET tau ntxiv thiab ua raws li "kev hloov pauv" rau lub zog ntawm LM339. Qhov no tso cai rau Wemos rau khau raj, teeb tsa nws 4 x sib piv GPIO pins ua "INPUT_PULLUP's", ncua ob peb feeb thiab tom qab ntawd (ntawm lwm GPIO tus pin D5 txhais tias yog OUTPUT) xa "HIGH" teeb liab ntawm GPIO pin D5 rau MOSFET, uas muaj qhov hloov pauv LM339 rau. Kuv yuav pom zoo thaiv kab ntawv raws li hais saum toj no, tab sis yog tias koj pom tias Wemos sib tsoo zoo li kuv tau ua, tom qab ntawd koj yuav tsum suav nrog MOSFET nrog 1k ohm rub nqes resistor. Yog xav paub ntxiv txog yuav ua li cas, saib qhov kawg ntawm cov lus qhia no.

Tswb zones rau LM339 cov khoom siv tsis hloov pauv

Tam sim no peb yuav tsum tau khiav cov xov hlau los ntawm txhua thaj tsam ntawm lub tswb tswj vaj huam sib luag rau LM339 cov khoom sib piv. Nrog lub tswb nrov tseem siv hluav taws xob, rau txhua thaj tsam pub cov xaim rau txhua qhov tsis hloov pauv (+) cov tswv yim ntawm LM339 tus sib piv. Piv txwv li, hauv kuv qhov system:

  • Hlau los ntawm Z1 mus rau LM339 cov tswv yim 1+
  • Hlau los ntawm Z2 mus rau LM339 cov tswv yim 2+
  • Hlau los ntawm Z3 mus rau LM339 cov tswv yim 3+
  • Hlau los ntawm Z4 mus rau LM339 cov tswv yim 4+

Xa mus rau tus pin-out ntawm LM339 hauv qab kauj ruam 3 yog tias koj ceeb toom (nws yog xim coded nrog daim duab daim duab) Thaum ua tiav, koj daim ntawv qhia zaub mov yuav tsum zoo ib yam li cov duab qhia hauv theem no.

Fais fab ntawm lub tswb ntsuas thiab ntsuas qhov hluav taws xob tawm ntawm qhov faib hluav taws xob kom ntseeg tau tias nws sib npaug koj qhov ntsuas hluav taws xob raws li tau suav ua ntej.

Kauj Ruam 5: Txuas Txuas Wemos D1 Mini

Txuas lub Wemos D1 mini

Tam sim no peb muaj tag nrho LM339 cov tswv yim tau saib xyuas, tam sim no peb yuav tsum tau xaim hauv Wemos D1 mini. Txhua tus LM339 tus pin tso tawm mus rau Wemos GPIO (lub hom phiaj dav dav nkag/tso tawm) tus pin uas peb yuav xaiv los ntawm tus lej raws li tus lej nkag nkag. Wemos siv sijhawm txog 5V qhov siab tshaj plaws raws li nws Vcc (cov khoom siv nkag mus) qhov hluav taws xob (txawm hais tias tswj hwm qhov no sab hauv mus rau 3.3V) Peb yuav siv LM7805 tus tswj hluav taws xob ntau heev (EDIT: saib hauv qab) kom tso lub tsheb nqaj hlau 12V ntawm lub khob cij nqes mus rau 5V rau lub zog rau Wemos. Cov ntaub ntawv rau LM7805 qhia tias peb xav tau lub tshuab hluav taws xob txuas rau ntawm txhua sab ntawm tus tswj hwm kom ua kom lub zog muaj zog, raws li tau qhia hauv daim duab duab. Cov ceg ntev dua ntawm tus capacitor yog qhov zoo (+) yog li ua kom ntseeg tau tias qhov no tau xaim nyob ib puag ncig txoj hauv kev.

Tus tswj hwm qhov hluav taws xob siv hluav taws xob hauv (sab laug tus pin), hauv av (tus pin nruab nrab) thiab qhov hluav taws xob tawm (sab xis tus pin) Ob zaug kos tus pin-tawm yog tias koj qhov ntsuas hluav taws xob sib txawv los ntawm LM7805.

(Kho: Kuv pom cov amps los ntawm lub tswb vaj huam sib luag tau siab dhau rau LM7805 los tswj. Qhov no tau ua rau muaj cua sov ntau hauv cov cua sov me me ntawm LM7805 thiab ua rau nws ua tsis tiav, thiab ua rau Wemos nres Kuv hloov LM7805 thiab cov khoom siv nrog DC-DC phaw hloov pauv thiab tsis muaj teeb meem txij li. thiab kho kom txog thaum qhov hluav taws xob tso tawm yog ~ 5V)

GPIO input pins

Rau qhov haujlwm no, peb siv cov pins hauv qab no:

  • Z1 => pin D1
  • Z2 => pin D2
  • Z3 => pin D3
  • Z4 => pin D5

Hlau tawm cov txiaj ntsig los ntawm LM339, mus rau qhov cuam tshuam GPIO pins ntawm Wemos board, raws li daim duab daim duab qhia hauv cov kauj ruam no. Ib zaug ntxiv, Kuv tau xim xim cim cov tswv yim thiab sib piv cov txiaj ntsig, kom yooj yim pom qhov hais txog dab tsi. Txhua tus GPIO tus pin hauv Arduino tau txhais tias yog 'INPUT_PULLUP', txhais tau tias lawv yuav raug rub mus txog 3.3V hauv kev siv ib txwm muaj (IDLE) thiab LM339 yuav rub lawv mus rau hauv av yog PIR tau tshwm sim. Txoj cai ntsuas pom HIGH rau LOW hloov pauv, thiab xa xov tsis siv rau koj lub khoos phis tawj siv hluav taws xob hauv tsev. Yog tias koj muaj teeb meem nrog kev ua haujlwm no, nws muaj peev xwm koj muaj koj cov inverting vs non-inverting inputs qhov tsis raug ib puag ncig (yog tias qhov hluav taws xob los ntawm koj PIR nce siab thaum ua rau, zoo li tshwm sim nrog feem ntau nyiam PIR's, tom qab ntawd koj yuav xav tau kev sib txuas lwm txoj kev ncig)

Arduino IDE Cov

Tshem tawm Wemos los ntawm lub khob cij, tam sim no peb yuav tsum tau xa cov cai rau nws (hloov pauv txuas ntawm no) Kuv yuav tsis mus qhia ntxaws txog yuav ua li cas, vim tias muaj ntau cov kab lus ntawm lub vev xaib ntawm kev xa cov cai rau Wemos lossis lwm yam ESP8266 hom laug cam. Txuas koj lub USB cable rau Wemos board thiab rau hauv koj lub PC thiab tua Arduino IDE. Rub tawm cov cai thiab qhib nws hauv koj qhov project. Koj yuav tsum ua kom ntseeg tau lub rooj tsav xwm raug teeb tsa thiab thauj khoom rau koj txoj haujlwm nrog rau qhov raug xaiv COM chaw nres nkoj (Cov Cuab Yeej, Chaw Nres Nkoj). Koj tseem yuav xav tau cov tsev qiv ntawv tsim nyog tau teeb tsa (PubSubClient, ESP8266Wifi) Kom tau txais Wemos board nrog rau hauv koj daim duab, saib kab lus no.

Koj yuav tsum tau hloov cov kab hauv qab no, thiab hloov nrog koj tus kheej SSID thiab tus lej cim rau koj kev sib txuas wireless. Tsis tas li, hloov tus IP chaw nyob rau taw tes rau koj tus kheej MQTT tus tswv lag luam.

// Wi -nkaus

const char* ssid = "koj_wifi_ssid_here"; const char* password = "your_wifi_password_here"; // MQTT Broker IPAddress MQTT_SERVER (172, 16, 223, 254)

Thaum hloov pauv, txheeb xyuas koj cov cai tom qab ntawv rub tawm mus rau Wemos board ntawm USB cable.

Sau ntawv:

  • Yog tias koj siv cov chaw nres nkoj GPIO sib txawv, koj yuav tsum tau kho qhov chaws. Yog tias koj siv ntau dua lossis tsawg dua thaj chaw tshaj li kuv muaj, koj kuj yuav tsum tau kho cov cai thiab TOTAL_ZONES = 4; tas li kom haum.
  • Hauv qab pib ntawm kuv lub tswb ceeb toom, lub tswb ceeb toom yuav ua lub zog ntsuas rau txhua 4 x PIRs uas rub txhua qhov txuas nrog GPIO rau hauv av, ua rau Wemos xav tias thaj chaw tau tshwm sim. Txoj cai yuav tsis quav ntsej xa MQTT cov lus yog tias nws pom txhua 4 x thaj chaw nquag nyob rau tib lub sijhawm, vim nws xav tias lub tswb nrov tau qhib lub zog.

Hloov qhov txuas txuas rau tus lej NTAWM NO

Kauj Ruam 6: Kuaj thiab OpenHAB Kev Kho

Kev Xeem thiab OpenHAB Kev Kho
Kev Xeem thiab OpenHAB Kev Kho

MQTT Xeem

MQTT yog "sau npe / tshaj tawm" kev xa xov. Ib lossis ntau lub cuab yeej tuaj yeem tham nrog "MQTT broker" thiab "sau npe" rau qee yam ncauj lus. Txhua cov lus xa los ntawm lwm lub cuab yeej uas "tshaj tawm" rau tib lub ncauj lus, yuav raug thawb tawm los ntawm tus tswv lag luam rau txhua lub cuab yeej uas tau sau npe rau nws. Nws yog qhov hnyav heev thiab yooj yim rau siv raws tu qauv thiab zoo meej raws li cov txheej txheem yooj yim xws li ib qho ntawm no. Txog kev sim, koj tuaj yeem saib cov lus MQTT los ntawm Wemos rau koj tus broker MQTT los ntawm kev ua cov lus txib hauv qab no ntawm koj Mosquitto server (Mosquitto yog ib ntawm ntau MQTT Broker software muaj). Cov lus txib no sau npe nkag rau cov lus khaws cia khaws cia:

mosquitto_sub -v -t openhab/tswb/xwm txheej

Koj yuav tsum pom cov lus nkag los ntawm Wemos txhua 30 feeb lossis ntau dua nrog tus lej "1" (lub ntsiab lus "Kuv muaj txoj sia nyob") Yog tias koj pom tas li "0's" (lossis tsis muaj lus teb) ces tsis muaj kev sib txuas lus. Thaum koj pom tus lej 1 los rau hauv, tom qab ntawd nws txhais tau tias Wemos tab tom sib tham nrog MQTT tus broker (tshawb "MQTT Lub Xeem Yuav thiab Phau Testament" kom paub ntau ntxiv txog qhov no ua haujlwm li cas, lossis pom qhov no zoo blog nkag)

Thaum koj tau ua pov thawj tias kev sib txuas lus ua haujlwm tau zoo, peb tuaj yeem sim tias lub xeev cheeb tsam tau tshaj tawm los ntawm MQTT. Sau npe yuav ua rau cov ncauj lus hauv qab no (tus # yog daim npav loj)

mosquitto_sub -v -t openhab/tswb/#

Cov xwm txheej ib txwm yuav tsum tuaj, zoo li yuav tsum yog IP chaw nyob ntawm Wemos nws tus kheej. Taug kev pem hauv ntej ntawm PIR, thiab koj yuav tsum pom cov ntaub ntawv hauv cheeb tsam tuaj qhia tias nws qhib, tom qab ntawd thib ob lossis tom qab ntawd, nws tau kaw, zoo ib yam li hauv qab no:

openhab/tswb/xwm txheej 1

openhab/tswb/cheeb tsam 1 Qhib

openhab/tswb/cheeb tsam 1 Kaw

Thaum qhov no ua haujlwm, peb tuaj yeem teeb tsa OpenHAB kom muaj qhov no zoo sawv cev hauv GUI.

OpenHAB Configuration

Cov kev hloov pauv hauv qab no xav tau rau OpenHAB:

'alarm.map' hloov pauv cov ntaub ntawv: (yeem, rau kev sim)

Kaw = IdleOPEN = TriggeredNULL = Unknown- = Tsis paub

'status.map' hloov cov ntaub ntawv:

0 = Ua tsis tau

1 = Online -= DAWB! NULL = tsis paub

'cov khoom' file:

String alarmMonitorState "Alarm Monitor [MAP (status.map):%s]" {mqtt = "<[mqttbroker: openhab/alarm/status: state: default]"} String alarmMonitorIPAddress "Tswb Saib IP [%s]" {mqtt = "<[mqttbroker: openhab/alarm/ipaddress: state: default]"} Number zone1_Chart_Period "Zone 1 Chart" Hu rau alarmZone1State "Zone 1 State [MAP (alarm.map):%s]" {mqtt = "<[mqttbroker: openhab/alarm/zone1: state: default "} String alarmZone1Trigger" Lounge PIR [%1 $ ta%1 $ tr] "Number zone2_Chart_Period" Zone 2 Chart "Contact alarmZone2State" Zone 2 State [MAP (alarm.map):% s] "{mqtt =" <[mqttbroker: openhab/alarm/zone2: state: default "} String alarmZone2Trigger" First Hall PIR [%1 $ ta %1 $ tr] "Number zone3_Chart_Period" Zone 3 Chart "Hu rau alarmZone3State" Zone 3 State [MAP (alarm.map):%s] "{mqtt =" <[mqttbroker: openhab/alarm/zone3: state: default "} String alarmZone3Trigger" Chav pw PIR [%1 $ ta%1 $ tr] " zone4_Chart_Period "Zone 4 Chart" Hu rau alarmZone4State "Zone 4 State [MAP (alarm.map):%s]" {mqtt = "<[mqttbroker: openha b/tswb/thaj tsam 4: xeev: lub neej ntawd "} Txoj hlua alarmZone4Trigger" Lub Tsev Loj PIR [%1 $ ta %1 $ tr]"

'sitemap' cov ntaub ntawv (suav nrog rrd4j teeb duab):

Text item = alarmZone1Trigger valuecolor = [<= 60 = "#ff0000", <= 300 = "#ffa500", <= 600 = "#008000", 3600 = "#000000"] {Ncej {Hloov khoom = zone1_Chart_Period daim ntawv lo = "Lub Sijhawm" mappings = [0 = "Teev", 1 = "Hnub", 2 = "Lub Hli"] Duab url = "https:// localhost: 8080/rrdchart.png" pom kev = [zone1_Chart_Period == 0, zone1_Chart_Period = = Uninitialized] Duab url = "https:// localhost: 8080/rrdchart.png" visibility = [zone1_Chart_Period == 1] Duab url = "https:// localhost: 8080/rrdchart.png" visibility = [zone1_Chart_Period == 2]}} Text item = alarmZone2Trigger valuecolor = [<= 60 = "#ff0000", <= 300 = "#ffa500", <= 600 = "#008000", 3600 = "#000000"] {Ncej {Hloov khoom = zone2_Chart_Period label = "Period" mappings = [0 = "Hour", 1 = "Day", 2 = "Week"] Image url = "https:// localhost: 8080/rrdchart.png" visibility = [zone2_Chart_Period == 0, zone2_Chart_Period == Uninitialized] Duab url = "https:// localhost: 8080/rrdchart.png" visibility = [zone2_Chart_Period == 1] Duab url = "https:// localhost: 8080/rrdchart.png" visibility = [zone2_Chart_Period == 2]}} Cov ntawv nyeem = tswbZone3Trigger valuecolor = [<= 60 = "#ff0000", <= 300 = "#ffa500", <= 600 = "#008000", 3600 = "#000000"] {Ncej {Hloov cov khoom = zone3_Chart_Period daim ntawv lo = "Sijhawm" daim ntawv qhia = [0 = "Teev", 1 = "Hnub", 2 = "Lub Hli"] Duab url = "https:// localhost: 8080/rrdchart.png" pom kev = [zone3_Chart_Period == 0, zone3_Chart_Period == Uninitialized] Duab url = "https:// localhost: 8080/rrdchart.png" visibility = [zone3_Chart_Period == 1] Duab url = "https:// localhost: 8080/rrdchart.png" visibility = [zone3_Chart_Period == 2]}} Ntawv item = alarmZone4Trigger valuecolor = [<= 60 = "#ff0000", <= 300 = "#ffa500", <= 600 = "#008000", 3600 = "#000000"] {Ncej {Hloov khoom = zone4_Chart_Period daim ntawv lo = " Lub sijhawm "mappings = [0 =" Teev ", 1 =" Hnub ", 2 =" Lub Hli "] Duab url =" https:// localhost: 8080/rrdchart.png "pom kev = [zone4_Chart_Period == 0, zone4_Chart_Period == Uninitialized] Duab url = "https:// localhost: 8080/rrdchart.png" visibility = [zone4_Chart_Period == 1] Duab url = "https:// localhost: 8080/rrdchart.png" visibility = [zone4_Chart_Period == 2] }} // YOOJ YIM tab sis siv tau rau kev txheeb xyuas xwm txheej thiab tus IP ntxiv ss Text item = alarmMonitorState Text item = alarmMonitorIPAddress

cov cai 'file:

txoj cai "Tswb Zos 1 lub xeev hloov pauv"

thaum Yam khoom ceeb toom Zone1State hloov mus rau Qhib tom qab ntawd postUpdate (tswb Zone1Trigger, Hnub Tim Tshiab Sijhawm Tshiab ()) tswbZone1State.state = kaw kawg

txoj cai "Tswb Zos 2 lub xeev hloov pauv"

thaum Yam khoom ceeb toom Zone2State hloov mus rau Qhib tom qab ntawd postUpdate (tswb Zone2Trigger, Hnub Tim Tshiab Sijhawm Tshiab ()) tswbZone2State.state = kaw kawg

txoj cai "Tswb Zos 3 lub xeev hloov pauv"

thaum Yam khoom ceeb toom Zone3State hloov mus rau Qhib tom qab ntawd postUpdate (tswbZone3Trigger, Hnub Tim Tshiab Sijhawm Tshiab ()) tswbZone3State.state = kaw kawg

txoj cai "Tswb Zone 4 xeev hloov"

thaum Yam khoom ceeb toom Zone4State hloov mus rau Qhib tom qab ntawd postUpdate (tswbZone4Trigger, Hnub Tim Tshiab Sijhawm Tshiab ()) tswbZone4State.state = kaw kawg

Koj yuav xav hloov pauv OpenHAB teeb tsa me ntsis kom haum rau koj tus kheej teeb tsa.

Yog tias koj muaj teeb meem nrog PIRs tau tshwm sim ces pib txij thaum pib, thiab ntsuas qhov ntsuas hluav taws xob rau txhua feem ntawm Circuit Court. Thaum koj zoo siab nrog qhov ntawd, txheeb xyuas koj cov xov hlau, xyuas kom muaj ib qho hauv av, txheeb xyuas cov lus ntawm Wemos ntawm lub khoos phis tawj debug, txheeb xyuas MQTT kev sib txuas lus thiab tshawb xyuas cov syntax ntawm koj hloov pauv, cov khoom thiab cov ntaub ntawv sitemap.

Hmoov zoo!

Pom zoo: