Cov txheej txheem:

Tsim Kuv Tus Kheej rau Kuv Cov Ntaub Ntawv IOT ntawm Raspberry PI: 3 Cov Kauj Ruam
Tsim Kuv Tus Kheej rau Kuv Cov Ntaub Ntawv IOT ntawm Raspberry PI: 3 Cov Kauj Ruam

Video: Tsim Kuv Tus Kheej rau Kuv Cov Ntaub Ntawv IOT ntawm Raspberry PI: 3 Cov Kauj Ruam

Video: Tsim Kuv Tus Kheej rau Kuv Cov Ntaub Ntawv IOT ntawm Raspberry PI: 3 Cov Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Tsim Kuv Tus Kheej rau Kuv Cov Ntaub Ntawv IOT ntawm Raspberry PI
Tsim Kuv Tus Kheej rau Kuv Cov Ntaub Ntawv IOT ntawm Raspberry PI

Thov nyeem yog tias koj xav tau los tsim koj tus kheej daim duab IOT siv 7 kab ntawm cov cai.

Kuv xav tsim cov kab kos los tso saib cov ntaub ntawv hauv cov duab los ntawm kuv lub IOT sensors ntawm nplooj ntawv web. Yav dhau los, rau qhov no, Kuv tau siv cov kev pabcuam thib peb (qee qhov them nyiaj) thiab cov neeg sab nrauv thib peb ua haujlwm rau kuv cov ntaub ntawv khaws cia - Mysql, siv cov lus programming hu ua Php. Kuv pom cov kev pabcuam thib 3 no nyuaj heev lossis kim dhau rau kev xa tawm. Yog li ntawd, kuv tau sau kuv tus kheej Php ua haujlwm yooj yim uas siv cov ntaub ntawv raws li arrays los ntawm cov ntawv sau lossis cov lus database (los ntawm Mysql tej zaum) thiab qhia lawv ua kab kab ntawm lub vev xaib. Kuv tau ua txhua qhov php code muaj nyob ntawm github-https://github.com/scanos/php-simple-chart. Kuv kuj tau suav qee qhov chaws ntawm no - thawj php cov ntaub ntawv - PhpSimpleChart2.php -contains kab kab ua haujlwm kab ntawv ua lwm yam, PhpSimpleChart_ex1.php, yog cov piv txwv cov ntaub ntawv qhia siv yuav siv nws li cas. Kuv hais qhia tias koj tseem mus ntsib nplooj ntawv github kom tau txais cov cai hloov tshiab.

Kuv tab tom siv qhov no ntawm kuv tus Raspberry Pi. Nov yog yam koj xav tau:

1) Qee qhov kev paub ntawm kev siv lub web server xws li Apache, cov ntaub ntawv xws li Mysql, thiab PHP. Ua ke, cov no hu ua LAMP - Linux, Apache, Mysql thiab PHP. thiab muaj ntau cov ntaub ntawv ntawm lub vev xaib hais txog kev xa tawm ntawm Raspberry Pi. Yog li ntawd, kuv yuav tsis npog qhov no ntawm no.

2) LAMP linux ib puag ncig - dua, xws li Raspberry Pi.

3) Ib qho txhais tau tias rub tawm thiab tsim cov ntaub ntawv rau koj lub vev xaib ib puag ncig, piv txwv li cov ntawv tais ceev tseg ntawm koj li Raspberry Pi uas koj tso koj li program php cov ntaub ntawv.

Tom ntej no, kuv yuav qhia koj li cas los tsim koj tus kheej Php cov ntaub ntawv siv ob daim ntawv php uas kuv tau hais ua ntej.

Kauj Ruam 1: Tus PHP Function Code - PhpSimpleChart2.php

PHP Function Code - PhpSimpleChart2.php
PHP Function Code - PhpSimpleChart2.php

Cov ntaub ntawv no hu ua PhpSimpleChart2.php - koj yuav tsum rub nws los ntawm git chaw cia khoom los ntawm txhaj lub pob download / clone - saib cov duab saum toj no. Thaum koj tau ua tiav lawm, xa ob daim ntawv php mus rau koj lub vev xaib siv koj tus qauv FTP tus thov lossis tej zaum koj tau teeb tsa samba sib koom ntawm koj li Raspberry Pi uas ua rau koj Pi folders zoo li windows folders.

Koj tsis tas yuav hloov pauv cov cai hauv qhov tseem ceeb Php cov ntaub ntawv - PhpSimpleChart2.php. Nov yog kab lus kab lus yooj yim tsim ua haujlwm rau Php. Yeej, 2 arrays raug xa mus rau kev ua haujlwm nrog rau lwm cov lus sib cav xws li daim duab qhia qhov ntev. 1st array muaj thawj qhov tseem ceeb xws li kub thiab lwm yam. Qhov thib ob array muaj cov hnub tseem ceeb cuam tshuam. Qhov kev zov me nyuam sim ua kom pom lub teeb pom kev zoo nyob ntawm qhov ntau, min, max thiab array ntsiab lus. Daim ntawv tshwm sim yuav raug txiav thiab muab tso rau hauv MS cov ntaub ntawv ua haujlwm raws li gif,-p.webp

Thaum koj tau tshaj tawm PhpSimpleChart2.php rau koj lub vev xaib, koj tuaj yeem sau koj tus kheej tsab ntawv los siv qhov no. Qhov no tau qhia nyob rau nplooj ntawv tom ntej.

Kauj Ruam 2: Sau Koj Tus Kheej Txoj Haujlwm Raws Li Qhov Piv Txwv

Sau Koj Tus Kheej Txoj Haujlwm Raws Li Qhov Piv Txwv
Sau Koj Tus Kheej Txoj Haujlwm Raws Li Qhov Piv Txwv

Kuv tau qhia ib qho piv txwv txoj haujlwm, PhpSimpleChart_ex1.php uas rov nyob hauv git repository. Thawj kab ntawm txoj cai yog hu rau php tsab ntawv uas muaj daim ntawv qhia ua haujlwm -

xav tau ("PhpSimpleChart2.php");

Hauv qhov no, cov ntaub ntawv PhpSimpleChart2.php tau muab tso rau hauv tib daim nplaub tshev raws li tsab ntawv koj tab tom sau kom hu nws. Vam tias, koj yuav paub tias cov ntaub ntawv php yuav tsum muaj qhov nyeem tau zoo / sau cov khoom 755.

Tom ntej no, koj yuav tsum tsim koj cov ntaub ntawv cov ntaub ntawv thiab nthuav tawm cov kab. Nov yog cov piv txwv arrays, ib qho rau cov ntaub ntawv thiab ib qho rau cov hnub tim thiab sijhawm cuam tshuam. Pom tseeb, yuav tsum muaj tus lej zoo ib yam hauv ob pawg.

$ data_array = array ("12", "15", "18", "12", "11", "23", "11", "24", "15", "18", "12", " 11 "," 23 "," 11 "," 24 ");

$ date_array = array ("12th 14h", "12th 15h", "12th 16h", "12th 17h", "12th 18h", "12th 19h", "12th 20h", "12th 21h", "12th 15h", "12th 16h", "12th 17h", "12th 18h", "12th 19h", "12th 20h", "12th 21h");

Feem ntau, koj yuav nyeem cov txiaj ntsig no los ntawm cov lus nug database lossis thauj lawv los ntawm cov ntawv sau.

Tom ntej no, koj yuav tsum teeb tsa qhov ntsuas rau koj daim ntawv. Nws zoo nkauj ncaj nraim rau pem hauv ntej. Koj teeb tsa cov npe ua ntej thiab tom qab ntawd kho qhov siab thiab dav ntawm kab ntawv.

$ chart_text = "Kuv daim ntawv xeem Lub Xya Hli 2018";

$ y_title = "Temp Deg C";

$ x_scale = 1000;

$ y_scale = 400;

Tom qab ntawd koj ua lub luag haujlwm hu raws li hauv qab no.

draw_line_chart ($ data_array, $ date_array, $ chart_text, $ x_scale, $ y_scale, $ y_title);

Kuv tau qhia qhov tsim tawm ntawm qhov kev piv txwv no hauv daim duab txuas. Cov phiaj xwm phiaj xwm sim ntsuas qhov ntsuas thiab zam kev sib tsoo ntawm y-axis thiab daim duab piav qhia cov ntsiab lus. Vam tias, nws ua haujlwm rau koj. Qhov ntawd yog txhua yam koj xav tau.

Kauj Ruam 3: Xaus

Kuv vam tias koj pom qhov no muaj txiaj ntsig. Koj tuaj yeem siv lwm txoj hauv kev uas ua haujlwm rau koj tab sis ntawm no yog ob peb qhov kev xav hauv txhua kis;

1) Feem ntau cov neeg sab nrauv IOT teeb duab kev pabcuam ua haujlwm raws li kev pabcuam online uas nkag mus tau yooj yim feem ntau yog API.

2) IOT cov neeg siv muaj ntau yam kev txawj ntse nrog rau kev nthuav tawm cov duab ua haujlwm.

PROS ntawm kuv qhov kev daws teeb meem

a) tuaj yeem ua haujlwm offline

b) Xoom tus nqi.

c) Hneev taw me me

CONS

a) Tsis raug tshuaj xyuas kom zoo ib yam li cov tsev software loj.

b) Txwv tsis pub ua haujlwm, piv txwv li tsis muaj kab kos kab thiab lwm yam.

Khoom noj rau kev xav!

Pom zoo: