Cov txheej txheem:

Cov hauv paus IoT: Txuas Koj Li IoT mus rau Huab Siv Mongoose OS: 5 Kauj Ruam
Cov hauv paus IoT: Txuas Koj Li IoT mus rau Huab Siv Mongoose OS: 5 Kauj Ruam

Video: Cov hauv paus IoT: Txuas Koj Li IoT mus rau Huab Siv Mongoose OS: 5 Kauj Ruam

Video: Cov hauv paus IoT: Txuas Koj Li IoT mus rau Huab Siv Mongoose OS: 5 Kauj Ruam
Video: poj laib hauv koj siab. ntxawm tsab 2024, Hlis ntuj nqeg
Anonim
Cov hauv paus IoT: Txuas Koj Li IoT mus rau Huab Siv Mongoose OS
Cov hauv paus IoT: Txuas Koj Li IoT mus rau Huab Siv Mongoose OS
Cov hauv paus IoT: Txuas Koj Li IoT mus rau Huab Siv Mongoose OS
Cov hauv paus IoT: Txuas Koj Li IoT mus rau Huab Siv Mongoose OS

Yog tias koj yog tus neeg uas tab tom tinkering thiab hluav taws xob, ntau zaus ntau dua li, koj yuav hla lub sijhawm Internet ntawm Yam, feem ntau yog luv ua IoT, thiab hais tias nws hais txog cov khoom siv uas tuaj yeem txuas rau hauv internet! Ua tus neeg zoo li kuv tus kheej, Kuv tau txaus siab thaum kuv tau paub tias cov cuab yeej zoo no tau yooj yim rau kuv. Qhov kev xav ntawm kev muaj peev xwm txuas kuv cov phiaj xwm rau hauv internet siv cov khoom siv me me thiab tsuas yog xav txog lub qhov rooj suav tsis txheeb uas nws yuav qhib rau kuv cov phiaj xwm phiaj xwm tau ua rau kuv muaj zog.

Tab sis qhia rau IoT kom txuas rau hauv is taws nem tsis yooj yim li tsuas yog yuav nws tawm ntawm lub txee thiab txhawb nws. Thiab sib nrug los ntawm kev tau txais lub cuab yeej txuas rau internet, peb kuj yuav tsum tau thawb qee cov ntaub ntawv muaj txiaj ntsig rau hauv is taws nem. Cov lus qhia no cuam tshuam nrog cov txheej txheem koom nrog kom ua tiav lub hom phiaj saum toj no, thiab yog txhais tau rau cov nyeem ntawm txhua qib kev paub dhau los, txij li pib mus rau cov qub tub rog uas tshiab rau IoT.

Hauv Cov Lus Qhia no, ua piv txwv, Kuv yuav qhia tawm yuav ua li cas npaj lub phiaj xwm ntawm qhov ntsuas kub sab hauv nyeem ntawm ESP32 pawg thawj coj txhim kho uas yuav tsum muab rau cov nyeem nyeem lub tswv yim zoo ntawm cov txheej txheem.

Txawm hais tias Cov Lus Qhia no siv ESP32 thiab Mongoose OS, tab sis cov txheej txheem tuaj yeem txuas ntxiv rau txhua IoTs thiab firmware muaj!

Khoom siv

Txhawm rau tuaj yeem siv qhov Kev Qhia Ntawv no rau koj tus kheej, koj yuav xav tau tsuas yog qhov tsawg ntawm cov cuab yeej kho vajtse, thiab lawv yog:

  • Internet ntawm Yam (IoT): Kuv tau siv qhov pheej yig ESP32 pawg thawj coj txhim kho pawg. Yog tias koj tab tom npaj yuav yuav ESP32 pawg thawj coj tshiab, tom qab ntawd koj yuav tsum txheeb xyuas DFRobot's ESP32 board.
  • Cov Ntaub Ntawv Xov Xwm: Siv cov xov tooj uas koj IoT xav tau rau lub teeb ci thiab lwm yam.
  • Roj Teeb (Yeem Xaiv): Yuav qhov no tsuas yog koj xav kom txhawb koj li IoT rau lub sijhawm ntev.
  • Mini Breadboard (Tsis teb los tau)

Kuv qhia tus nyeem ntawv kom siv IoT sib txawv ntawm ESP32 kom nws/nws yuav nkag siab tiag tias ua dab tsi ntawm no, tsis yog tsuas yog ua raws kuv. Ntseeg kuv, koj yuav txaus siab ua qhov txheej txheem no siv koj tus kheej lub siab hauv qee qhov IoT, piv txwv li, ESP8266 yuav yog qhov kev xaiv zoo.

Kauj Ruam 1: Taw qhia rau MQTT

Taw qhia rau MQTT
Taw qhia rau MQTT

MQTT yog dab tsi?

"MQTT yog cov txheej txheem xa xov yooj yim, tsim los rau kev txwv cov cuab yeej nrog cov bandwidth qis. Yog li, nws yog qhov kev daws teeb meem zoo tshaj plaws rau Internet ntawm Cov Ntawv Thov. MQTT tso cai rau koj xa cov lus txib los tswj cov txiaj ntsig, nyeem thiab tshaj tawm cov ntaub ntawv los ntawm cov cim ntsuas thiab ntau ntxiv. " (Los ntawm RandomNerdTutorials)

MQTT ua haujlwm li cas?

Ua ntej mus kev, cia peb xav txog peb lub ntiaj teb tiag ua ntej. Piv txwv tias koj xav tau daim npav sau los ntawm koj tus phooj ywg tus phooj ywg, hais tias, Laurel, uas koj tus kheej tsis paub. Txij li koj tau tshwj xeeb heev txog daim npav ntawd, koj yuav nug koj tus phooj ywg, xav tias Tom, nug seb Laurel puas kam muag nws lossis tsis yog. Thaum ua li ntawd, koj yuav nug Tom kom yuav daim npav sau nws tus kheej yog tias Laurel txaus siab muag, vim tias koj tsis xav kom lwm tus neeg tau txais nws txhais tes ntawm cov khoom koj xav tau! Raws li lub sijhawm dhau mus, Tom thiab Laurel sib cuam tshuam, thiab ntawm kev pom zoo ua ke, Laurel muab nws daim npav sau rau Tom rau hauv kev pauv nyiaj. Tom qab qhov kev sib pauv no, Tom khaws daim npav nrog nws tus kheej kom txog thaum nws ntsib koj dua, uas yog thaum kawg nws muab daim npav sau rau koj. Nov yog yuav ua li cas thiaj li muaj txiaj ntsig sib pauv tau hauv peb lub neej txhua hnub.

Hauv MQTT, cov hauv paus ntsiab lus koom nrog hauv kev sib pauv yog tus tshaj tawm (Laurel), ib tus neeg yuav khoom (Koj), thiab tus tswv lag luam (Tom). Nws cov haujlwm ua haujlwm kuj tseem zoo ib yam li cov piv txwv saum toj no tau hais ua piv txwv, tshwj tsis yog rau qhov sib txawv loj heev! Hauv MQTT, kev sib pauv tau pib los ntawm tus tswv lag luam, piv txwv li Laurel yuav yog thawj tus mus cuag Tom qhia tias nws xav muag nws daim npav sau. Yog tias peb sib piv kev ua haujlwm ntawm MQTT nrog peb qhov piv txwv ntawm lub ntiaj teb tiag, tom qab ntawd nws yuav yog raws li hauv qab no:

  1. Laurel qhia Tom tias nws xav muag nws daim npav sau (cov ntaub ntawv lossis them nyiaj) thiab muab daim npav rau nws.
  2. Tom siv daim npav ntawd nyob hauv nws muaj thiab qhib rau muab rau daim npav sau. Thaum koj thiab Tom ntsib thiab nws pom tias koj txaus siab rau daim npav (ua npe rau ib lub ncauj lus). Tom ntawd muab daim npav rau koj.

Raws li tag nrho cov txheej txheem tso siab rau tus tswv lag luam thiab tsis muaj kev cuam tshuam ncaj qha ntawm tus neeg siv khoom thiab tus tshaj tawm, MQTT tshem tawm qhov teeb meem ntawm synchronizing ob tus tshaj tawm thiab cov neeg siv khoom. Lub xub ntiag ntawm tus tswv lag luam nruab nrab yog qhov muaj txiaj ntsig rau cov peev txheej-txwv cov cuab yeej zoo li IoTs thiab microprocessors raws li lawv lub zog ua haujlwm tsis txaus los nqa cov ntaub ntawv xa mus rau ib txwm muaj, uas yuav cuam tshuam nrog kev siv nyiaj ntau ntxiv xws li kev txheeb xyuas tseeb, encryption thiab lwm yam Ntxiv rau qhov no, MQTT muaj ntau ntau lwm yam xws li ua lub teeb yuag, ib-rau-ntau qhov kev faib khoom, thiab ntxiv rau, uas ua rau nws zoo tagnrho rau txwv tsis pub muaj tes hauj lwm thiab cov neeg siv khoom

Kauj ruam 2: Qhia rau IoT Platform

Dab tsi yog IoT Platform?

"Hauv qib siab, Internet ntawm Yam (IoT) lub platform yog kev txhawb nqa software uas txuas cov cuab yeej ntug, nkag mus rau cov ntsiab lus, thiab cov ntaub ntawv sib txuas mus rau lwm qhov ntawm cov saw muaj nuj nqis (uas feem ntau yog cov neeg siv kawg). IoT platforms feem ntau tuav tswj cov haujlwm txuas mus ntxiv thiab pom cov ntaub ntawv, uas tso cai rau cov neeg siv kom siv lawv qhov chaw ib puag ncig. " (Los ntawm Link-Labs)

Abstractly, IoT platform ua haujlwm nruab nrab ntawm tus neeg siv thiab cov ntaub ntawv khaws cov neeg sawv cev uas yog lub luag haujlwm sawv cev rau cov ntaub ntawv khaws tseg.

Hauv Cov Lus Qhia no, peb tab tom npaj yuav thawb peb ESP32 qhov ntsuas kub hauv online. Peb ESP32 yuav ua tus MQTT tus tshaj tawm thiab MQTT tus broker yuav yog IoT platform uas peb xaiv. Nco tseg tias hauv peb txoj haujlwm, tsis muaj lub luag haujlwm ntawm MQTT cov neeg siv khoom vim cov ntaub ntawv tau raug sawv cev los ntawm lub platform nws tus kheej. IoT platform yuav yog lub luag haujlwm khaws cia peb cov ntaub ntawv tshaj tawm thiab zoo sawv cev rau nws, ntawm no, ua kab kab. Kuv yuav siv Losant ua kuv li IoT platform ntawm no txij li nws tau siv dawb thiab muab qee txoj hauv kev zoo los sawv cev rau cov ntaub ntawv. Qee qhov piv txwv ntawm IoT platform yog Google Cloud, Amazon AWS thiab Adafruit, Microsoft Azure thiab lwm yam. Kuv xav qhia tus nyeem ntawv kom xa mus rau cov ntaub ntawv ntawm lawv xaiv IoT platform.

Teeb Losant:

  1. Nkag mus rau Losant
  2. Tsim ib lub cuab yeej (Hom ntawv tshwj xeeb)
  3. Ntxiv ob peb hom ntaub ntawv rau lub cuab yeej 1. Lub npe: ntsuas kub, Hom ntaub ntawv: Tus lej 2. Lub npe: offset, Hom ntaub ntawv: Number3. Lub npe: chav nyob, Hom ntaub ntawv: Txoj hlua
  4. Tsim kom muaj tus yuam sij nkag thiab sau cia tus lej ID thiab tus yuam sij nkag
  5. Tsim daim duab 1. Tsim lub dashboard.2. Ntxiv "Lub Sijhawm Teev Duab" thaiv rau nws siv qhov ntsuas kub sib txawv thiab koj lub cuab yeej tsim.

"Device ID" ua haujlwm lub hom phiaj ntawm kev ua tus ntiv tes tshwj xeeb rau lub cuab yeej. "Cov yuam sij nkag tau", raws li lub npe qhia, tso cai rau IoT tshaj tawm rau Losant raws li lub cuab yeej tus kheej.

Kauj Ruam 3: Npaj MQTT Publisher

Image
Image

Tam sim no uas peb tau npaj IoT platform rau tau txais thiab sawv cev rau cov ntaub ntawv, peb yuav tsum npaj MQTT tus tshaj tawm uas yuav yog lub luag haujlwm khaws thiab xa cov ntaub ntawv mus rau lub platform.

Tus txheej txheem ntawm MQTT tus tshaj tawm kev npaj yog raws li hauv qab no:

  • Sau cov cai: Txhawm rau qhia tus tshaj tawm (IoT) yuav sau cov ntaub ntawv li cas, txheej txheem thiab xa mus rau IoT platform. Cov lus qhia tau sau hauv tib neeg-nyeem tau cov lus qib siab uas feem ntau raug xa mus raws li txoj cai.
  • Nyem qhov firmware: IoT yuav tsis nkag siab cov lus qhia no vim nws tsis paub ib yam lus pib. Txhawm rau txuas cov lus tsis sib xws ntawm tib neeg thiab tshuab, cov lej tau muab tso ua ke rau hauv cov txheej txheem nyoos, cov txheej txheem ntawm hexadecimal lossis binary qhov tseem ceeb tshwj xeeb rau qhov chaw nco hauv IoT, lub npe hu ua firmware uas yog tom qab ntawd flashed rau IoT.

Hauv Cov Lus Qhia no, txij li kuv tab tom siv kuv li ESP32, kuv yuav ua rau Mongoose OS khoos phis tawj rau nws, uas lees txais cov haujlwm sau C thiab JavaScript ob qho tib si. Sib nrug los ntawm JS kev sib raug zoo, Mongoose OS tseem muaj ntau yam los muab, xws li tshaj tawm huab cua hloov tshiab, rau kev hloov kho koj li program hauv online, thiab cov ntawv tshwj xeeb rau cov khoom siv (mDash) thiab lwm yam.

Kuv tau tsim qhov qhib-app app rau Mongoose OS rau qhov Qhia Qhia no. Nws yog qhov yooj yim app hu ua losant-temp-sensor, uas ntiav MQTT xa qhov kwv yees kwv yees qhov ntsuas kub ib puag ncig, raws li kev ntsuas kub sab hauv ntawm ESP32, rau Losant (pub dawb-rau-siv IoT platform). Nws raug qhia kom hla lub app tus lej kom nkag siab zoo. Peb yuav ua kom pom qhov app no rau Cov Lus Qhia.

Yog tias koj yog tus nyiam taug txuj kev nyuaj, tom qab ntawd koj tuaj yeem sim ua tiav tib lub hom phiaj nrog Arduino-ESP32 firmware uas ua rau siv ESP32 ua Arduino (nrog WiFi muaj peev xwm).

Kev nrawm nrawm rau lub teeb nyem app nrog Mongoose OS:

  1. Nruab mos tool rau koj OS.
  2. Qhib lub cuab yeej thiab ua raws cov lus txib hauv qab no:

    1. mos clone
    2. cd losant-temp-sensor
    3. mos tsim --platform esp32
    4. mos flash
  3. Tom qab ua tiav qhov flashing, tso cai rau lub cuab yeej rov pib dua thiab tom qab ntawd ua raws cov lus txib hauv qab no:

    1. mos wifi "koj wifi ssid" "koj li wifi password" piv txwv li. mos wifi "Tsev" "tsev@123"
    2. mos config-set temperature.basis =

      qhov sov.unit ="

      "xws li. mos config-set temperature.basis = 33 / temperature.unit =" Celsius"

    3. mos config-set device.id = mqtt.client_id = mqtt.user = mqtt.pass =

Tom qab ua tiav txhua cov theem no kom raug, koj yuav xaus nrog ESP32 uas xa qhov ntsuas kub mus rau Losant ib ntus, tom qab txhua 10 feeb. Kev tshaj tawm ua tiav tau qhia los ntawm xiav LED, raws li qhia hauv cov vis dis aus saum toj no.

Kauj ruam 4: Cov lus hauv qab taw qhia

Image
Image
Cov lus hauv qab taw qhia
Cov lus hauv qab taw qhia

Yog tias koj tuaj yeem rov ua cov kauj ruam yav dhau los kom raug, tam sim no koj yuav muaj txoj haujlwm ua haujlwm nrog kev pab uas koj tuaj yeem soj ntsuam qhov ntsuas kub hauv koj chav, lossis txhua qhov chaw koj npaj yuav tso qhov project. Txij li thaum kuv tau khaws Cov Lus Qhia no raws li qhov kuv tuaj yeem ua tau, yog li koj tuaj yeem siv koj li IoT los sau cov ntaub ntawv ntawm txhua hom thiab sim txiav txim siab qee yam muaj txiaj ntsig los ntawm nws, lossis koj tuaj yeem ua nws tsuas yog rau qhov tsis zoo yog tias koj ' tau nkag siab qhov lus qhia no.

Rau kuv, qhov zoo tshaj plaws txog IoT yog qhov tseeb tias nws ua rau peb khaws cov ntawv loj ntawm cov ntaub ntawv, tsis suav nrog yog tias siv ib leeg thiab hloov nws mus rau hauv qee yam ua tiav. Qhov no yeej tsoo tsev lub siab ntawm kev tshawb fawb. Rau kuv, nws tau txaus siab heev thiab ua kom pom qhov ntsuas kub poob hauv kuv chav thaum nag teev los ntawm kuv daim duab.

Lubant-temp-sensor-app tau ua kom zoo dua rau kev siv hluav taws xob, vim nws siv kev pw tsaug zog tshwj xeeb ntawm ESP32 yog li koj tuaj yeem siv nws rau lub sijhawm ntev tsis muaj kev txhawj xeeb txog roj teeb txhua. Koj tuaj yeem txuas ntxiv txuas ntxiv lub zog ua haujlwm los ntawm kev tshem tawm LED ntawm lub rooj tsav xwm txhim kho. Kev kos tam sim no ntawm tag nrho cov teeb tsa tau pom saum toj no.

Lub hom phiaj ntawm Cov Lus Qhia no, yog los ntawm qhov pib tsuas yog muab rau koj qhia rau ntiaj teb ntawm IoT. Thaum ua tiav Cov Lus Qhia no, koj yuav muaj kev tuav zoo ntawm cov hauv paus uas koj tuaj yeem ntxiv dag zog ntau dua los ntawm lwm cov peev txheej hauv online.

Txawm hais tias koj yuav tsis tuaj yeem ua cov phiaj xwm nyuaj nyob rau theem no, nws tseem yuav tsum nco ntsoov tias yog tias koj muaj lub cib muaj zog txaus, thiab ib txoj hauv kev los ua ke ua ke, tom qab ntawd koj tuaj yeem ua txhua yam kev xav, los ntawm qhov yooj yim. rau txoj. Ib yam nkaus, muaj kev nkag siab zoo ntawm cov hauv paus thiab paub yuav siv lawv li cas kom raug yuav ua rau koj tuaj yeem tso ntau qhov kev sib deev. Yog li muab koj tus kheej rau sab nraub qaum rau ua thawj kauj ruam.

Kauj Ruam 5: Khab nias thiab Txhawb Nqa

Cov lus qhia no suav nrog cov piv txwv, piv txwv. qhov uas piav qhia MQTT pauv, uas kuv tau ua tus kheej. Cov kev piv txwv no tsuas yog ua tau ua tsaug rau cov khoom siv dawb SVG hauv qab no:

  • Infographic vector tsim los ntawm freepik - www.freepik.com
  • Infographic vector tsim los ntawm starline - www.freepik.com
  • Tib neeg vector tsim los ntawm pikisuperstar - www.freepik.com
  • Abstract vector tsim los ntawm macrovector - www.freepik.com
  • Abstract vector tsim los ntawm macrovector - www.freepik.com
  • Infographic vector tsim los ntawm pikisuperstar - www.freepik.com

Cov Lus Qhia no tau txhawb nqa los ntawm DFRobot. DFRobot muaj cov khoom siv hluav taws xob zoo heev yog li nco ntsoov xyuas nws.

Yog tias koj xav tias koj nyiam qhov Qhia Ntawv no thiab xav tau Cov Ntawv Qhia Zoo li no, tom qab ntawd koj tuaj yeem txhawb nqa kuv ntawm Patreon. Yog tias koj tsis tuaj yeem mus deb, tom qab ntawv koj tuaj yeem ua raws kuv ntawm no ntawm Cov Lus Qhia.

Pom zoo: