Cov txheej txheem:

IoT Enabled Sensor Cov Chaw Sau Cov Ntaub Ntawv Nrog ESP8266 & PubNub: 9 Kauj Ruam (nrog Duab)
IoT Enabled Sensor Cov Chaw Sau Cov Ntaub Ntawv Nrog ESP8266 & PubNub: 9 Kauj Ruam (nrog Duab)

Video: IoT Enabled Sensor Cov Chaw Sau Cov Ntaub Ntawv Nrog ESP8266 & PubNub: 9 Kauj Ruam (nrog Duab)

Video: IoT Enabled Sensor Cov Chaw Sau Cov Ntaub Ntawv Nrog ESP8266 & PubNub: 9 Kauj Ruam (nrog Duab)
Video: ? Что такое многополосный 6 атомный хронометраж ? То 2024, Hlis ntuj nqeg
Anonim
IoT Enabled Sensor Data Collection Center Nrog ESP8266 & PubNub
IoT Enabled Sensor Data Collection Center Nrog ESP8266 & PubNub
IoT Enabled Sensor Data Collection Center Nrog ESP8266 & PubNub
IoT Enabled Sensor Data Collection Center Nrog ESP8266 & PubNub

Feem ntau ntawm cov kev qhia ntawm ESP8266 yog ib qho ntawm cov neeg tshiab (nyob ntsiag to ntsais ib tus coj) lossis nyuaj rau qee tus neeg uas tab tom nrhiav rau qee yam los txhim kho thiab txhim kho thaum nws coj kev ntsais ntsais. siv ESP8266 thiab tshaj tawm cov ntaub ntawv sau rau PubNub. Lub hom phiaj tseem ceeb/lub hom phiaj yog txhawm rau txo lub sijhawm tib neeg siv kev tsim kho vajtse thiab hloov pauv lawv lub sijhawm ntawm kev tshuaj xyuas cov ntaub ntawv thiab pom kev nrog cov ntaub ntawv khaws tseg.

Rau cov tib neeg uas tsis paub nrog ESP8266/NodeMCU peb qhia koj kom nkag siab yooj yim ntawm yuav ua li cas nyem thiab program los ntawm ESPLORER. Muaj ntau qhov kev qhia/qhia qhia uas muaj qhov no zoo li Tau Pib-nrog-ESP8266-Siv-AT -Commands-NodeMCU.

Qhov kawg ntawm cov lus qhia no koj yuav tuaj yeem tsim koj tus kheej cov ntaub ntawv khaws cov ntaub ntawv thiab lub hauv paus teeb duab lub sijhawm tiag tiag nrog kev pab ntawm PubNub

Txais tos rau ESP8266 -NodeMCU Zaj Lus Qhia - 102 !!

Kauj Ruam 1: Cov Khoom Siv Hauv Txoj Haujlwm

Cheebtsam Siv Hauv Txoj Haujlwm
Cheebtsam Siv Hauv Txoj Haujlwm

Cov hauv qab no yuav tsum ua kom tiav txoj haujlwm

  • Ib pawg ESP8266. Lub rooj tsav xwm uas siv rau cov lus qhia no yog NodeMCU devKit v1.0 (ntxig rau module 143 txuas ntawm no)
  • Txhua lub sensor uas nws cov ntaub ntawv xav tau sau thiab nkag mus. Qhov yooj yim potentiometer tau siv los ua qhov ntsuas sib piv
  • Ib qho swb hloov
  • Ib lub micro rau USB (hom txiv neej) cable tso cov cai rau NodeMCU devKit v1.0 thiab tso lub zog ntaus ntawv
  • 2 coj rau qhov taw qhia hom
  • Qee tus txiv neej rau txiv neej cables thiab daim txiag ntoo
  • PubNub tus account nrog tshaj tawm qhov tseem ceeb, sau npe ua tus tseem ceeb thiab channel

Rub cov ntawv hauv qab no. Yog tias koj tsis xav hloov dab tsi thiab tsuas yog xav kom nws ua haujlwm rub tawm cov ntawv ua ntej tso ua ke (ntxig sau ua ke version zip nplaub tshev ntawm no). Yog koj xav nkag siab tias nws ua haujlwm li cas thiab xav kom koj txhais tes qias neeg tom qab ntawd koj tseem tuaj yeem rub tawm lub hauv paus ntsiab lus (ntxig rau qhov chaws version ntawm no)

Kauj Ruam 2: Tsim Circuit Court

Yog tias koj tau yuav (ntxig qhov txuas ntawm cov khoom kawg ntawm no) ces koj tuaj yeem hla cov kauj ruam no

Kauj Ruam 3: Tshaj Tawm Txoj Cai rau NodeMCU Cov Khoom Siv ESPlorer

Kev Tshaj Tawm Txoj Cai rau NodeMCU Cov Khoom Siv ESPlorer
Kev Tshaj Tawm Txoj Cai rau NodeMCU Cov Khoom Siv ESPlorer
Kev Tshaj Tawm Txoj Cai rau NodeMCU Cov Khoom Siv ESPlorer
Kev Tshaj Tawm Txoj Cai rau NodeMCU Cov Khoom Siv ESPlorer

Thaum koj qhib ESPlorer daim ntawv thov pib lub vijtsam yuav zoo li thawj daim duab.

Tam sim no muaj ob txoj hauv kev koj tuaj yeem mus tom ntej thiab ua tiav cov lus qhia no

Ua kom tiav cov cuab yeej ntsuas qhov cuab yeej cuab tam kom sai li sai tau thiab txav mus ua si nrog cov ntaub ntawv

Nkag siab txoj hauv kev NodeMCU thiab lua tsab ntawv ua haujlwm thiab kho raws li koj xav tau

yog (xaiv == 1)

Rub tawm txhua cov ntaub ntawv ua ntej ua ke (cov ntaub ntawv.lc) thiab txav mus rau theem tom ntej

lwm yog (xaiv == 2)

Tsuas yog qhib qhov chaws cov ntaub ntawv (.lua) cov ntaub ntawv hauv ESPlorer thiab pib ua si nrog tus lej. Qhia mus rau kauj ruam 5 rau kev piav qhia

Kauj ruam 4: Kho lub Sensor Hub

Configuring Sensor Hub
Configuring Sensor Hub
Configuring Sensor Hub
Configuring Sensor Hub

Tam sim no xaub qhov hloov mus rau hom teeb tsa thiab rov pib dua qhov module. Config hom taw qhia coj yuav tsum ci.

Raws li tau qhia hauv thawj daim duab thiab wireless network nrog lub npe "configMode" yuav raug tsim thiab pom tau. Txuas mus rau lub network ntawd nrog tus lej cim "password1234" los ntawm ib lub computer, lapotop lossis mobile.

Qhib ib qho xaum thiab sau cov url hauv qab no

192.168.4.1/?username='wifi_network_name'&pwd='password'&apipubkey='publish_key'&apisubkey='subscribe_key'&channel='Channel_name'&sensorOneName='Sensor_1_name'&check=1

Hloov qhov tsis nyob hauv nqe lus nrog koj tus kheej wifi (nrog siv internet) tus lej siv tus lej cim tus lej thiab PubNub cov lej. Qhov kawg url yuav tsum yog qee yam zoo li hauv qab no

192.168.4.1/?username=MyWiFi&pwd=123456&apipubkey=pub_kjabdc_56513akhbcqio3_ad&apisubkey=sub_ajkd23d_sf23_24'&channel=channel1&sensorOneName=sensor1&check=

Yog tias lub ntsuas phoo lub teeb tau teeb tsa kom raug koj teeb tsa hom coj yuav hloov tawm thiab cov ntaub ntawv hom coj mus yuav qhib thiab "configMode" wireless network yuav ploj mus. Yog tias koj xav nkag siab tias qhov no ua haujlwm zoo li cas lossis xav hloov qee qhov tsis txheeb xyuas qhov txuas ntxiv mus ntxiv mus rau qib 8

Kauj ruam 5: Customizing Configuration

Customizing Configuration
Customizing Configuration

Yog li dab tsi tshwm sim yog ESP8266 ua raws li tus router thiab tsim lub wireless network nrog muab ssid, lub npe siv thiab tus IP chaw nyob uas koj tuaj yeem txuas tau. ib qho cuab yeej txuas nrog rau kev teeb tsa wireless network.

192.168.4.1/?username='wifi_network_name'&pwd='password'&apipubkey='publish_key'&apisubkey='subscribe_key'&channel='Channel_name'&sensorOneName='Sensor_1_name'&check=1

Qhib ap.lua cov ntaub ntawv hauv ESPlorer. Qhov tsab ntawv no yog lub luag haujlwm rau kev teeb tsa thawj zaug ntawm lub ntsuas sensor. Nws tsim ob daim ntawv raws li cov ntaub ntawv uas tau muab los ntawm tus neeg siv

  • station.lua (muaj lub network ssid thiab tus password uas muaj internet siv tau los tshaj tawm cov ntaub ntawv)
  • api_file.lua (muaj PubNub tuav, lub npe channel nrog lub npe sensor)

Txhawm rau Kho tus IP chaw nyob:

Tus IP tuaj yeem teeb tsa rau ib qho chaw nyob vaild uas yuav tsum tau hloov pauv hauv qhov url. Default chaw nyob yuav yog "192.168.4.1". Raws li pom hauv daim duab thawj thawj 3 kab yog lub luag haujlwm teeb tsa tus IP chaw nyob thiab lub qhov rooj. Koj tuaj yeem tshawb xyuas yog tias qhov chaw nyob raug tsim nyog los ntawm kev xa "= wifi.sta.getip ()" hais kom ua

Txhawm rau Kho lub npe ssid

Cov txheej txheem tom ntej hauv tib daim duab yog lub luag haujlwm rau teeb tsa ssid thiab tus password rau lub wireless network.

Nco ntsoov yog tias koj tau ua ib qho kev hloov pauv hauv.lua cov ntaub ntawv koj yuav tsum sau lawv rau qhov kev hloov pauv kom tau txais kev xav tom qab rov pib dua

  1. Upload qhov hloov kho.lua cov ntaub ntawv.. piv txwv li ap.lua ntawv
  2. Xa cov lus txib "node.compile (ap.lua)" los ntawm txhaj rau lub pob xa hauv qab ntawm ESPlorer
  3. Tam sim no koj cov ntaub ntawv lua tau muab tso ua ke thiab cov ntaub ntawv.lc tshiab yuav raug tsim

Kauj Ruam 6: Ntxiv ntawm Sensors rau Hub thiab PubNub

Ntxiv ntawm Sensors rau Hub thiab PubNub
Ntxiv ntawm Sensors rau Hub thiab PubNub
Ntxiv ntawm Sensors rau Hub thiab PubNub
Ntxiv ntawm Sensors rau Hub thiab PubNub

Txhawm rau ntxiv sensor

Los ntawm lub neej ntawd tus lej xa tsuas yog ib qho ntaub ntawv sensor uas txuas nrog tus pin analog 0. Koj tuaj yeem ntxiv cov ntsuas ntau ntxiv kom xa cov ntaub ntawv ib txhij. Ua raws cov hauv qab no

  1. Ntxiv lub npe sensor hauv qhov url raws li qhia hauv daim ntawv loj. Yog li tam sim no url yuav zoo li hauv qab no Channel_name '& sensorOneName =' Sensor_1_name '& sensorTwoName =' Sensor_2_name '& kos = 1
  2. Lub npe sib xws yuav tsum tau ntxiv rau ap.lua cov ntaub ntawv raws li qhia hauv duab 1sensorTwo = _GET.sensorTwoName luam ntawv (sensorTwo). (Qhov no tsuas yog saib thiab tshawb xyuas cov ntaub ntawv)
  3. Kauj ruam kawg yog ntxiv nws rau api_file tiam ib feem ntawm qhov kawg raws li qhia hauv daim duab 2 {"eon": {"'..sensorOne..'": / '.. adc.read (0).. \', "'..sensorTwo..'": / '.. gpio.read (2).. \'}} Rov ua tib cov kauj ruam rau txhua qhov ntxiv ntawm lub sensor. Nco ntsoov siv gpio.read (tus pin#) rau digital thiab adc.read (tus pin#) rau analog rau cov cim digital

Nco ntsoov yog tias koj tau ua ib qho kev hloov pauv hauv.lua cov ntaub ntawv koj yuav tsum suav lawv rau qhov kev hloov pauv kom tau txais kev xav tom qab rov pib dua

  1. Upload qhov hloov kho.lua cov ntaub ntawv.. piv txwv li ap.lua ntawv
  2. Xa cov lus txib "node.compile (ap.lua)" los ntawm txhaj rau lub pob xa hauv qab ntawm ESPlorer
  3. Tam sim no koj cov ntaub ntawv lua tau muab tso ua ke thiab cov ntaub ntawv.lc tshiab yuav raug tsim

Kauj Ruam 7: Pib sau cov ntaub ntawv thiab xa mus rau PubNub

Pib pib sau cov ntaub ntawv thiab xa mus rau PubNub
Pib pib sau cov ntaub ntawv thiab xa mus rau PubNub

Thaum kev teeb tsa ua tiav kom raug cov ntaub ntawv hom coj yuav tau hloov pauv.

Yeej qhov no txhais tau tias cov ntaub ntawv ntsuas tau raug xa mus rau PubNub raws li kev teeb tsa teeb tsa uas koj tau muab rau hauv cov kauj ruam dhau los.

Yog lub hauv paus lub hauv paus yuav xa cov ntaub ntawv mus rau PubNub txhua 5 vib nas this. Yog koj xav teeb tsa uas ua raws cov theem hauv qab no

Txhawm rau Customize zaus ntawm kev khaws cov ntaub ntawv:

  • Qhib main.lua hauv ESPlorer
  • Mus rau kab hais kom ua hauv daim duab
  • Tus nqi tau hais yuav tsum yog hauv milliseconds.
  • Rub cov ntaub ntawv main.lua rau esp thiab sau cov ntaub ntawv los tsim.lc cov ntaub ntawv
  • Rov pib dua tus qauv thiab txheeb xyuas

Kauj Ruam 8: Yooj Yim Html Nplooj Ntawv rau Lub Sij Hawm Tiag Tiag Cov Ntaub Ntawv Los Ntawm PubNub

Yooj Yim Html Nplooj Ntawv rau Lub Sij Hawm Tiag Tiag Cov Ntaub Ntawv Los Ntawm PubNub
Yooj Yim Html Nplooj Ntawv rau Lub Sij Hawm Tiag Tiag Cov Ntaub Ntawv Los Ntawm PubNub
Yooj Yim Html Nplooj Ntawv rau Lub Sij Hawm Tiag Tiag Cov Ntaub Ntawv Los Ntawm PubNub
Yooj Yim Html Nplooj Ntawv rau Lub Sij Hawm Tiag Tiag Cov Ntaub Ntawv Los Ntawm PubNub

Qhib Sample.html cov ntaub ntawv los ntawm cov ntaub ntawv rub tawm. Qhov no tsuas yog nplooj ntawv html dawb los saib cov duab ntawm lub sijhawm tiag tiag ntawm cov ntaub ntawv khaws tseg.

Raws li pom hauv daim duab 1, koj tsuas yog yuav tsum teeb tsa nws nrog koj tus kheej PubNub tuav thiab lub npe channel.

Koj kuj tseem tuaj yeem ntxiv qhov no rau txhua lub vev xaib koj txhim kho thiab tsim kom pom kev zoo dua. Refer rau PunNub EON kom paub ntau ntxiv.

Kauj Ruam 9: Troubleshooting & FAQ

Yuav hloov tshiab sai sai no

Pom zoo: