Cov txheej txheem:

Los ntawm lub teeb nyem mus rau Tsab ntawv tsa suab Sensor nrog ESP8266 thiab MQTT: 5 Cov Kauj Ruam (nrog Duab)
Los ntawm lub teeb nyem mus rau Tsab ntawv tsa suab Sensor nrog ESP8266 thiab MQTT: 5 Cov Kauj Ruam (nrog Duab)

Video: Los ntawm lub teeb nyem mus rau Tsab ntawv tsa suab Sensor nrog ESP8266 thiab MQTT: 5 Cov Kauj Ruam (nrog Duab)

Video: Los ntawm lub teeb nyem mus rau Tsab ntawv tsa suab Sensor nrog ESP8266 thiab MQTT: 5 Cov Kauj Ruam (nrog Duab)
Video: Tshuaj theem vim li cas thiaj tau nqi ?/ Siv kho mob dab tsi?/paris polyphylla использовать для? 2024, Hlis ntuj nqeg
Anonim
Image
Image
LEDs Xav Tau Tam Sim No Kom Txwv
LEDs Xav Tau Tam Sim No Kom Txwv

Hauv kab ntawv no, kuv yuav nthuav qhia cov khoom hauv qab no:

  • LEDs xav tau kev txwv tam sim no
  • yuav ua li cas thiaj ua lub teeb nyem
  • ua lub teeb pom kev los ntawm lub roj teeb nqa tau, thiab ua kom lub teeb ci los ntawm ESP8266 ntawm MQTT

Daim vis dis aus yog rov ua dua thiab piav qhia luv luv ntawm qhov no ua haujlwm li cas,

Kuv tau npaj kom muaj PIR sensor suav nrog, tab sis cov ntawv qhia tau ntev dua yog li PIR sensor yuav nthuav tawm hauv ntu thib ob ntawm cov ncauj lus no

Yog li cia pib.

Kauj Ruam 1: LEDs Xav Tau Tam Sim No Kom Txwv

Rau cov pib tshiab, qhov no yog qhov xav tsis thoob li cas feem ntau tig rau lub teeb hluav taws xob lossis lub teeb ci. Tsis txhob txhawj, cov qij LED ntawm lub txee twb tau los nrog AC-rau-DC lub zog hloov pauv thiab txwv tam sim no. Tab sis yuav zoo los ua ib yam dab tsi los ntawm qhov kos.

Ib qho tseem ceeb kom tig lub LED yog qhov txwv tam sim no. Qhov no ua haujlwm li lub valve rau tam sim no kom thaum qhov hluav taws xob tau thov rau LED ua rau nws ua tus coj, tam sim no ntws los ntawm LEDs tsis tuaj yeem loj dua qhov ib txwm tswj los ntawm Circuit Court. LEDs tsis ua feem ntau tshwm sim los ntawm kev ua kom sov. Tsis muaj qhov txwv tam sim no hauv qhov chaw yog txoj hauv kev kom hlawv cov LEDs hauv ob peb feeb. Los ntawm txoj kev, kho cov LED chips, cov uas tuaj ntawm cov txheej txheem txhuas, kom lub rhaub dej kub txo cov LED nti thiab feem ntau pom zoo.

Kuv tau khawb kuv lub taub hau ntau thaum kawm qhov no ib puag ncig 2015, thiab tseem khawb kuv lub taub hau (rau qhov laj thawj sib txawv). Kuv kawm los ntawm cov ntawv qhia no thiab nws cov lus piav qhia meej txuag kuv qee qhov khaus.

Lub voj voog txuas nrog. Cov kab ntawv siab qhia qhov tseem ceeb ntawm txoj kev thauj khoom, thiab cov uas nyias nyias qhia txog kev tswj hwm lub luag haujlwm los tswj qhov tam sim no ntawm txoj kev tseem ceeb uas yog kwv yees li 150 mA. Wikipedia muaj kab lus luv luv thiab qee qhov kev hais qhia txuas nrog. Qhov kev txwv tam sim no tuaj yeem tsim nrog transistor los hloov MOSFET nrog nruab nrab tam sim no thauj khoom transistors xws li BD135, BD139.

Kauj ruam 2: Ua lub teeb nyem

Ua lub teeb nyem
Ua lub teeb nyem
Ua lub teeb nyem
Ua lub teeb nyem
Ua lub teeb nyem
Ua lub teeb nyem
Ua lub teeb nyem
Ua lub teeb nyem

Qhov xav tau:

  1. N-channel MOSFET (IRF540N $ 1.62/10pcs, 30N06, $.1.75/10pcs)
  2. NPN transistor (xws li S8085)
  3. 3.9 ohm - 2W resistor, tam sim no txwv tsis pub dhau 0.6/3.9 = 153mA
  4. 100kR (1/4W) resistor
  5. Lub laub-xauv hloov
  6. Muaj 0.5W 8mm LED, $ 3.18/100pcs ntawm no
  7. 18660 Lithium roj teeb. Kuv khaws ob peb ntawm lawv los ntawm lub txhab nyiaj fais fab. Lub roj teeb laptop (4, 6, 8 hlwb) ua los ntawm 18650 cell tab sis ceev faj nrog cov khoom ntawd.
  8. 1 nce mus txog 12V pawg thawj coj, zoo li qhov no, $ 0.56
  9. 1 lub roj teeb lithium zoo li qhov no, $ 0.30

Qhov sib txawv tseem ceeb rau lub Circuit Court saum toj no yog siv lub roj teeb Lithium (18660) nrog txhawb nqa lub rooj tsavxwm tsis txhob thuam-5V lub zog hloov pauv.

Daim duab kawg qhia pom lub teeb nyem kawg thiab nws tau them los ntawm ib qho micro USB qhov chaw (> 1A).

Kauj Ruam 3: Internet Ntawm Yam Nrog Lub Teeb Pom Kev Zoo no?

Internet ntawm Yam Nrog Lub Teeb nyem no?
Internet ntawm Yam Nrog Lub Teeb nyem no?
Internet ntawm Yam Nrog Lub Teeb nyem no?
Internet ntawm Yam Nrog Lub Teeb nyem no?
Internet ntawm Yam Nrog Lub Teeb nyem no?
Internet ntawm Yam Nrog Lub Teeb nyem no?

Kuv tsoo qhov no ua peb kauj ruam:

  • Npaj tus neeg yuav khoom (qhov no)
  • Teeb MQTT server (kauj ruam tom ntej)
  • thiab npaj Tus Tshaj Tawm (tus tom ntej)

Qhov:

Ua ntej, yog, Kuv tau siv lo lus ntuas, aka IOTs, tab sis qhov no tuaj yeem ua ke ua ke ntawm kev siv Circuit hauv Kauj Ruam 2 nrog ESP8266 thiab tom qab ntawd tswj lub teeb ci los ntawm MQTT txoj kev.

Cov khoom rau hauv Circuit Court zoo ib yam, tshwj tsis yog:

  1. Hloov 12V txhawb nqa los ntawm MT3608 txhawb nqa pawg thawj coj, $ 1.92/5pcs, qhov no tuaj yeem txhawb qhov hluav taws xob ntawm 18650 roj teeb (li 3.7V) txog 28 V, txaus rau lub zog 8LEDs (hloov 3).
  2. Txoj haujlwm tsis thawb hauv qhov hloov pauv tau txuas nrog GPIO 1 lossis 2 hauv ESP8266 rau PWM teeb liab.
  3. ESP8266 01, $ 1.68 txhua. Zoo li no
  4. AMS1117 3.3 V, tus tswj hluav taws xob rau ESP8266, qee lub peev xwm
  5. USB module kom nyem ESP8266, $ 0.78/pcs zoo li qhov no

Btw. cov kev sib txuas yog rau kev yooj yim.

Soldering thiab uploading:

  • Siv cov khoom sib dhos ua ke, thiab siv cov txheej txheem saum toj no. Qee qhov ua ntej 3.3 qhov hluav taws xob hluav taws xob tuaj yeem txuag koj qee lub sijhawm ($ 1.38/5pcs zoo li no). Kuv tsis meej pem kom nco tus pin thaum tig lub PCB pawg thawj coj thiab ua tiav qee qhov AMS1117 tus tswj hluav taws xob.
  • Tom ntej no Ua qhov kev hloov pauv me me zoo li hauv daim duab thib peb los tuav GPIO 0 rau GND, nrawm nrawm RST Pin nrog GND tus pin kom tso ESP8266 rau hauv Flashmode.
  • Rub tawm cov cai ntawm no los ntawm kuv GitHub, thiab xa cov cai rau ESP 8266 siv Arduino IDE.

Kuv tau hais qhia kab kom pom cov ncauj lus uas tus neeg siv khoom tau tso npe rau. Txhua cov lus tshaj tawm rau lub ncauj lus no yuav raug xa mus rau lwm tus neeg siv khoom (cov neeg siv khoom) rau cov ncauj lus no. EPS8266 hauv kab lus no yuav mloog JSON cov lus tshaj tawm rau lub ncauj lus thiab hais tawm yog tias tau hloov pauv hauv channel Peb

* ib zaug dhau ib zaug, Kuv xav tias kuv tuaj yeem tso lub zog rub tawm (100k) rau hauv av ntawm Gate ntawm MOSFET thaum ESP8266 tsis tau nthuav tawm. Qhov no ua haujlwm thaum tsis muaj ESP8266, tab sis nrog ESP8266, tus tiv thaiv kuj tseem rub GPIO0 lossis 2 rau GND, ua rau lawv mus rau hauv hom Flash lossis tsis khau raj (thaum GPIO2 yog LOW)). Koj yuav pom ntsuab ntsuab yog tias qhov no tshwm sim.

Kauj Ruam 4: Teeb MQTT Server

Teeb MQTT Server
Teeb MQTT Server
Teeb MQTT Server
Teeb MQTT Server
Teeb MQTT Server
Teeb MQTT Server
Teeb MQTT Server
Teeb MQTT Server

MQTT (Message Queuing Telemetry Transport) yog cov txheej txheem tsis sib xws raws li kev tshaj tawm-sau npe yuav ua. Ntaus hosting MQTT lus hauv thiab tawm hu ua tus broker. Zoo li tus tswv lag luam tiag, nws muaj kev sib pauv ntawm cov tshaj tawm (muag khoom) thiab cov neeg siv khoom (cov neeg yuav khoom). Tsis muaj nyiaj pauv cov tes. Muaj ntau ntau cov lus qhia rau qhov no.

Ntawm no yog cov recap. Raspberry Pi yog lub cuab yeej nrov tshaj plaws rau qhov no. Frist, nruab MQTT los ntawm:

sudo apt-tau nruab mosquitto mosquitto-cov neeg siv khoom

sim yog tias MQTT server ua haujlwm los ntawm qhib ob lub dav hlau ntawm Raspberry, ib hom thawj kab thiab lwm qhov rau tom ntej:

mosquitto_sub -h localhost -t "yourtopic"

mosquitto_pub -t "yourtopic" -h localost -m "hais ib yam dab tsi"

Koj yuav tsum pom qhov "hais ib yam dab tsi" qhia tawm ntawm thawj lub davhlau ya nyob twg. Vahuam! Nws ua haujlwm.

Qhov "#" tuaj yeem siv los mloog txhua lub ncauj lus, hloov "koj cov lus" los ntawm "#"

Tam sim no koj tsis xav kom ib tus tuaj yeem tshaj tawm lossis sau npe rau koj li MQTT server, koj yuav tsum teeb tus password, ua li ntawd los ntawm:

cd ~ ib

mosquitto_passwrd -c pwfile mqtt_user

mqtt_user tuaj yeem yog lwm lub npe siv uas koj nyiam, sau tus password ob zaug, thiab hloov kho cov ntaub ntawv.conf los ntawm:

sudo nano /etc/mosquitto/mosquitto.conf

ntxiv ob kab no:

allow_anonymous cuav

password_file/tsev/pi/pwfile

ces rov pib dua lub mositto los ntawm:

sudo systemctl rov pib dua Mositto

ua qhov kev xeem los ntawm suav nrog lub npe nrog tus lej zais xws li:

mosquitto_sub -h localhost -t "yourtopic" -u "mqtt_user" -P "123456"

mosquitto_pub -h localhost -t "yourtopic" -u "mqtt_user" -P "123456" -m "qhov no puas ruaj ntseg?"

Tsis tas li yog tias MQTT tsis kam txuas, sim qhov no los muab MQTT cov kev pabcuam rau tom qab ntawm Linux system los ntawm:

mosito -d

Kuv pom cov ntawv ua pov thawj no zoo rau saib. Kuv tau kawm qee yam los ntawm ob qho no hnub no.

  1. Adafruit:
  2. Stees-internet-guide.com

Kauj Ruam 5: Npaj Tus Tshaj Tawm

Npaj Tus Publisher
Npaj Tus Publisher
Npaj Tus Publisher
Npaj Tus Publisher
Npaj Tus Publisher
Npaj Tus Publisher
Npaj Tus Publisher
Npaj Tus Publisher

Txog qhov no, Kuv ua lub dashboard yooj yim los thawb cov lus rau MQTT server. Hauv kev sawv ntsug, LCD qhia Lub Sijhawm.

Qhov:

  1. SSD1306 Screen zaub, $ 2.41 txhua
  2. EPS8266 WEMOS D1 Mini, $ 2.53 txhua
  3. Ib tug potentiometer
  4. Ib tus lej 4 tus lej swb.
  5. ob 3mm LEDs,
  6. ib co resistors

Soldering:

Nov yog daim duab qhia chaw ntawm lub davhlau ya nyob twg:

Upload cov cai:

Lub npe WEMOS ESP8266 zoo siab ua haujlwm nrog. Koj tsuas xav tau micro USB, nias lub pob upload ntawm Arduino IDE nyem lub nti. Cov cai nyob ntawm no (GitHub):

Txhawm rau tshaj tawm cov lus, thawb qhov hloov kom tig ntsuab coj (thiab liab tawm), tom qab ntawv xaub tus pin thiab kho, thiab thaum kawg nias lub pob kom rov thawb cov lus mus rau MQTT server. Lub dashboard tuaj yeem tshaj tawm JSON cov lus rau 4 raws.

Ua tibzoo saib qhov tseem ceeb ntawm tus lej (screenshot). Qhov ntawd yog lub ncauj lus lub dashboard thawb cov lus rau, thiab peb cov LEDs xav ua kom pom ib yam tshiab los ntawm JSON cov lus

Qhov ntawd yog hais txog nws. Kuv vam tias cov ntawv qhia yuav pab tau.

Pom zoo: