Cov txheej txheem:

Yuav Ua Li Cas Txuas Raspberry Pi mus rau Huab Siv Node.js: 7 Kauj Ruam
Yuav Ua Li Cas Txuas Raspberry Pi mus rau Huab Siv Node.js: 7 Kauj Ruam

Video: Yuav Ua Li Cas Txuas Raspberry Pi mus rau Huab Siv Node.js: 7 Kauj Ruam

Video: Yuav Ua Li Cas Txuas Raspberry Pi mus rau Huab Siv Node.js: 7 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Yuav Ua Li Cas Txuas Raspberry Pi mus rau Huab Siv Node.js
Yuav Ua Li Cas Txuas Raspberry Pi mus rau Huab Siv Node.js

Phau ntawv qhia no muaj txiaj ntsig zoo rau txhua tus neeg saib kom txuas Raspberry Pi mus rau huab, tshwj xeeb tshaj yog rau AskSensors IoT platform, siv Node.js.

Tsis muaj Raspberry Pi?

Yog tias koj tsis muaj tus Raspberry Pi tam sim no, Kuv yuav qhia koj kom tau txais Raspberry Pi 3, vim tias nws nrawm dua thiab koj yuav tsis tas yuav yuav ib qho USB Wi-nkaus adapter sib cais. Ib qho ntxiv, peb yuav tsum teeb tsa node.js ntawm Raspberry Pi thiab ntau Node.js cov ntawv sau xav tau Raspberry Pi raws li ARMv7+ architecture xws li Pi 3 lossis Pi 2 thiab yuav tsis ua haujlwm nrog Raspberry Pi 1 Model B /B+ lossis Raspberry Pi Zero.

Tab sis tsis txhob txhawj, nws zoo nkauj ncaj nraim, tsuas yog ua raws cov kauj ruam!

Paub nrog Node.js?

Koj yuav tsum tau ua thawj qhov kev sim ntawm node.js nrog AskSensors los ntawm koj lub khoos phis tawj (Windows/Linux/MacOs), kuv qhov kev qhia yav dhau los qhia pom ib qib zuj zus qhia rau cov ntaub ntawv tsis siv neeg xa mus rau AskSensors siv node.js.

Kauj Ruam 1: Cov Khoom Uas Koj Xav Tau

Nov yog cov ntaub ntawv xav tau:

  1. Raspberry Pi 3 Qauv B+ lossis Qauv B (koj tseem tuaj yeem siv Raspberry Pi 2 Qauv B)
  2. USB micro cable los txhawb koj li Pi.
  3. Daim npav MicroSD, Kuv pom zoo kom chav kawm 10 daim npav uas yog 16 GB lossis siab dua.
  4. MicroSD rau SD daim npav nco daim npav, koj yuav tsum tau siv daim npav SD nyeem ntawv ntawm koj lub khoos phis tawj/lub desktop los sau rau daim npav microSD.

Kauj ruam 2: Teeb Koj Raspberry Pi

Teeb Koj Raspberry Pi
Teeb Koj Raspberry Pi

Khiav kev teeb tsa yooj yim ntawm Raspbian ntawm Raspberry Pi dhau los ua qhov yooj yim thiab piav qhia meej hauv phau ntawv no Pib Pib. Nov yog cov kauj ruam tseem ceeb:

  1. Download NOOBS,
  2. Extract nws ntawm koj SD
  3. Plug nws thiab qhib lub Raspberry Pi.
  4. Thaum hais kom sai, xaiv rau nruab Raspbian thiab cia nws khiav.

Yog lawm, Tam sim no peb muaj qhov zoo heev Raspberry Pi system uas tuaj yeem siv rau ntau yam haujlwm!

Kauj Ruam 3: Nruab Node Js

Ntawm no peb mus rau hauv node.js teeb tsa, Txhim kho ARM-version ntawm Node ua yooj yim heev!

  1. Xyuas kom koj tau txuas nrog internet
  2. Qhib lub davhlau ya nyob twg ntawm Raspberry Pi. Ntaus cov lus txib no:

wget

sudo dpkg -i node_latest_armhf.deb

Yeej. Nws yuav tsum tsis siv sijhawm ntev dhau los rub tawm thiab teeb tsa.

Koj kuj tseem muaj qhov kev xaiv los hais qhia qhov txuas chaw nyob ntawm cov version koj xav tau:

Mus rau node.js nplooj ntawv rub tawm thiab luam qhov txuas qhov chaw nyob ntawm tus qauv ntawm ARM uas koj xav tau. Piv txwv li:

wget

Kauj Ruam 4: Ntsuam Xyuas Koj Li

Kom paub tseeb tias node.js ua haujlwm raug, Ntaus cov lus txib hauv qab no. Nws yuav tsum xa rov qab tam sim no ntawm node thiab npm teeb tsa.

node -v

npm -v

Xyuas kom nws tsis muab qhov yuam kev.

Yog tias txhua yam zoo, peb tuaj yeem txav mus rau qib tom ntej!

Kauj Ruam 5: Sau Npe Rau Asksensors

Kos npe rau AskSensors tus account yooj yim thiab pub dawb, yog tias koj tseem tsis muaj tus account tseem, tsim ib qho tshiab ntawm

Tsim lub Sensor tshiab nrog tsawg kawg ib tus qauv, Txuag nws, thiab qhia tus qauv 1 teeb duab.

Qhov tshwj xeeb Api Key In yuav muab, peb yuav siv nws hauv qib tom ntej.

Xav paub ntau ntxiv?

Ntawm no, Kuv yuav tsis mus hla cov ntsiab lus ntawm kev tsim AskSensors tus account, Qhov no tau piav qhia ntxaws hauv ntau cov lus qhia, yeeb yaj kiab, thiab qhia.

Kauj Ruam 6: Khiav Node.js Script

Khiav Node.js Script
Khiav Node.js Script

Qhov node.js demo peb tab tom hais qhia xa cov ntaub ntawv dag mus rau AskSensors hla HTTPS GET Thov, txhua 20 vib nas this (20 vib nas this tau teeb tsa ua piv txwv, koj tuaj yeem teeb tsa lub sijhawm sib txawv).

Rub tawm.js cov ntaub ntawv los ntawm github, Nws xav tau kev teeb tsa ntawm https npm pob.

Koj yuav tsum teeb tsa koj tus yuam sij Api txhawm rau xa cov ntaub ntawv mus rau lub ntsuas qhov ntsuas koj tau tsim raws li qhia hauv qib dhau los.

Tam sim no koj tau npaj los sau tsab ntawv kawg:

node

Qhov ntawd yog nws! Txaus siab rau saib koj cov ntaub ntawv kwj phiaj hauv kab ntawv (daim duab saum toj no qhia qhov piv txwv ntawm daim phiaj tawg).

Kauj ruam 7: Ua tiav

Ua tsaug rau koj nyeem. xav tias dawb los tawm tswv yim!

Peb yuav tshaj tawm ntau cov lus qhia muaj txiaj ntsig yav tom ntej, ua raws peb!

Vam tias yuav ntsib koj dua:)

Pom zoo: