Cov txheej txheem:

Kev Thauj Mus Los Cov Ntaub Ntawv Pom Nrog Google Daim Ntawv Qhia: 6 Cov Kauj Ruam
Kev Thauj Mus Los Cov Ntaub Ntawv Pom Nrog Google Daim Ntawv Qhia: 6 Cov Kauj Ruam

Video: Kev Thauj Mus Los Cov Ntaub Ntawv Pom Nrog Google Daim Ntawv Qhia: 6 Cov Kauj Ruam

Video: Kev Thauj Mus Los Cov Ntaub Ntawv Pom Nrog Google Daim Ntawv Qhia: 6 Cov Kauj Ruam
Video: Dais thiab nab qa sib xeem tsheb kauj vab 2024, Kaum ib hlis
Anonim
Kev Thauj Mus Los Cov Ntaub Ntawv Pom Nrog Google Daim Ntawv Qhia
Kev Thauj Mus Los Cov Ntaub Ntawv Pom Nrog Google Daim Ntawv Qhia

Feem ntau peb xav sau ntau cov ntaub ntawv thaum caij tsheb kauj vab, lub sijhawm no peb siv Wio LTE tshiab los taug qab lawv.

Kauj Ruam 1: Yam Khoom Siv Hauv Txoj Haujlwm no

Hareware Cheebtsam

  • Wio LTE EU Version v1.3- 4G, Cat.1, GNSS, Espruino Tau tshaj
  • Grove - Pob ntseg -clip Lub Plawv Tus Nqi Sensor
  • Grove - 16 x 2 LCD (Dub rau Daj)

Software apps thiab cov kev pabcuam online

  • Arduino IDE Cov
  • PubNub Tshaj Tawm/Sau Npe API
  • Google Maps

Kauj ruam 2: Zaj dab neeg

Image
Image

Kauj Ruam 3: Kev Kho Vajtse Txuas

Web Configuration
Web Configuration

Nruab GPS thiab LTE kav hlau txais xov rau Wio LTE thiab ntsaws koj daim npav SIM rau nws. Txuas Lub Pob Ntseg-Lub Plawv Tus Nqi Sensor thiab 16x2 LCD rau Wio LTE's D20 thiab I2C chaw nres nkoj.

Koj tuaj yeem hloov Ear-clip Heart Rate Sensor mus rau lwm lub ntsuas uas koj nyiam. Thov saib qhov kawg ntawm kab lus no.

Kauj ruam 4: Web Configuration

Ntu 1: PubNub

Nyem rau qhov no nkag mus lossis sau npe rau PubNub tus lej, PubNub tau siv los xa cov ntaub ntawv ntawm lub sijhawm tiag tiag rau daim duab qhia chaw.

Qhib Demo Project hauv PubNub Tus Thawj Saib Xyuas Haujlwm Portal, koj yuav pom Tus Publish Key thiab Tus lej Sau Npe, nco ntsoov lawv rau kev tsim software.

Ntu 2: Google Daim Ntawv Qhia

Thov ua raws li no kom tau txais Google Map API Key, nws yuav siv rau hauv sofware programming ib yam.

Kauj ruam 5: Software Programming

Software Programming
Software Programming

Ntu 1: Wio LTE

Vim tias tsis muaj PubNub tsev qiv ntawv rau Wio LTE, peb tuaj yeem xa peb cov ntaub ntawv los ntawm HTTP thov, saib PubNub REST API Cov Ntawv.

Txhawm rau txuas HTTP txuas ntawm koj daim npav SIM txuas rau hauv Wio LTE, koj yuav tsum teeb tsa koj li APN ua ntej, yog tias koj tsis paub qhov ntawd, thov hu rau koj tus neeg teb xov tooj.

Thiab tom qab ntawd, teeb tsa koj PubNub Publish Key, Sau Npe Tseem Ceeb thiab Channel. Cov channel ntawm no, yog siv los sib txawv Publishers thiab Subscribers. Piv txwv li, peb siv cov tsheb kauj vab nyob ntawm no, txhua tus Subcribers hauv cov tsheb kauj vab channel yuav tau txais cov lus peb tshaj tawm.

Cov teeb tsa saum toj no, peb tsis ntim hauv chav kawm, yog li koj tuaj yeem hloov kho lawv hauv tsheb kauj vab.ino yooj yim dua, koj tuaj yeem rub cov lej no los ntawm qhov kawg ntawm kab lus no.

Qhov 2: PubNub

Nias thiab tuav Boot0 tus yuam sij hauv Wio LTE, txuas nws rau koj lub khoos phis tawj ntawm USB cable, rub qhov program hauv Arduino IDE, nias Pib dua tus lej hauv Wio LTE.

Tom qab ntawd tig mus rau PubNub, nyem Debug Console hauv Demo Project, sau koj lub npe lub npe hauv Default Channel, nyem Ntxiv Client.

Thaum koj pom [1, "Subscribed", "bike"] hauv console, Tus Neeg Ua Haujlwm tau ua tiav tiav. Tos ib pliag, koj yuav pom Wio LTE cov ntaub ntawv tshwm hauv console.

Ntu 3: Google Daim Ntawv Qhia

ENO Maps yog daim ntawv qhia sijhawm tiag nrog PubNub thiab MapBox, nws tseem tuaj yeem siv rau PubNub thiab Google Map, koj tuaj yeem rub nws los ntawm nws yog GitHub.

Koj tuaj yeem yooj yim siv tus piv txwv npe hu ua google-kos-line.html hauv cov ntawv piv txwv, tsuas yog hloov Kho Luam Tawm Tus Xov Tooj, Sau Npe Tseem Ceeb, Channel thiab Google Key hauv kab 29, 30, 33 thiab 47.

CEEB TOOM: Thov tawm kab 42, lossis nws yuav xa cov ntaub ntawv simulation rau koj PubNub.

Yog tias koj xav kom pom lub plawv ntsuas kab ntawv hauv qab txoj cai sib koom, koj tuaj yeem siv Chart.js, nws tuaj yeem rub tawm los ntawm nws lub Vev Xaib, muab tso rau hauv ENO Maps 'lub hauv paus nplaub tshev, thiab suav nrog nws rau google-kos-line.html lub taub hau.

Thiab ntxiv cov canvas hauv qhov div los tso saib daim duab:

Tom qab ntawd tsim ob arrays kom khaws cov ntaub ntawv qhia

//… var chartLabels = Array tshiab (); var chartData = tshiab Array (); //…

Ntawm lawv, daim ntawv teev npe siv los khaws cov ntaub ntawv chaw, daim ntawv qhia hnub yog siv los khaws cov ntaub ntawv ntsuas lub plawv. Thaum cov lus tuaj, thawb cov ntaub ntawv tshiab rau lawv, thiab rov ua dua daim duab.

//… var map = eon.map ({message: function (message, timetoken, channel) {//… chartLabels.push (obj2string (message [0].latlng)); chartData.push (message [0].data); var ctx = document.getElementById ("chart"). getContext ('2d'); var chart = new Chart (ctx, {type: 'line', data: {labels: chartLabels, datasets: [{label: " Lub plawv dhia ", cov ntaub ntawv: chartData}]}}); // …}});

Txhua yam ua tiav. Sim coj nws nrog koj caij tsheb kauj vab tom ntej.

Kauj Ruam 6: Yuav Ua Li Cas Nrog Lwm Tus Sensor Grove?

Hauv Wio LTE txoj haujlwm, koj tuaj yeem nqa ib thiab ntau cov ntaub ntawv kev cai los tso rau hauv kab ntawv lossis ua ntau dua. Kab lus hauv qab no qhia yuav hloov kho qhov program kom ua tiav nws li cas.

Thawj qhov koj yuav tsum paub yog, json koj xav tshaj tawm rau PubNub, yuav tsum tau nkag mus hauv url. Nkag mus json nyuaj-coded hauv chav kawm BikeTracker, nws zoo li no:

%% 5b %% 7b %% 22latlng %% 22 %% 3a %% 5b%f %% 2c%f %% 5d %% 2c %% 22data %% 22 %% 3a%d %% 7d %% 5d

Yog li nws yooj yim los nqa ib cov ntaub ntawv kev cai, lossis koj tuaj yeem siv cov cuab yeej url-encode los ua koj tus kheej encoded json kom tau txais cov ntaub ntawv ntau ntxiv.

Lub sijhawm no peb sim siv I2C High Accracy Temp & Humi Grove los hloov Lub plawv dhia Grove. Vim tias LCD Grove tseem siv I2C, peb siv I2C Hub los txuas Temp & Humi Grove thiab LCD Grove rau Wio LTE.

Tom qab ntawd suav nrog cov ntaub ntawv taub hau rau BickTracker.h, thiab ntxiv qhov sib txawv thiab txheej txheem rau BikeTracker chav kawm kom khaws thiab ntsuas kub.

/// BikeTracker.h

//… #include “Seeed_SHT35.h” class application:: BikeTracker: application:: interface:: IApplication {//… proteced: //… SHT35 _sht35; ntab _ kub; //… void MeasureTemperature (tsis muaj dab tsi); } /// BikeTracker.cpp //… // BikeTracker:: BikeTracker (khoob) //: _ethernet (Ethernet ()), _gnss (GNSS ()) {} // 21 yog tus lej SCL tus lej BikeTracker:: BikeTracker (void): _ethernet (Ethernet ()), _gnss (GNSS ()), _sht35 (SHT35 (21)) {} //… void BikeTracker:: measureTemperature (void) {ntab kub, av noo; yog (_sht35.read_meas_data_single_shot (HIGH_REP_WITH_STRCH, & kub, & av noo) == NO_ERROR) {_temperature = kub; }} // ib…

Yog tias koj xav tau, koj tuaj yeem hloov LCD cov zaub hauv Loop () txoj hauv kev:

// sprintf (line2, "Lub plawv dhia: %d", _heartRate);

Ntsuas Kub (); sprintf (kab 2, "Temp: %f", _temperature);

Tab sis yuav ua li cas tshaj tawm nws rau PubNub? Koj yuav tsum hloov pauv json thiab sprintf () kev ua haujlwm tsis hauv PublishToPubNub () txoj hauv kev, cia nws zoo li no:

// sprintf (cmd, "Tau txais/tshaj tawm/%s/%s/0/%s/0/%% 5b %% 7b %% 22latlng %% 22 %% 3a %% 5b%f %% 2c%f% %5d %% 2c %% 22data %% 22 %% 3a%d %% 7d %% 5d? Store = 0 HTTP/1.0 / n / r / n / r ", // _publishKey, _subscribeKey, _channel, _latitude, _longitude, _heartRate); sprintf (cmd, "Tau txais/tshaj tawm/%s/%s/0/%s/0/%% 5b %% 7b %% 22latlng %% 22 %% 3a %% 5b%f %% 2c%f %% 5d %% 2c %% 22data %% 22 %% 3a%f %% 7d %% 5d? Store = 0 HTTP/1.0 / n / r / n / r ", _publishKey, _subscribeKey, _channel, _latitude, _longitude, _temperature);

Tom qab ntawd koj tuaj yeem pom qhov ntsuas kub hauv PubNub debug console.

Pom zoo: