Cov txheej txheem:

Cov Ntaub Ntawv Huab Cua Siv Google Ntawv thiab Google Tsab Ntawv: 7 Kauj Ruam
Cov Ntaub Ntawv Huab Cua Siv Google Ntawv thiab Google Tsab Ntawv: 7 Kauj Ruam

Video: Cov Ntaub Ntawv Huab Cua Siv Google Ntawv thiab Google Tsab Ntawv: 7 Kauj Ruam

Video: Cov Ntaub Ntawv Huab Cua Siv Google Ntawv thiab Google Tsab Ntawv: 7 Kauj Ruam
Video: qhia sau ntawv nrawm los yog sau ntawv kom ceev || ສອນພີມໄວ ຫຼື ບໍ່ຕ້ອງເບີ່ງແປ້ນພີມ 2024, Kaum ib hlis
Anonim
Cov Ntaub Ntawv Huab Cua Siv Google Ntawv thiab Google Tsab Ntawv
Cov Ntaub Ntawv Huab Cua Siv Google Ntawv thiab Google Tsab Ntawv

Hauv Blogtut no, peb yuav xa cov nyeem ntawm SHT25 sensor mus rau google nplooj ntawv siv Adafruit huzzah ESP8266 uas pab xa cov ntaub ntawv mus rau internet.

  • Kev xa cov ntaub ntawv mus rau google daim ntawv xov tooj ntawm tes yog qhov muaj txiaj ntsig thiab txoj hauv kev yooj yim uas txuag cov ntaub ntawv hauv daim ntawv teev npe online.
  • Hloov chaw siv yam tshwj xeeb tshwj xeeb zoo li thawb lub thawv lossis MQTT NODE RED lossis lwm yam REST API, peb yuav xa cov ntaub ntawv los ntawm kev siv google tsab ntawv uas yooj yim tau txais cov ntaub ntawv los ntawm lub sensor los ntawm kev siv tsab ntawv txuas los ntawm google tsab ntawv thov tom qab tshaj tawm
  • Peb tuaj yeem siv cov ntawv sau xa cov ntaub ntawv los ntawm google daim ntawv, cov ntawv lossis txawm tias mus rau google tsav.
  • Tsuas yog tsis xaus ntawm no ntxiv koj tuaj yeem txuas Google nplooj ntawv nrog ib daim ntawv thov web-based uas sib qhia cov ntaub ntawv nrog cov neeg siv raws li lawv xav tau
  • Tsis muaj nqi ntxiv uas yuav tsum tau them tsis zoo li lwm cov servers hauv online ntawm no thiab koj tuaj yeem khaws cov ntaub ntawv mus txog 10 GB Siab kawg hauv tus neeg siv nyiaj thiab siv tau
  • Ib qho ntawm kev siv zog zoo tshaj plaws yog koj tuaj yeem kawm txog kev txuas cov ntaub ntawv rau hauv internet nrog rau qhov kev thov ntawm lub sijhawm tiag tiag yooj yim.
  • Peb yuav siv I2C kev sib txuas uas ua tus tswv-qhev tus txheej txheem los qhia cov ntaub ntawv nrog google nplooj ntawv hauv txoj kev hloov pauv tau.
  • I2C cov txheej txheem txheej txheem sib txuas cov cuab yeej sensor thiab ua haujlwm nrog ib puag ncig 256 lub cim nyob rau ib lub sijhawm los ntawm kev siv tsuas yog 2 xaim rub tawm kom hloov cov ntaub ntawv sensor hauv 8 khoom kho vajtse

Kauj ruam 1: Kho vajtse

Adafruit Feather HUZZAH Cov Khoom Siv

Adafruit Feather Huzzah Board

Adafruit I2C koom ua ke thiab USB adapter

SHT25 Kub thiab Vaum Sensor

I2C Kab

Kauj Ruam 2: Cov Khoom Ua Haujlwm Li Cas

Nqa cov nyeem ntawm cov ntaub ntawv ntawm lub sijhawm tiag tiag ntawm cov ntsuas hluav taws xob los ntawm ESP8266 thiab xa cov ntaub ntawv mus rau huab sib txawv platform yog yooj yim dua.

Peb yuav siv Wire.h lub tsev qiv ntawv hauv Arduino IDE los tsim ob txoj kev sib txuas lus ntawm Adafruit Huzzah Board thiab SHT25 sensor I2C module thiab I2C cable.

Nco tseg: Txhawm rau zam kev teeb tsa txoj kab hluav taws xob nyuaj, kuv yuav siv I2C adapter rau Adafruit Huzzah tsim los txuas I2C sensor.

Rau tus tshiab kom teeb tsa Esp8266 yo yuav tsum dhau los ntawm ESP8266 teeb tsa

Thawj zaug pib lub tsev qiv ntawv:

  • Hlau tsev qiv ntawv
  • ESP8266WiFi
  • WiFiClientSecure

Kauj Ruam 3: I2C Module Execution Process in Arduino IDE

Tom qab pib ua cov tsev qiv ntawv, peb yuav txiav txim siab txheej txheem I2C kom siv los nqa lub ntsuas nyeem ntawv hloov pauv lawv thiab hloov pauv 8 cov ntaub ntawv raws li qhov xav tau:

Pib sau npe hauv ob txoj kab hlau I2C raws tu qauv rau I2C sensor module

#define Ntxiv 0x40

  • Pib I2C kis thiab pib sau npe thiab thov rau 2 bytes cov ntaub ntawv los ntawm qhov uas peb yuav nyeem cov ntaub ntawv ntsuas.
  • Yog tias 2 bytes cov ntaub ntawv yuav muaj tom qab ntawd nyeem cov ntaub ntawv ntsuas thiab siv hais hauv qab no cov qauv peb tab tom hloov pauv qhov txiaj ntsig xav tau

float humidity = (((data [0] * 256.0 + data [1]) * 125.0) / 65536.0) - 6;

ntab cTemp = (((data [0] * 256.0 + data [1]) * 175.72) / 65536.0) - 46.85;

ntab fTemp = (cTemp * 1.8) + 32;

Luam qhov tseem ceeb hauv lub vijtsam saib ua ntej

Kauj Ruam 4: ESP8266 Kev Txuas Nrog WiFi thiab Google Daim Ntawv Qhia

Tom qab ua tiav I2C cov qauv peb yuav kawm paub yuav ua li cas nqa cov ntaub ntawv thiab los ntawm kev siv WiFi cov tsev qiv ntawv thiab tus tswv tsev tus lej nrog rau cov lej API kom xa cov ntaub ntawv mus rau Google nplooj ntawv.

  • Txhais WiFi cov ntaub ntawv pov thawj thoob ntiaj teb hauv ESP8266 uas yuav pab peb txuas lub rooj tsavxwm nrog internet
  • Raws li peb tab tom siv HTTP tus thov thiab yuav txhais HTTPS = 443 raws tu qauv kom ruaj ntseg txoj hauv kev HTTP raws li tsab ntawv yuav ua haujlwm nyob hauv txoj kev nyab xeeb nkaus xwb.
  • Pib lub tswv yim cov ntsiab lus hauv cov cai

const char* host = "script.google.com";

ua int httpsPort = 443;

Txoj hlua SCRIPT_ID = "hais qhia tus lej ID raws li tau hais hauv snaps";

Nco tseg: Tsab ntawv ID tau hais hauv "web apps URL" thaum Gscript code yuav tshaj tawm, tsuas yog luam thiab muab tus lej hais hauv qab no thiab pib ua ntej hauv cov lus txib saum toj no

  • Tsis tas li siv qhov hloov pauv nrog qhov sib txawv, peb tab tom yuav pib ua qhov sib txawv thoob ntiaj teb uas nqa cov ntaub ntawv los ntawm I2C module thiab xa nws mus rau kab ntawv URL uas yuav txuas ntxiv xa cov ntaub ntawv mus rau qhov chaw.
  • Siv ESP8266 WiFi Lub Tsev Qiv Ntawv peb yuav tuaj yeem txuas lub rooj tsavxwm nrog internet
  • Cov ntaub ntawv ntsuas yuav tau tuav rau lub server hauv ib cheeb tsam tom qab txhua 5 vib nas this.

  • Nrog kev pab los ntawm tsab ntawv URL, cov ntaub ntawv yuav raug tuav rau google tsab ntawv tshaj tawm txuas txuas Nplooj ntawv nquag tom qab txhua 15 vib nas this.

Kauj Ruam 5: Siv Google Daim Ntawv Siv GScript Editor

Automate Google Sheet Siv GScript Editor
Automate Google Sheet Siv GScript Editor
Automate Google Sheet Siv GScript Editor
Automate Google Sheet Siv GScript Editor
Automate Google Sheet Siv GScript Editor
Automate Google Sheet Siv GScript Editor

Raws li peb txhua tus muaj tus lej google txhawm rau nkag mus rau hauv google daim ntawv nrog koj tus lej nyiaj

  • Hais txog qhov tseem ceeb uas koj xav tau los ntawm lub ntsuas hluav taws xob txuas nrog ESP8266
  • Mus rau Cov Cuab Yeej> Script Editor
  • Siv "Doget" ua haujlwm kom tau txais cov xwm txheej
  • Hauv "Doget" ua haujlwm rau pib daim ntawv nthuav qhia API tus lej zoo li txuas rau Daim Ntawv Cuam Tshuam uas koj xav xa qhov ntsuas qhov ntsuas.
  • Nrog kev pab ntawm kev siv lub tshuab ua haujlwm kom hais hauv cov cai los sawv cev rau cov ntaub ntawv hauv kab thiab kab ntawv yooj yim.
  • Thaum kawg, khaws cov ntaub ntawv thiab nyem rau "Publish" >> Nyem "Deploy as web apps"
  • Nco ntsoov tias thaum twg los xij yuav muaj kev hloov pauv los xaiv "qhov project version" >> "New" >> nias "update"

Tam sim no lub web app URL yuav tshwm raws li hauv qab no:

script.google.com/macros/s/ "GSGS ID "/exec:

siv ntxiv hauv ESP8266 txoj cai rau nqa cov ntaub ntawv los ntawm cov ntsuas

Peb tab tom yuav siv HTTPS Tau thov kom txuas cov ntaub ntawv mus rau tus tswv tsev tus lej tau hais hauv gscript tus kws kho qhov chaw uas peb sau peb cov ntaub ntawv txuas ntxiv txuas nrog google daim ntawv.

muaj nuj nqi doGet (e) {Logger.log (JSON.stringify (e)); // saib qhov tsis sib xws tshwm sim = 'Ok'; // xav tias ua tiav yog (e.parameter == 'undefined') {tshwm = 'Tsis muaj Parameters'; } lwm {var sheet_id = ''; // Spreadsheet ID var sheet = SpreadsheetApp.openById (sheet_id).getActiveSheet (); var newRow = sheet.getLastRow () + 1; var rowData = ; } Logger.log (JSON.stringify (rowData)); // Sau kab tshiab hauv qab no var newRange = sheet.getRange (newRow, 1, 1, rowData.length); newRange.setValues ([rowData]); }

Kauj Ruam 6: Txwv:

Txwv
Txwv
  • Txoj haujlwm no tsuas yog txwv kom khaws cov ntaub ntawv ntawm I2C sensor hauv google nplooj ntawv
  • Peb tab tom siv HTTPS GET thov kom tau txais qhov txiaj ntsig los ntawm I2C cov haujlwm
  • Peb yuav tsum hloov pauv tus nqi hauv txoj hlua thiab tom qab ntawd xa cov ntaub ntawv mus rau gscript URL txuas.

Kauj Ruam 7: Txoj Cai, Khab nias, Siv

Github Code:

github.com/varul29/SHT25_GoogleSheets_Goog…

Siv

I2C Code:

Google Script Tutorial:

Embedded Store:

Tutorial Blog:

Pom zoo: