Cov txheej txheem:

Tsis siv neeg IoT Hallway Hmo Teeb Nrog ESP8266: 4 Cov Kauj Ruam (nrog Duab)
Tsis siv neeg IoT Hallway Hmo Teeb Nrog ESP8266: 4 Cov Kauj Ruam (nrog Duab)

Video: Tsis siv neeg IoT Hallway Hmo Teeb Nrog ESP8266: 4 Cov Kauj Ruam (nrog Duab)

Video: Tsis siv neeg IoT Hallway Hmo Teeb Nrog ESP8266: 4 Cov Kauj Ruam (nrog Duab)
Video: ua neej tiam no tsis cia siab lawm ( zoo xyooj ) C.V 2024, Hlis ntuj nqeg
Anonim
Image
Image
Sau tag nrho Cov Khoom Siv Xav Tau
Sau tag nrho Cov Khoom Siv Xav Tau

Kuv pib qhov haujlwm no tau tshoov siab los ntawm lub teeb ntaiv los ntawm lwm txoj haujlwm qhia. Qhov sib txawv yog lub hlwb ntawm kev siv hluav taws xob siv ESP8266, uas txhais tau tias nws yuav los ua IoT ntaus ntawv.

Qhov kuv xav hauv siab yog kom muaj teeb pom kev tsaus ntuj rau cov menyuam yaus, thaum lawv tawm mus ntawm lawv chav, nws pom txoj hauv kev mus rau chav dej. Txog qhov no kuv siv ESP8266 txhawm rau txheeb xyuas qhov txav los ntawm PIR sensor. Kuv siv 2 PIR sensors, ib qho ntawm txhua qhov kawg rau kev rov qab los. Muab hais tias ESP8266 yog IoT muaj peev xwm, tom qab ntawd kuv tseem tuaj yeem siv qhov no txhawm rau txheeb xyuas seb puas muaj kev txav mus los ntawm txoj kev hauv tsev los ntawm kev tshaj tawm MQTT cov lus rau Tus Pab Tsev.

Kauj Ruam 1: Sau tag nrho cov ntaub ntawv xav tau

Sau tag nrho Cov Khoom Siv Xav Tau
Sau tag nrho Cov Khoom Siv Xav Tau
Sau tag nrho Cov Khoom Siv Xav Tau
Sau tag nrho Cov Khoom Siv Xav Tau

Rau qhov haujlwm no kuv tab tom siv cov ntaub ntawv hauv qab no:

SIB 8266

- PIR sensor

- 330 Ohm resistor uas ua raws li qhov txwv tam sim no

- 5 V addressable LED Sawb (WS2812B)

- Cov kab hluav taws xob los teeb lub tsev

Kauj ruam 2: Txuas lub Circuit Court

Txuas lub Circuit Court
Txuas lub Circuit Court
Txuas lub Circuit Court
Txuas lub Circuit Court
Txuas lub Circuit Court
Txuas lub Circuit Court

Peb yog qhov tseem ceeb txuas rau LED kab ntawv Cov ntaub ntawv kab rau tus pin D2 lossis ESP8266 ntawm 330 Ohm resistor kom txwv qhov tam sim no. Nco ntsoov ESP8266 lub zog ua haujlwm yog 3.3V.

PIR sensors tau txuas nrog Pin D5 thiab D6, ib qho rau sab laug sensor thiab ib qho rau sab xis. Tsis txhob hnov qab txuas lub zog rau PIR thiab LED sawb rau 3.3V hauv qhov no.

Kauj ruam 3: Upload Code

Rub tawm Txoj Cai
Rub tawm Txoj Cai
Rub tawm Txoj Cai
Rub tawm Txoj Cai

Txhawm rau ua haujlwm koj yuav xav tau lub tsev qiv ntawv hauv qab no:

- "FastLed" lub tsev qiv ntawv los ntawm Daniel Garcia, hauv qhov piv txwv no kuv muaj version 3.3.3 teeb tsa

-Lib Time

- ESP8266Wifi

- ESP8266WebServer

- ArduinoOTA Cov

Yog tias koj tseem tsis tau teeb tsa lawv koj tuaj yeem teeb tsa lawv los ntawm "Cuab Yeej-> Tswj Tsev Qiv Ntawv" hauv Arduino interface.

Hauv kab lus hauv qab no ntawm cov cai

#define FASTLED_ESP8266_D1_PIN_ORDER#suav nrog "FastLED.h" FASTLED_USING_NAMESPACE

#define NUM_LEDS 30

#define LEDS_PER_STAIR 2 // Cov Leds ntawm ib tus ntaiv. Tseem tsis tau hloov pauv - tsuas yog pom #define BRIGHTNESS 120 // 0 … 255 (siv hauv fade7) #define PIN_LED 04 // LED Cov lej tus lej (GPIO4) D2 #define PIN_PIR_DOWN 14 // PIR Downstairs Pin (GPI14) D5 #define PIN_PIR_UP 12 // PIR Upstairs Pin (GPI12) D6

Koj tuaj yeem teeb tsa Tus lej ntawm LED hauv koj daim kab xev LED, tseem txuas ntawm LEDStrip yog tias koj txiav txim siab txuas nws mus rau tus lej sib txawv thiab tseem yog PIR sensor tus pin yog tias koj txiav txim siab txuas nws mus rau tus lej sib txawv ntawm MCU.

Cov teeb tsa saum toj no nyob hauv "ledsettings.h" cov ntaub ntawv.

Koj tuaj yeem rub tawm tag nrho cov cai los ntawm qhov txuas hauv qab no.

Thaum koj muaj peev xwm sau cov cai ua tiav koj tuaj yeem xa nws mus rau ESP8266.

Kauj Ruam 4: Xeem thiab Xeem thiab Teeb Meem

Xeem thiab Xeem thiab Teeb Meem
Xeem thiab Xeem thiab Teeb Meem
Xeem thiab Xeem thiab Teeb Meem
Xeem thiab Xeem thiab Teeb Meem

Yog tias txhua yam mus tau zoo, koj yuav tsum muaj Lub Teeb Pom Kev Ua Haujlwm uas koj tuaj yeem txaus siab rau. Thaum koj txhawb lub zog hluav taws xob thawj zaug, LED Sawb yuav ci nrog qee cov zaj sawv sib tshooj. Tom qab ntawd lub peev xwm ESP8266 yuav ua lub luag haujlwm nkag (AP) tso cai rau koj teeb tsa WiFi txuas.

Yog tias koj siv tus lej uas kuv muaj koj yuav tsum tuaj yeem pom "ESP-HallLight" ua qhov nkag mus. Rau kev nyab xeeb Kuv tau tso tus lej tiv thaiv rau AP. Tus password tsis raug yog "arduino" koj tuaj yeem hloov qhov no hauv cov ntaub ntawv settings.h, hauv ntu hauv qab no.

#define CLOCK_NAME "ESP-HallLight"

#define WIFI_AP_NAME CLOCK_NAME #define WIFI_APPSK "arduino" // default AP password

Thaum txuas tau zoo siv lub xov tooj ntawm tes lossis lub laptop ntawm WiFi, koj yuav tsum muaj peev xwm taw koj tus browser mus rau 192.168.4.1, koj yuav tsum pom lub vijtsam teeb tsa raws li pom hauv daim duab saum toj no. Tam sim no koj tuaj yeem nkag mus rau koj li WiFi chaw thiab ib zaug nkag ESP8266 yuav rov pib dua thiab sim txuas rau koj li WiFi. Yog tias nws muaj peev xwm txuas tau zoo koj yuav tsis pom qhov "ESP-HallLight" nkag mus ntxiv.

Yog tias koj tseem txuas nrog Arduino interface koj tuaj yeem saib xyuas qhov no los ntawm kev saib ua ntu zus.

Nco tseg: Koj tsis tas yuav teeb tsa WiFi rau lub ntsuas hluav taws xob kom ua haujlwm, nws yuav tsum ua haujlwm tom qab ob peb feeb thaum lub teeb pib pib.

Txhawm rau sim koj tuaj yeem sim taug kev los ntawm ib sab lossis tuav koj txhais tes, lub teeb yuav tsum ci tom qab kev taw qhia ntawm kev mus ncig, yog tias nws ua qhov tsis sib xws, tom qab ntawd koj yuav tsum tau hloov pauv sab laug thiab sab xis hauv qhov chaws.

Thaum lub sijhawm kuv tsim thawj zaug kuv yuam kev txuas qhov tsis raug ntawm LED sawb, uas ua rau tsis muaj ib qho ntawm LEDs teeb pom kev.

Kuv vam tias koj txaus siab rau qhov kev tsim no, yog tias qhov no muaj txiaj ntsig, thov pov npav rau qhov kev sib tw. Yog tias koj muaj lus nug tsis txhob ua siab deb sau ntawv rau kuv, thiab kuv yuav teb nws sai li sai tau.

Qee qhov tom qab xav yuav ntxiv cov yam ntxwv ntxiv xws li:

  • Muaj qhov cuam tshuam los tig LEDs ntawm nws tus kheej ntawm lub ntsuas, zoo ib yam li kuv tshaj tawm yav dhau los hais txog WiFi tswj LED Sawb lossis LED Sawb Cov xwm txheej qhia.
  • Ntxiv qhov tshwj xeeb ntxiv rau tshaj tawm MQTT cov lus rau Tsev Pabcuam zoo ib yam li cov ntawv hauv qab no.

Pom zoo: