Cov txheej txheem:

Wifi rau RF - Qhov Rooj Xauv: 3 Kauj Ruam (nrog Duab)
Wifi rau RF - Qhov Rooj Xauv: 3 Kauj Ruam (nrog Duab)

Video: Wifi rau RF - Qhov Rooj Xauv: 3 Kauj Ruam (nrog Duab)

Video: Wifi rau RF - Qhov Rooj Xauv: 3 Kauj Ruam (nrog Duab)
Video: ? Что такое многополосный 6 атомный хронометраж ? То 2024, Hlis ntuj nqeg
Anonim
Wifi rau RF - Qhov Rooj Xauv
Wifi rau RF - Qhov Rooj Xauv
Wifi rau RF - Qhov Rooj Xauv
Wifi rau RF - Qhov Rooj Xauv
Wifi rau RF - Qhov Rooj Xauv
Wifi rau RF - Qhov Rooj Xauv

Txheej txheem cej luam

Cov lus qhia no yuav ua rau koj muaj peev xwm xauv / qhib koj lub qhov rooj ntawm koj lub tsev siv lub tshuab siv tshuab (xws li OpenHAB - software pub dawb hauv tsev uas kuv tus kheej siv) Cov duab saum toj no qhia pom piv txwv ntawm OpenHAB iPhone app. Hloov koj tuaj yeem siv MQTT kev xa xov raws li tau piav qhia hauv qab no hauv yuav luag txhua lub system koj xav tau.

Kev xav

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

  • OpenHAB (pub dawb qhib qhov cuab yeej siv tshuab hauv tsev) ua haujlwm, txawm hais tias tau hais los, nws yuav tsum ua haujlwm nrog txhua lub tshuab siv hluav taws xob hauv tsev 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 binding tau teeb tsa thiab teeb tsa nrog OpenHAB (MQTT yog kev xa xov xa tawm/tshaj tawm hom kev cai uas yog qhov hnyav thiab zoo rau kev sib txuas lus ntawm cov khoom siv)
  • Tias koj twb tau teeb tsa RF raws lub qhov rooj ntawm lub qhov rooj kaw qhov rooj uas los nrog tsawg kawg ib qho yuam sij fob tej thaj chaw deb (feem ntau ua) Cov no tuaj yeem yuav tau tus nqi pheej yig ntawm Amazon (kwv yees ~ US $ 60, txawm hais tias lub roj teeb ntawm tus qauv no tsuas yog kawg ~ 4 lub hlis yog li pom tias koj tuaj yeem muab DC uas ua rau lub zog kaw lossis siv me ntsis ntxiv ntawm tus qauv tsim nyog:-))

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

Taw qhia

Txoj haujlwm no tshwj xeeb qhia koj yuav siv RF li cas lub qhov rooj kaw KEY FOB kom muaj txiaj ntsig ntau dua los ntawm kev hloov nws mus ua haujlwm wirelessly, yog li muab koj lub peev xwm los xauv lossis qhib koj lub qhov rooj ntawm koj lub tsev siv tshuab, lub vev xaib, koj lub xov tooj (dhau ntawm OpenHAB app) lossis tseem teem sijhawm rau nws pib kaw thaum hmo ntuj siv cov cai hauv kev siv tshuab hauv tsev. Txog qhov haujlwm no, Kuv yuav "Mi RF raws lub pob qhov rooj kaw lub qhov rooj" tawm ntawm Amazon txog $ 60 *

(* Kho: cov roj teeb ntawm cov khoom tshwj xeeb ntawm lub qhov rooj xauv tsis nyob ntev li ntawd! rau Windsor muaj lub qhov rooj kaw hluav taws xob kaw uas lub roj teeb kav ntev txog 2 xyoos. Hloov pauv, txawm tias ua haujlwm ntau dua, txiav txim siab khiav DC lub zog los ntawm cov tub ntxhais ntawm koj lub qhov rooj mus rau lub xauv)

Rau qhov lawv muab RF (xov tooj cua zaus) ua lub qhov rooj xauv nrog lub hauv xov tooj cua thiab tus yuam sij fob rau kev xauv / qhib lub chaw deb. Nrog RF txawm li cas los xij, qhov tseem ceeb fob xav tau nyob hauv ntau ntawm lub qhov rooj kaw. Txoj haujlwm no yuav siv tus yuam sij fob los ntawm kev koom ua ke nrog Wemos (IOT board nrog ESP8266 nti) los ua qhov xauv / qhib lub wirelessly, yog li tswj tau los ntawm txhua qhov chaw koj muaj Internet txuas.

Kuv xav tau dab tsi?

Ua ntej tshaj, yuav thiab teeb tsa RF raws tus lej ntsuas phoo. Koj yuav tsum paub tseeb tias nws los nrog tus yuam sij fob! Kuaj lub fob thiab xyuas kom meej tias los ntawm nias lub pob, nws yuav xauv lossis qhib lub qhov rooj ua ntej pib. Feem ntau ntawm cov qhov rooj xauv no yuav tsum ua raws tus qauv qhov rooj qhov rooj thiab xauv lub xauv yog li yog tias koj twb muaj lub qhov rooj tuag (zoo li kuv tau ua) hloov nws yog qhov yooj yim tshwj xeeb.

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) lossis tsuas yog ESP8266 CHIP yuav tsum ua (Kuv tsis pom zoo ESP-01 version rau txoj haujlwm no, raws li GPIO 0 tus pin xav tau los tuav lub zog kom siab rau nws kom khau raj los ntawm nyem, txawm li cas los xij ua qhov no yuav ua rau lub qhov rooj kaw thaum ESP8266 lub zog tuaj yeem qhib lub qhov rooj ntawm koj lub qhov rooj! ntawm Wemos thiab cov khoom siv tsawg dua, peb yuav tsom mus rau txoj hauv kev yooj yim dua)
  • 5V DC lub zog siv hluav taws xob rau lub zog Wemos thiab Keyfob (cov roj teeb yuav tsis xav tau ntxiv) Yog tias koj tab tom ua haujlwm rau Wemos siv 5V VCC tus pin (ntau dua li qhov chaw nres nkoj USB) thiab DC lub zog hluav taws xob siab dua 5V, koj yuav kuj tseem xav tau 5V tus tswj hluav taws xob (xws li LM7805) ntxiv rau 2 x capacitors, 10V 0.33uF thiab 10V 0.1uF lossis zoo sib xws (raws li LM7805 cov ntawv)
  • Ob 2N7000 lossis MOSFETs zoo sib xws (cov no yuav raug siv los hloov keyfob, ib qho rau xauv, lwm qhov rau kev qhib. 2N7000 yog qhov ntau heev thiab pheej yig txhim kho hom N-Channel MOSFET yog li yuav tsum yooj yim heev rau qhov chaw)

  • Ob tus 10K ohm resistors (cov no yuav siv los ua rub tawm rau txhua qhov ntawm MOSFETs yog li lub qhov rooj xauv / qhib tsis tau ua rau lub zog nce!)
  • D ua haujlwm ntawm koj lub keyfob, koj kuj tseem yuav xav tau xaim hauv lwm lub capacitor (xws li 10V 220uF lossis zoo ib yam me me) los pab txhawb lub zog rau lub keyfob. Saib yog vim li cas tom qab hauv kab lus no.
  • Cov cuab yeej xav tau: sab txiav, ib leeg tub ntxhais hlau, hlau txuas, hloov pauv thiab xaiv tau ntau lub ntsuas

Tus yuam sij fob nws tus kheej feem ntau siv 2 x 3V roj teeb hauv koob (6V Vcc) Yog li ntawd, siv 5V cov khoom siv nrog lub tshuab hluav taws xob txawm li cas los xij yog qhov hluav taws xob txaus rau ob lub zog Wemos thiab ua rau lub xauv / qhib.

Yog tias koj muaj keyfob uas ua haujlwm tawm ntawm ib lub roj teeb 3V, tom qab ntawd koj yuav tsum muaj peev xwm ntxiv 3.3V tus tswj hluav taws xob hauv koj lub Circuit Court kom poob qhov hluav taws xob ze rau 3V xav tau. Lub roj teeb 3V ua tau zoo nyob ib puag ncig 3.1V, thiab feem ntau cov hluav taws xob muaj qee yam ntawm kev ua kom muaj hluav taws xob siab dua, yog li hauv qhov piv txwv 3.1V txog 3.3V yog +6%. Ua ke nrog qhov tseeb Wemos tau teeb duab tam sim no, yog li qhov voltage yuav zoo li txawm tias tsawg dua. Yog tias tsis ntseeg ntsuas nrog lub ntsuas hluav taws xob thiab yog ua tau, txheeb xyuas nrog tus muag khoom ntsuas qhov siab tshaj qhov siab (lossis siab tshaj qhov ua siab ntev) tus keyfob yuav lees txais, vim kuv tsis muaj lub luag haujlwm yog tias koj lub keyfob tsis ua haujlwm! Thaum kawg, raws li kev daws teeb meem hloov teeb hluav taws xob faib hluav taws xob hloov pauv.

Kauj ruam 1: Sib dhos

Los ua ke
Los ua ke
Los ua ke
Los ua ke
Los ua ke
Los ua ke

Soldering

Sib dhos cov khoom siv yog yooj yim heev. Ua ntej tshaj, qhib qhov tseem ceeb fob - tshem cov roj teeb thiab cov ntaub ntawv raws li koj tsuas xav tau lub rooj tsav xwm hauv tsev. Tom ntej txuas tus xaim ntawm txhua sab ntawm ob txhais ceg ntawm qhov tseem ceeb fob khawm. Ua qhov no rau ob qho tib si "xauv" khawm thiab "qhib" khawm. Tom ntej no, tig lub fob dua thiab muab xaim rau ntawm + thiab - cov ntaub qhwv nyob tom qab ntawm lub fob, raws li qhia hauv cov duab. Lub ncoo loj dua yog +, qhov me dua yog -

Nco tseg: Lub zog 5V yuav ua rau lub zog Wemos thiab Key fob, yog li cov roj teeb fob tsis xav tau ntxiv lawm.

Los ua ke

Muab 5V Vcc thiab GND rau Wemos thiab ntxiv MOSFETs thiab cov tshuaj tiv thaiv rau lub khob cij raws li daim duab. 10K ohm resistors yuav tsum khiav los ntawm GND mus rau lub rooj vag (nruab nrab tus pin) ntawm MOSFETs. Qhov no yuav rub qhov hluav taws xob mus rau hauv av nres MOSFETs tau ua rau lub zog nce.

Tom ntej no txuas xov hlau los ntawm D1 ntawm Wemos mus rau lub rooj vag ntawm thawj MOSFET thiab D2 ntawm Wemos mus rau lub rooj vag ntawm MOSFET thib ob. D1 thiab D2 yog GPIO (cov hom phiaj dav dav nkag/tso tawm) pins uas raug xaiv ua OUTPUT pins hauv txoj cai.

Thaum kawg, ntsaws cov keyfob xov hlau mus rau ntawm lub khob cij, Vcc mus rau 5V txoj kev tsheb nqaj hlau, GND rau GND, tom qab ntawd xaim ntawm qhov tsis zoo ntawm lub khawm mus rau qhov chaw sab ntawm txhua MOSFET thiab sab zoo ntawm lub pob mus rau sab sab ntawm txhua MOSFET raws li qhia hauv daim duab (siv lub multimeter yog tias tsis paub meej ntawm polarity)

(Kho: Hloov Windsor qhov rooj kaw qhov kuv tau hais ua ntej, muaj lub keyfob uas tau siv hluav taws xob me ntsis ntau dua li qub keyfob. Qhov no ua rau Wemos ua kom tsis txhob teb zoo vim qhov hluav taws xob poob rau nws, thaum lub qhov rooj raug xauv/qhib. koj ntsib qhov teeb meem qub, tom qab ntawd txhawm rau kho cov xaim hauv 220uF (lossis zoo sib xws) lub tshuab ua ntej ua ntej +/- txuas uas tawm mus rau keyfob. Lub capacitor yuav tsub nqi thiab thaum ua rau, tso lub capacitor ntau dua li ncaj qha DC zog)

Tam sim no ntsaws USB cable rau hauv Wemos thiab lwm qhov kawg ntawm kab lus rau hauv koj lub computer.

(Txoj cai yuav tso tus pin D1 "HIGH", ua rau MOSFET tig los tso cai rau qhov hluav taws xob mus los ntawm cov dej ntws mus rau qhov chaw thiab yog li ntawd, "hloov" lub pob rau 1 thib ob ua ntej nqa tus pin tso tawm "LOW" dua thiab hloov nws tawm Qhov ua tau zoo, nws tsuas yog simulating qhov tseem ceeb ntawm lub pob ntawm cov cai)

Arduino IDE Cov

Tua tawm Arduino IDE. Rub tawm thiab qhib cov cai (txuas txuas ntxiv ntawm no) Ua kom ntseeg tau tias cov laug cam ntxiv tau suav nrog hauv IDE, saib ntawm no yuav teeb tsa li cas. Tom qab ntawd koj yuav tsum ua kom lub rooj tsav xwm raug teeb tsa thiab thauj khoom rau koj txoj haujlwm (Cov cuab yeej, Cov laug cam, Tus Thawj Saib Xyuas Haujlwm - tshawb "esp8266" thiab teeb tsa) ntxiv rau qhov chaw nres nkoj COM raug xaiv (Cov Cuab Yeej, Chaw Nres Nkoj, COM …). Koj tseem yuav xav tau cov tsev qiv ntawv tsim nyog PubSubClient thiab ESP8266Wifi teeb tsa (Sketch, Tswj Tsev Qiv Ntawv, suav nrog Tsev Qiv Ntawv …)

Tom ntej no, hloov cov kab hauv qab no ntawm tus lej, thiab hloov nrog koj tus kheej SSID thiab tus lej zais 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. Yog tias koj tsis muaj MQTT broker teeb tsa, Kuv pom zoo siv Mosquitto. Rub tawm rau Windows lossis Linux ntawm no.

// Wificonst char* ssid = "your_wifi_ssid_here"; const char* password = "your_wifi_password_here"; // MQTT Broker IPAddress MQTT_SERVER (192, 168, 222, 254);

Thaum hloov pauv, txheeb xyuas koj cov cai tom qab ntawd rub mus rau Wemos / ESP8266 lub rooj tsavxwm ntawm USB cable.

Kauj Ruam 2: Kuaj thiab OpenHAB Kev Kho

Kev Xeem thiab OpenHAB Kev Kho
Kev Xeem thiab OpenHAB Kev Kho
Kev Xeem thiab OpenHAB Kev Kho
Kev Xeem 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 mus rau lwm lub cuab yeej uas tau sau npe rau lub ncauj lus ntawd. 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. Saib daim duab ntws rau lub tswv yim ntxhib ntawm nws ua haujlwm li cas.

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/frontdoor/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, tam sim no koj tuaj yeem taug qab qhov tseeb "txhais" (xauv/qhib) cov lus. Ua ntej tshaj npe rau cov ncauj lus hauv qab no.

mosquitto_sub -v -t openhab/frontdoor/trigger

Tam sim no qhib kab lus thib ob qhov rai thiab khiav cov lus txib tshaj tawm hauv qab no, xa cov ncauj lus ntawm "LOCK" lossis "UNLOCK". Koj yuav tsum pom cov lus sib tham tshwm nyob rau thawj lub qhov rai thiab koj tseem yuav tsum pom lub teeb liab liab teeb nyem ntawm lub keyfob thiab lub qhov rooj kaw qhov rooj lossis xauv raws li xav tau.

mosquitto_pub -t openhab/frontdoor/trigger -m LOCK

(-t txhais tau tias 'ncauj lus', -m txhais tau tias 'lus', -v txhais tau tias 'hais lus' tso tawm)

Nco tseg: Yog lub qhov rooj qhib thaum koj xa xauv lossis xauv thaum koj xa cov lus txib qhib, tsuas yog hloov D1 thiab D2 xov nyob ib puag ncig

OpenHAB kev teeb tsa

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

'cov khoom' file:

Hloov frontdoorTrigger "Front Door" (gDoors) {mqtt = "> [mqttbroker: openhab/frontdoor/trigger: command: ON: LOCK],> [mqttbroker: openhab/frontdoor/trigger: command: OFF: UNLOCK]"} Number frontdoorStatus "Hauv Qhov Rooj [MAP (xwm txheej.map):%d]" (gDoors) {mqtt = "<[mqttbroker: openhab/frontdoor/status: state: default]"}

'sitemap' cov ntaub ntawv:

Hloov cov khoom = frontdoorTrigger mappings = [ON = "Xauv", OFF = "Xauv"] Cov ntawv nyeem = frontdoorStatus

'status.map' cov ntaub ntawv (hauv kev hloov pauv nplaub tshev):

0 = Down1 = Ciaj sia- = tsis paub

Koj yuav xav hloov pauv OpenHAB teeb tsa me ntsis kom haum rau koj tus kheej teeb tsa, xws li "mqttbroker:" ib feem uas hais txog koj lub npe MQTT tus tsim khoom.

Daim duab kawg qhia pom cov khoom ntawm PCB. Hauv qhov no, vim tias kuv tab tom siv DC lub zog xa khoom uas yog> 5V (hauv kuv rooj plaub 9V) pawg thawj coj kuj suav nrog LM7805 tus tswj hluav taws xob ntxiv rau 0.33uF capacitor rau lub zog sab thiab 0.1uF capacitor ntawm lub zog tawm sab los pab kom du thiab ruaj khov qhov hluav taws xob. Txwv tsis pub seem ntawm kev sib txuas yog tib yam li tau piav ua ntej.

Teeb meem

- Yog tias koj muaj teeb meem qhov twg Wemos kaw tsis tu ncua lossis qhib lub qhov rooj (piv txwv li: xa lub teeb liab RF thiab LED teeb ntawm tus yuam sij fob nyob twj ywm) tom qab ntawd xyuas koj VCC thiab GND xov hlau rau Wemos. Muaj feem yog, ib lossis ob qho ntawm cov no tsis txuas nrog kom raug.

Kauj Ruam 3: Muab Cov Khoom Txhim Kho rau PCB

Solder Up Cheebtsam rau PCB
Solder Up Cheebtsam rau PCB
Solder Up Cheebtsam rau PCB
Solder Up Cheebtsam rau PCB

Kuv xaus qhov muag tag nrho cov khoom sib txuas mus rau PCB, tsuas yog siv cov xov hlau thiab/lossis cov kab laug sab los koom nrog txhua yam khoom siv. Tom qab ntawd kuv tau txais lub qub DC phab ntsa wart thiab txiav cov hlau los ntawm nws luv dua me ntsis, tom qab ntawd khiav mus rau qhov txuas txuas uas kuv tau muab txuas rau PCB. Lub zog tom qab ntawd tawm mus rau 5V qhov ntsuas hluav taws xob / lub tshuab hluav taws xob thiab cov khoom tsim nyog. Kuv yooj yim xiav-tsoo lub nraub qaum ntawm PCB rau ntawm phab ntsa wart, thiab ntsaws nws rau hauv lub hwj chim taw tes sab hauv ib qho ntawm kuv lub txee rau khoom. Nws tau ua haujlwm tam sim no txog 9 lub hlis yam tsis muaj teeb meem!

Pom zoo: