Cov txheej txheem:

Yuav Ua Li Cas Tsim Kev Tshawb Fawb Kab Mob Nrog Arduino: 7 Cov Kauj Ruam
Yuav Ua Li Cas Tsim Kev Tshawb Fawb Kab Mob Nrog Arduino: 7 Cov Kauj Ruam

Video: Yuav Ua Li Cas Tsim Kev Tshawb Fawb Kab Mob Nrog Arduino: 7 Cov Kauj Ruam

Video: Yuav Ua Li Cas Tsim Kev Tshawb Fawb Kab Mob Nrog Arduino: 7 Cov Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Yuav Ua Li Cas Tsim Kev Tshawb Fawb Kab Mob Nrog Arduino
Yuav Ua Li Cas Tsim Kev Tshawb Fawb Kab Mob Nrog Arduino

Tsim cov lus tsa suab thiab muaj lub txee tsim khoom siv Feather HUZZAH programmed nrog Arduino thiab siv los ntawm Ubidots.

Kev siv lub cev muaj txiaj ntsig zoo thiab kuaj pom muaj nyob hauv Smart Homes thiab Smart Manufacturing tuaj yeem muaj txiaj ntsig zoo hauv cov ntawv thov xws li los ntawm cov neeg laus Ambient Assisted Living (AAL) cov kev daws teeb meem lossis Cov Txheej Txheem Kev Tsim Khoom uas pub MES loj dua. Lwm cov ntawv thov rau Kev Tshawb Fawb thiab Kev Tshawb Fawb Pom muaj xws li tab sis tsis txwv rau:

  1. Qhov rooj thiab lub qhov rooj automation
  2. Chaw nres tsheb sensors los xaiv qhov chaw pub dawb
  3. Kev saib xyuas lub tank deb
  4. Lub tsev ntse thiab cov chaw rau teeb pom kev zoo thiab nyab xeeb
  5. Kev ntsuas pom thiab suav hauv cov kab xa khoom
  6. Txheeb xyuas qhov cim ntawm cov ntaub ntawv luam tawm
  7. Ua kom pom cov kua hauv cov duab los qhia, yas, thiab ntawv tig
  8. Nrhiav kom pom deb
  9. Cov neeg suav

Thaum muaj ntau daim ntawv thov rau lub xub ntiag thiab txav mus los, muaj qhov sib npaug zoo li ntau lub ntsuas kom khaws cov ntaub ntawv, xws li lub peev xwm, inductive, photoelectric, thiab ultrasonic sensors. Nyob ntawm tus nqi, ib puag ncig ib puag ncig, thiab qhov xav tau kom raug, ib tus yuav tsum xaiv cov cuab yeej haum zoo tshaj plaws rau ib puag ncig thiab daim ntawv thov xav tau.

Txog qhov kev qhia no, peb yuav tsom mus rau kev tsim cov khoom lag luam ntawm lub sijhawm tiag; daim ntawv thov yuav suav txhua chav nyob uas hla ntawm txoj siv thauj khoom. Peb yuav siv Arduino IDE los teeb tsa Feather HUZZAH ESP8266, lub ntsuas hluav taws xob ultrasonic, thiab Ubidots los txhim kho peb daim ntawv thov thiab tso tawm peb IoT dashboard.

Kauj ruam 1: Yuav tsum tau ua

  1. Plaub HUZZAH nrog ESP8266MB7389-100
  2. Ultrasonic Sensor
  3. Arduino IDE 1.8.2 lossis siab dua
  4. Ubidots tus account -lossis -STEM License

Kauj ruam 2: Teeb

  • Kuv Kho Kho Vajtse
  • II. Teeb Firmware
  • III. Kev Txhim Kho Daim Ntawv Thov Ubidots (cov xwm txheej, hloov pauv, thiab dashboards)

Kauj Ruam 3: Teeb Kho Vajtse

Kho vajtse teeb
Kho vajtse teeb
Kho vajtse teeb
Kho vajtse teeb

Ultrasonic Sensor MB7389-100 yog tus nqi qis rau kev siv rau kev lag luam nrog dav-ntau thiab siv lub zog qis uas xav tau hauv cov huab cua nyuaj ua tsaug rau nws qhov kev ntsuas IPv67.

Txhawm rau pib, tsom iav daim duab hauv qab no txhawm rau txuas lub ntsuas hluav taws xob ultrasonic rau Feather HUZZAH ESP8266.

NCO TSEG: Lub ntsuas nyeem ntawv tuaj yeem ua raws li kev nyeem lossis PWM; hauv qab no peb yuav piav qhia kev teeb tsa rau PWM nyeem ntawv, xav paub ntxiv thov saib cov piv txwv uas tau hais los saum no.

[Xaiv tau] tso lub micro-maub los thiab cov ntsuas sab hauv de IP67 rooj plaub los tiv thaiv lawv los ntawm hmoov av, dej, thiab lwm yam kev hem thawj ib puag ncig. Cov ntaub ntawv tus qauv zoo ib yam li qhov tau qhia hauv cov duab saum toj no.

Kauj ruam 4: Teeb Firmware

Teeb Firmware
Teeb Firmware
Teeb Firmware
Teeb Firmware

Ua ntej, koj yuav tsum teeb tsa Feather Huzzah hauv Arduino IDE thiab sau cov cai. Nco ntsoov txheeb xyuas qhov teeb tsa no los ntawm kev ua qhov kev ntsais ntsais yooj yim. Yog xav paub ntxiv txog kev txuas koj lub cuab yeej Feather txheeb xyuas qhov no pab qhia teeb tsa kho vajtse muaj txiaj ntsig.

Txhawm rau xa cov ntaub ntawv ntsuas mus rau Ubidots IoT Txoj Kev Txhim Kho, luam thiab muab cov cai hauv qab no tso rau hauv Arduino IDE. Nco ntsoov muab Wi-nkaus lub npe network, tus password, thiab koj tus lej Ubidots tus lej Token qhov uas tau qhia hauv tus lej.

/******************************** Cov tsev qiv ntawv suav nrog *************** **************** /#suav nrog /****************************** ** Ntev thiab cov khoom ******************************* //*Ubidots*/const char*SSID_NAME = "xxxxxxxx"; // Muab koj tus SSID nameconst char* SSID_PASS = "xxxxxxxx"; // Muab koj tus passwordconst char* TOKEN = "Assig_your_ubidots_token"; // Muab koj daim ntawv TOKENconst char* DEVICE_LABEL = "tswj kev txav chaw"; // Koj lub cuab yeej labelconst char* VARIABLE_LABEL = "nrug"; // Koj qhov sib txawv ntawm labelconst char* USER_AGENT = "ESP8266"; const char* VERSION = "1.0"; const char* HTTPSERVER = "industrial.api.ubidots.com"; // Ubidots Cov neeg siv lag luam // const char* HTTPSERVER = " yam.ubidots.com "; // Ubidots Educational usersint HTTPPORT = 80;/ * Ultrasonic Sensor */const int pwPin1 = 5; // Tus PWM tus pin qhov twg lub sensor txuas nrog WiFi Client tus neeg siv khoom Ubi;/**************************************** Cov Haujlwm Pabcuam *** **************************** // ** Tau txais qhov ntev ntawm lub cev @arg sib txawv ntawm lub cev ntawm hom char @return dataLen the ntev ntawm qhov sib txawv*/int dataLen (char* sib txawv) {uint8_t dataLen = 0; rau (int i = 0; kuv nrug / 25.4* / ntab nrug = pulseIn (pwPin1, HIGH); xaToUbidots (DEVICE_LABEL, VARIABLE_LABEL, nrug); ncua (1000);} tsis muaj nuj nqis sendToUbidots (const char* device_label, const char* variable_label, ntab sensor_value) {char * lub cev = (char *) malloc (sizeof (char) * 150); char * cov ntaub ntawv = (char *) malloc (sizeof (char) * 300); / * Qhov chaw khaws cov txiaj ntsig xa * / char str_val [10]; /*---- Hloov pauv qhov tseem ceeb ntawm lub ntsuas hluav taws xob rau hom char -----* / /*4 yog qhov dav dav, 2 yog qhov tseeb; ntab tus nqi raug theej rau str_val* / dtostrf (sensor_value, 4, 2, str_val); /* Ua kom lub cev xa mus rau qhov kev thov* /sprintf (lub cev, "{"%s / ":%s}", variable_label, str_val); /* Tsim HTTP thov kom POST */sprintf (cov ntaub ntawv, "POST /api/v1.6/devices/%s", device_label); sprintf (data, "%s HTTP/1.1 / r / n", data); sprintf (data, "%sHost: things.ubidots.com / r / n", data); sprintf (data, "%sUser-Agent:%s/%s / r / n", data, USER_AGENT, VERSION); sprintf (data, " %sX-Auth-Token: %s / r / n", cov ntaub ntawv, TOKEN); sprint f (cov ntaub ntawv, "%sConnection: kaw / r / n", cov ntaub ntawv); sprintf (cov ntaub ntawv, "%sContent-Type: application/json / r / n", data); sprintf (cov ntaub ntawv, " %sContent-Length: %d / r / n / r / n", cov ntaub ntawv, dataLen (lub cev)); sprintf (cov ntaub ntawv, "%s%s / r / n / r / n", cov ntaub ntawv, lub cev); / * Thawj qhov txuas */ clientUbi.connect (HTTPSERVER, HTTPPORT); / * Txheeb xyuas cov neeg siv khoom sib txuas */ yog (clientUbi.connect (HTTPSERVER, HTTPPORT)) {Serial.println (F ("Tshaj tawm koj cov kev hloov pauv:")); Serial.println (cov ntaub ntawv); / * Xa HTTP Thov */ clientUbi.print (cov ntaub ntawv); } / * Thaum tus neeg siv khoom muaj nyeem cov lus teb ntawm server * / thaum (clientUbi.available ()) {char c = clientUbi.read (); Serial.write (c); } / * Tsis nco * / dawb (cov ntaub ntawv); dawb (lub cev); / * Nres tus neeg siv khoom */ clientUbi.stop ();}

ProTip: koj tuaj yeem tshawb xyuas yog tias koj lub cuab yeej txuas nrog kom raug los ntawm kev qhib lub hauv paus saib hauv Arduino IDE.

Koj tuaj yeem txheeb xyuas lub cuab yeej tau tsim hauv koj li Ubidots backend los ntawm kev saib nws hauv koj tus lej Kev Tswj Ntaus Ntawv -> Cov cuab yeej.

Los ntawm kev nyem koj lub cuab yeej, koj yuav pom qhov sib txawv hu ua "nrug" qhov twg lub ntsuas qhov nyeem tau khaws cia. Lub npe no tau muab tso rau hauv cov cai uas koj nyuam qhuav tau muab tso rau hauv Arduino IDE. Yog tias koj xav hloov kho koj qhov kev hloov pauv tsis siv neeg, thov ua li ntawd los ntawm kev kho Daim Npav Ntaus Ntawv lossis los ntawm kev ua kom pom qhov hloov tshiab nrog tus lej hloov pauv raug rau koj daim ntawv thov.

Nrog Feather HUZZAH ESP8266 txuas nrog thiab tshaj tawm cov ntaub ntawv rau Ubidots, tam sim no yog lub sijhawm los tsim daim ntawv thov siv Ubidots ua tib zoo tsim cov cai-dawb thov kev teeb tsa.

Kauj Ruam 5: Kev Txhim Kho Daim Ntawv Thov Ubidots

Kev Txhim Kho Daim Ntawv Thov Ubidots
Kev Txhim Kho Daim Ntawv Thov Ubidots
Kev Txhim Kho Daim Ntawv Thov Ubidots
Kev Txhim Kho Daim Ntawv Thov Ubidots
Kev Txhim Kho Daim Ntawv Thov Ubidots
Kev Txhim Kho Daim Ntawv Thov Ubidots

Ubidots Event Configuration

Kev nyeem tam sim no peb tab tom xa mus rau Ubidots yog cov tswv yim nyob deb. Txog kev txhais cov ntawv nyeem no rau hauv cov txiaj ntsig xav tau uas peb xav tau -suav cov chav - peb yuav tsum tsim cov xwm txheej raws li cov theem hauv qab no:

  1. Sab hauv cov cuab yeej tam sim no "txav-tswj" tsim qhov hloov pauv tshiab uas hu ua "thawv", uas yuav tau txais 1 txhua zaus suav nrog chav tshiab.
  2. Mus rau Kev Tswj Ntaus Ntawv -> Cov Txheej Txheem, thiab nyem lub cim xiav ntxiv rau lub kaum sab xis saum toj ntawm nplooj ntawv kom ntxiv qhov xwm txheej tshiab.
  3. Kho koj qhov kev tshwm sim pib nrog "Yog ua":
  • Xaiv qhov sib txawv: "nrug"
  • Tus nqi: tus nqi (lub neej ntawd)
  • Tsawg dua lossis sib npaug rau [qhov siab tshaj plaws xav tau deb} ntawm lub ntsuas cua thiab lub thawv hla los ntawm*peb daim ntawv thov hu rau 500mm
  • Rau 0 feeb
  • Txuag

4. Thaum cov teeb tsa tau teeb tsa rau koj daim ntawv thov tshwj xeeb, nyem lub cim kab ntxwv "ntxiv rau" lub cim nyob rau sab xis saum toj kom ntxiv qhov kev ua raws cai.

5. Xaiv "Set Variable" raws li qhov kev nqis tes ua.

6. Tom ntej no, xaiv qhov tsim yav dhau los tsis sib xws "thawv" thiab tus nqi "1".

7. Txuag kev hloov pauv. Yog tias qhov xwm txheej tau teeb tsa kom raug, nws yuav xa "1" txhua zaus qhov kev ncua deb ntawm lub ntsuas cua thiab lub tsev ntev dua li qhov pib qhia, uas qhia tias tsis muaj ib qho khoom nyob ze - thiab yuav tsum suav ib chav tshiab uas nyuam qhuav dhau los.

Hauv daim npav Cov Khoom Tshwj Xeeb, koj yuav pom tias qhov sib txawv "thawv" qhov twg "1" raug xa tawm txhua lub sijhawm uas chav nyob tau hnov.

Tshwj xeeb tshaj yog muaj txiaj ntsig zoo rau kev siv txoj siv thauj khoom siv thiab chav suav cov qauv no tuaj yeem kho kom haum rau ib puag ncig sib txawv lossis kho vajtse yooj yim hauv koj li coding lossis koj daim ntawv thov kev txhim kho.

8. Pom pom tus naj npawb ntawm cov chav uas hnov (lossis lub sijhawm tau tshawb pom qhov khoom) Tam sim no, siv "cov thawv" sib txawv, peb tab tom tsim qhov tshiab qhov rai sib txawv qhov sib txawv kom suav tag nrho cov ntaub ntawv tau txais los ntawm qhov sib txawv "thawv" hauv txhais spam (feeb, teev, hnub, lis piam, thiab lwm yam). Txhawm rau ua qhov kev txhim kho no, ua raws cov theem yooj yim no:

Muab cov ntawv pov thawj hauv qab no rau koj qhov kev hloov pauv qhov rai tshiab

Xaiv lub cuab yeej: tswj kev txav chaw (lossis lub npe ntawm lub cuab yeej koj tab tom xa koj cov ntaub ntawv)

Xaiv qhov sib txawv: cov thawv

Suav tus lej: sum

Txhua: "1" teev (lossis raws li koj daim ntawv thov)

Tam sim no muab lub npe rau qhov hloov pauv tshiab uas qhia txog tus naj npawb ntawm cov thawv (lossis txav) suav hauv ib teev, ib yam li "thawv/teev" lossis "units/teev.

Kauj ruam 6: Dashboard Configurations

Dashboard Configurations
Dashboard Configurations

Thaum kawg, tsim lub dashboard los tso saib cov naj npawb ntawm cov chav nkag siab.

Mus rau Kev Tswj Ntaus Ntawv -> Dashboards thiab ntxiv cov cuab yeej tshiab. Cov cuab yeej no yuav tso tawm cov lej ntawm cov thawv suav hnub no tawg los ntawm teev.

Muab cov ntawv pov thawj hauv qab no rau koj tus widget tshiab kom pom koj suav.

Koj xav pom koj cov ntaub ntawv li cas?: Daim duab

Xaiv ib hom widget: kab ntawv kab

Ntxiv ib lub cuab yeej: tswj kev txav chaw

Ntxiv qhov sib txawv: cov thawv/teev

Tiav. Thiab nrog qhov kev txhim kho dashboard zaum kawg no - koj daim ntawv thov ua tiav thiab tam sim no koj muaj cov lus tsa suab muaj txiaj ntsig thiab muaj txiaj ntsig zoo thiab muaj lub ntsej muag nrhiav kom pom. Nov yog qhov kawg saib ntawm peb cov txiaj ntsig.

Pom zoo: