Cov txheej txheem:

LoRa-Raws Li Pom Kev Pom Kev Pom Zoo rau Kev Ua Liaj Ua Teb Iot - Tsim Tsim Daim Ntawv Thov Ua Ntej Siv Firebase & Angular: 10 Kauj Ruam
LoRa-Raws Li Pom Kev Pom Kev Pom Zoo rau Kev Ua Liaj Ua Teb Iot - Tsim Tsim Daim Ntawv Thov Ua Ntej Siv Firebase & Angular: 10 Kauj Ruam

Video: LoRa-Raws Li Pom Kev Pom Kev Pom Zoo rau Kev Ua Liaj Ua Teb Iot - Tsim Tsim Daim Ntawv Thov Ua Ntej Siv Firebase & Angular: 10 Kauj Ruam

Video: LoRa-Raws Li Pom Kev Pom Kev Pom Zoo rau Kev Ua Liaj Ua Teb Iot - Tsim Tsim Daim Ntawv Thov Ua Ntej Siv Firebase & Angular: 10 Kauj Ruam
Video: Tswv Yexus lub neej thaum pib txug thaum xaus 2024, Hlis ntuj nqeg
Anonim
LoRa-Raws Li Pom Kev Pom Kev Pom Zoo rau Kev Ua Liaj Ua Teb Iot | Tsim Tsim Daim Ntawv Thov Ua Ntej Siv Firebase & Angular
LoRa-Raws Li Pom Kev Pom Kev Pom Zoo rau Kev Ua Liaj Ua Teb Iot | Tsim Tsim Daim Ntawv Thov Ua Ntej Siv Firebase & Angular

Hauv tshooj dhau los peb tham txog yuav ua li cas cov ntsuas hluav taws xob ua haujlwm nrog loRa module txhawm rau nthuav tawm cov ntaub ntawv hluav taws kub Lub Sijhawm Sijhawm, thiab peb tau pom daim duab qhia siab heev li cas peb txoj haujlwm tag nrho ua haujlwm li cas. Hauv tshooj no peb yuav tham txog yuav ua li cas peb tuaj yeem sau cov ntaub ntawv no hauv web application.

Kauj ruam 1: Teeb Angular hauv Koj Lub Computer

Angular yog ib qho ntawm javascript nrov tshaj plaws (uas yog cov ntawv sau zoo) raws cov qauv feem ntau siv hauv kev lag luam software, raws li peb siv firebase raws li peb cov backend (backend raws li server) tsuas yog qhov peb xav tau yog lub ntsej muag los tswj cov backend no. Yog li cia saib yuav ua li cas teeb tsa txhua qhov tsim nyog qhov no los ntawm kos.

xav txog tag nrho cov lus qhia no yog lub hauv paus ntawm Windows 10 ib puag ncig thiab vam tias koj muaj kev paub yooj yim txog kaum thiab firebase.

Nruab node.js thiab NPM ntawm qhov rais

Ua ntej tshaj plaws mus rau Node.js lub vev xaib raug cai node.js thiab rub tawm qhov tseeb version ntawm node.js, node yog ib puag ncig runtime kom khiav tag nrho cov lej javascript. NPM sawv rau ntawm tus thawj tswj hwm pob uas pab koj teeb tsa txhua lwm yam software tsim nyog los ntawm cov cuab yeej kab hais kom ua, uas yog lub tswv yim yooj yim txog ntawm node thiab NPM yog tias koj xav mus tob dua muaj tons ntawm cov vev xaib thiab yeeb yaj kiab uas koj tuaj yeem tau txais kev paub ntau ntxiv txog ntawm. (Nco ntsoov tias koj tau nruab node.js thoob ntiaj teb koj lub khoos phis tawj).

thov txheeb xyuas yog tias koj tau ua tiav teeb tsa ua ntej koj mus tom ntej.

Nruab Angular

Qhib koj cov kab hais kom ua cuab yeej thiab ua haujlwm hauv qab no hais kom ua, npm nruab -g @angular/cli

tam sim no nco ntsoov tias koj tau teeb tsa lub kaum ntse ntse tiav, koj tuaj yeem kawm paub ntau ntxiv txog kaum rau qhov kev qhia no angular official lub vev xaib.

Kauj Ruam 2: Teeb Koj Cov Qauv Txheej Txheem

Teeb Koj Cov Qauv Txheej Txheem
Teeb Koj Cov Qauv Txheej Txheem
Teeb Koj Cov Qauv Txheej Txheem
Teeb Koj Cov Qauv Txheej Txheem

Mus rau qhov chaw koj xav tsim koj txoj haujlwm, rau kuv kuv tau siv D: / Angular-Projects qhov chaw no. Qhib kab hais kom ua tam sim ntawd hauv qhov chaw ntawd. Ntaus hauv qab cov lus txib.

ng kev ua liaj ua teb tshiab-saib xyuas-kab ke

ces kaum yuav tsim txhua yam tsim nyog uas peb xav kom muaj hauv peb qhov kawg. ua ntej peb txuas frontend thiab backend ua ke. cia peb kawm me ntsis txog qhov angular thiab firebase.

Angular

Wb tham txog yuav ua li cas lub web architecture zoo li zoo li, muaj frontend lossis cov neeg siv khoom backend lossis server sab, cov neeg siv khoom txhais tau tias nws yog qhov twg tag nrho HTML, CSS muaj, tab sis nyob rau hauv angular peb tsis tas yuav tsim cov nplooj ntawv web rau peb muaj zoo li, home.html, about.hml, index.html … thiab lwm yam. tsuas muaj ib nplooj ntawv nkaus xwb rau tag nrho daim ntawv thov nws yog index.html thaum tus neeg siv hla mus rau lwm nplooj ntawv lossis lwm qhov muaj index.html tab tom ua nrog nrog cov nplooj ntawv uas txhais tau tias html thiab css saib ntawm qee nplooj ntawv. yog li peb daim ntawv thov tag nrho tsuas muaj ib nplooj.html nkaus xwb. Nov yog qhov peb hu ua SPA. Yog li cia peb tsim peb daim ntawv thov. qhib CMD hauv tib cov npe hauv qab no hais kom ua.

ng tsim khoom tiv thaiv tsev.

qhov no yuav tsim kom muaj cov ntawv ntawm koj lub vev xaib, tom qab ntawd koj yuav pom cov ntawv home.ts thiab home.html cov ntaub ntawv thiab home.css hauv home.html cov ntaub ntawv uas koj yuav txiav txim siab li cas koj cov nplooj ntawv hauv tsev thiab hauv tsev. css qhov twg koj yuav ntxiv koj cov style rau nplooj ntawv hauv tsev, thiab kawg home.ts cov ntaub ntawv uas koj yuav mus rau tus lej koj hom ntawv sau lossis javascript code los ua haujlwm nrog peb backend.

Kauj Ruam 3: Txhim Kho Bootstrap 4

Raws li peb tau tham hauv cov kauj ruam yav dhau los tam sim no peb tau nqis tes ua peb txoj haujlwm thiab tam sim no peb muaj lub tswv yim meej txog yuav ua li cas kaum sab xis ua haujlwm. tam sim no rau lub hom phiaj styling peb yuav siv bootstrap 4, txhawm rau nruab bootstrap rau peb cov haujlwm yam hauv qab no hais kom ua hauv txoj haujlwm.

npm nruab bootstrap@3

tam sim no koj tsis tas yuav txhawj xeeb yuav ua li cas peb tuaj yeem tsim peb lub vev xaib, bootstrap yuav ua qhov ntawd.

Kauj Ruam 4: Txheeb Txoj Kev

Txhais Kev
Txhais Kev

Hauv qhov project IOT peb tab tom yuav sau lub taub hau, lub hauv paus, qhov ntsuas kub, av noo, Co2 feem pua, cov av noo. yog li peb tab tom tsim 4 nplooj ntawv nplooj ntawv uas txhais tau tias nyob rau hauv kaum peb peb yuav tsim 4 ntu rau txhua qhov ntsuas no.

ntshuam angular router module hauv AppModule tivthaiv.

txhais cov kev hauv cov ntawv cais.

const txoj kev: Txoj kev = [{txoj kev: 'thawj-tivthaiv', tivthaiv: HomeComponent}, {txoj kev: 'thib ob tivthaiv', tivthaiv: HumiComponent},];

ntxiv cov kab no ntawm cov lej sab hauv cov cim ntshuam hauv AppMoodule.

@NgModule ({ntshuam: [RouterModule.forRoot (txoj hauv kev)], xa tawm: [RouterModule]})

Cia peb ntxiv bootstrap navigation bar code hauv peb cov ntawv header.html thiab txuas peb cov khoom,

Kauj ruam 5: Firebase

Firebase
Firebase
Firebase
Firebase

Firebase yog ib qho kev pabcuam txias tshaj plaws uas google tau muab rau lawv cov neeg siv. Yog li ib qho ntawm cov yam ntxwv uas peb tau siv rau txoj haujlwm no yog firebase lub sijhawm tiag tiag database thiab hosting. cia peb tsim tus account firebase thiab txuas peb txoj haujlwm rau firebase lub sijhawm tiag tiag database.

Kauj ruam 01: Nkag mus rau koj tus account gamil

kauj ruam 02: ntaus firebase console hauv koj qhov bar tshawb

kauj ruam 03: tam sim no koj ua tiav.

Kauj Ruam 6: Nruab Firebase hauv Angular

Txhawm rau ua haujlwm nrog firebase peb tau teeb tsa lossis suav nrog qhov kev pabcuam tsev qiv ntawv txuas rau firebase thiab cov ces kaum ua ke. mus rau koj txoj hauv kev txoj haujlwm thiab qhib CMD thiab ntaus hauv qab kab ntawv.

npm nruab firebase @angular/fire --save

Kauj Ruam 7: Txuas Peb Txoj Haujlwm Angular Nrog Firebase

Txuas Peb Txoj Haujlwm Angular Nrog Firebase
Txuas Peb Txoj Haujlwm Angular Nrog Firebase
Txuas Peb Txoj Haujlwm Angular Nrog Firebase
Txuas Peb Txoj Haujlwm Angular Nrog Firebase
Txuas Peb Txoj Haujlwm Angular Nrog Firebase
Txuas Peb Txoj Haujlwm Angular Nrog Firebase
Txuas Peb Txoj Haujlwm Angular Nrog Firebase
Txuas Peb Txoj Haujlwm Angular Nrog Firebase

tam sim no peb yuav tsum ntxiv peb txoj haujlwm rau hauv firebase. nias ntxiv lub cim icon ntawm koj tus account firebase, thiab muab lub npe project uas koj nyiam thiab txuas ntxiv ob lwm ntxiv kom txog thaum koj pom qhov zoo nkauj xiav dashboard ntawm koj tus account firebase, koj tuaj yeem pom tias sab laug sab peb tuaj yeem pom tag nrho cov npe ntawm firebase cov kev pabcuam, yog li peb tuaj yeem siv txhua qhov kev pabcuam no. tam sim no txhua yam npaj txhij mus. hauv koj lub console ntxiv ib qho app kom pib thiab nyem rau ntawm lub cim. kom tau txais txhua qhov kev teeb tsa cov ntsiab lus los txuas peb daim ntawv thov angular nrog tus lej firebase. Cov ntsiab lus no tshwj xeeb rau peb txoj haujlwm. tam sim no theej cov ntsiab lus thiab mus rau koj txoj haujlwm angular nrhiav ib puag ncig.ts ntxiv hauv qab cov cai thiab muab cov ntsiab lus ntawd tso rau hauv.

export const ib puag ncig = {

ntau lawm: muaj tseeb, firebase: {

koj cov ntsiab lus teeb tsa ntawm no …

}

};

thiab tseem ntxiv cov lej hauv qab no ntawm app.module.ts

ntshuam: [AngularFireModule.initializeApp (ib puag ncig.firebase),….],

Kauj Ruam 8: Txhim Kho NgxCharts Library hauv Koj Txoj Haujlwm Angular

Mus rau txoj hauv kev raws li peb tau ua hauv cov kauj ruam dhau los, ntaus hauv qab cov cai hauv koj li CMD.

npm i @swimlane/ngx-charts --save

NgxChart Official site mus rau ntawm lub xaib no thiab rub daim duab uas koj xav tau. Kuv nyiam nrog kab ntawv kab. mus rau qhov url no thiab rub cov cai thiab ntxiv rau hauv cov khoom sib xws.

Kauj Ruam 9: Tsim Cov Kev Pabcuam Hauv Chav Kawm thiab Lub Sijhawm Teev Npe

Tsim Cov Kev Pabcuam Hauv Chav Kawm thiab Lub Sijhawm Teev Npe
Tsim Cov Kev Pabcuam Hauv Chav Kawm thiab Lub Sijhawm Teev Npe
Tsim Cov Kev Pabcuam Hauv Chav Kawm thiab Lub Sijhawm Teev Npe
Tsim Cov Kev Pabcuam Hauv Chav Kawm thiab Lub Sijhawm Teev Npe

Mus rau qhov project nplaub tshev thiab qhib CMD thiab ntaus txoj hauv kev siv tau thiab nyiam lub npe npe rau kev pabcuam nrog rau cov lus tsim tawm. Ua ntej peb nkag mus rau cov cai Kuv xav qhia me ntsis tswv yim txog firebase lub sijhawm tiag tiag database. Nws tsis zoo li lwm cov qauv piv txwv txheeb ze database. Peb tsis tuaj yeem pom cov qauv hauv rooj hauv Qhov Kev Sib Txawv ntawm cov databases, Qhov no hu ua NOSQL database peb tuaj yeem pom cov ntawv sau lossis cov ntaub ntawv hauv paus cov qauv. Uas yog hu ua JSON, yog li yog peb xav khaws cov ntaub ntawv sab hauv hauv cov ntaub ntawv zoo li no peb yuav tsum hla cov ntawd zoo li JSON Cov Hom Phiaj. Hauv daim duab saum toj no koj tuaj yeem pom, Hauv peb qhov chaw khaws ntaub ntawv muaj ib lub node lossis ntug hu ua cov cuab yeej, thiab hauv qab ntawm qhov ntawd muaj lwm lub npe hu ua DeviceA thiab hauv qab ntawm lub node, koj tuaj yeem pom saum toj no txhua qhov ntsuas xws li cov av noo, kub..etc.. hauv qab Hum node koj tuaj yeem pom cov ntaub ntawv senor uas tau khaws tseg ib ntus.

async getData () {

qhov no.items = ;

rov cog lus tshiab ((daws teeb meem) => {

qhov no.database list (`/devices/$ {this.sessionService.get (" DeviceA ")}/$ {" Hum "}`).snapshotChanges (). subscribe (snapshot => {

snapshot.forEach (caij => {

yog (! element.key.startsWith ('current_hum')) {

this.items.push ({

name: moment (element.payload.val () ['date'], 'YYYY-M-DD hh: mm: ss'). format ('YYYY-MM-DD hh: mm'), tus nqi: element.payload.val () ['tus nqi']

});

}

});

daws (qhov no.items);

});

});

}

qhov no yog cov kev pabcuam hauv chav kawm txhawm rau nkag mus rau cov ntaub ntawv uas tau khaws cia hauv qab hum node hauv lub database, txhua yam koj yuav tsum tau ua yog hu rau chav kawm getData () ua haujlwm qhov twg koj xav sau koj daim ntawv.

async ngOnInit () {this.items = tos qhov no.humService.getData ();

qhov no.multi = [{

npe: '%', series: this.items

}];

}

Ntawm no sab hauv peb cov chav kawm ngOnInit txoj hauv kev peb tau hu rau peb cov kev pabcuam suav nrog ntau qhov array uas cov array uas peb yuav tsum dhau qhov txiaj ntsig rau daim duab.

Kauj ruam 10: Sau koj li Project

Sau koj qhov Project
Sau koj qhov Project
Sau koj qhov Project
Sau koj qhov Project

Mus rau koj cov phiaj xwm phiaj xwm thiab qhib CMD thiab ntaus ng server, Tom qab ntawd tag nrho Cov Cai Ntaus Cim yuav hloov mus rau hauv javascript. thiab ntaus qhov url uas CMD tab tom yuav qhia rau koj, rau qhov haujlwm saum toj no https:// localhost: 4200/tsev thiab koj tau ua tiav.

Pom zoo: