Orodha ya maudhui:

Kicheza Mwendo Kutumia Thingsai.io Iot Cloud Platform: 6 Hatua
Kicheza Mwendo Kutumia Thingsai.io Iot Cloud Platform: 6 Hatua

Video: Kicheza Mwendo Kutumia Thingsai.io Iot Cloud Platform: 6 Hatua

Video: Kicheza Mwendo Kutumia Thingsai.io Iot Cloud Platform: 6 Hatua
Video: The Doctrine of Repentance | Thomas Watson | Christian Audiobook 2024, Novemba
Anonim
Kicheza Mwendo Kutumia Thingsai.io Iot Cloud Platform
Kicheza Mwendo Kutumia Thingsai.io Iot Cloud Platform

Katika mafunzo haya nitaelezea juu ya kugundua mwendo kwa kutumia sensor ya PIR na Esp32 pamoja na jukwaa la wingu la IOT Thingai.io

Hatua ya 1: Vipengele

Vipengele
Vipengele
Vipengele
Vipengele

VITENGO VYA HARDWARE;

1. Bodi ya Maendeleo ya 32

Sensorer ya PIR

3. waya za jumper

SOFTWARE:

1. Arduino IDE

2. Akaunti ya Thingsai.io

Hatua ya 2: Uunganisho

Viunganisho
Viunganisho

Uunganisho ni utulivu rahisi.

PIN ZA PIR ------------ ESP32 PINS

VCC ------------------- 3V3 kwenye esp32

GND ------------------ GND kwenye esp32

OUT ------------------- D22 kwenye esp32

Hatua ya 3: CODING

Bandika nambari hii kwenye IDE yako ya Arduino na sasisho fulani, sensa ya Mwendo wako itatoa pato bila kasoro.

# pamoja

# pamoja

# pamoja

hesabu = 0, i, m, j, k;

int t, t1, t2, t3;

pini = 22;

/////////////////////////////////////////// MATANGAZO YOTE YA WINGA /////// //////////////////////////

const char * mwenyeji = "api.thingsai.io"; // AU mwenyeji = devapi2.thethingscloud.com

const char * post_url = "/ vifaa / DataData ya kifaa"; // AU / api / v2 / thingscloud2 / _table / data_ac

const char * time_server = "baas.thethingscloud.com"; // hii ni kubadilisha muhuri wa muda

const int httpPort = 80;

const int httpsPort = 443;

const char * server = "api.thingsai.io"; // URL ya seva

ch timestamp [10];

WiFiMulti WiFiMulti;

// Tumia darasa la Wateja wa WiFi kuunda unganisho la TCP

Mteja wa Wateja wa WiFi;

///////////////////////////////////////// TIMESTAMP HESABU kazi ////////// ///////////////////////////////////

int GiveMeTimestamp ()

{

muda mrefu uliotiwa saini = milisiti ();

// Mteja wa Wateja wa WiFi;

wakati (mteja anapatikana () == 0)

{

ikiwa (millis () - muda wa kumaliza> 50000)

{

mteja.acha ();

kurudi 0;

}

}

wakati (mteja anapatikana ())

{

Mstari wa kamba = mteja.readStringUntil ('\ r'); // indexOf () ni funtion ya kutafuta smthng, inarudi -1 ikiwa haipatikani

int pos = line.indexOf ("\" timestamp / ""); // tafuta "\" timestamp / "" kutoka mwanzo wa jibu lilipata na kunakili data zote baada ya hapo, itakuwa alama yako ya muda

ikiwa (pos> = 0)

{

int j = 0;

kwa (j = 0; j <10; j ++)

{

timestamp [j] = mstari [pos + 12 + j];

}

}

}

}

////////////////////////////////////////////////////////////////////////////////////////////////////////

kuanzisha batili ()

{

Serial. Kuanza (115200);

kuchelewesha (10);

pinMode (pini, INPUT);

// Tunaanza kwa kuungana na mtandao wa WiFi

WiFiMulti.addAP ("wifi_name", "Wifi_password");

Serial.println ();

Serial.println ();

Serial.print ("Subiri kwa WiFi…");

wakati (WiFiMulti.run ()! = WL_CONNECTED) {

Printa ya serial (".");

kuchelewesha (500);

}

Serial.println ("");

Serial.println ("WiFi imeunganishwa");

Serial.println ("Anwani ya IP:");

Serial.println (WiFi.localIP ());

kuchelewesha (500);

}

kitanzi batili ()

{

int analogValue = AnalogRead (pato la pini);

{

/ / /////////////////////

{

bool isDetected = digitalRead (pini);

ikiwa (Imetambuliwa) {

Serial.println ("Uwepo umegunduliwa");

}

kuchelewesha (500);

}

Serial.print ("kuunganisha kwa");

Serial.println (mwenyeji); // imefafanuliwa kichwa: - mwenyeji = devapi2.thethingscloud.com au 139.59.26.117

/////////////////////////////////////// TIMESTAMP CODE SNIPPET //////////// ////////////////

Serial.println ("ndani pata muhuri wa muda / n");

ikiwa (! mteja.connect (time_server, {

kurudi; // * - * - * - * - * - * - * - * - * - *

}

mteja.println ("GET / api / timestamp HTTP / 1.1"); // Je! Sehemu hii inafanya nini, sikupata

mteja.println ("Jeshi: baas.thethingscloud.com");

mteja.println ("Cache-Control: no-cache");

mteja.println ("Postman-Token: ea3c18c6-09ba-d049-ccf3-369a22a284b8");

mteja.println ();

NipeTimestamp (); // itaita kazi ambayo itapata majibu ya muhuri wa wakati kutoka kwa seva

Serial.println ("timestamp imepokea");

Serial.println (timestamp);

Serial.println ("ndani ya ThingsCloudPost");

Kamba PostValue = "{" device_id / ": 61121695839, \" slave_id / ": 2";

PostValue = PostValue + ", \" dts / ":" + muhuri wa muda;

PostValue = PostValue + ", \" data / ": {" PIR / ":" + pin + "}" "" "" ";

Serial.println (PostValue);

/ * tengeneza mfano wa WiFiClientSecure * /

Mteja wa WiFiClientSecure;

Serial.println ("Unganisha kwenye seva kupitia bandari 443");

ikiwa (! mteja.connect (seva, 443)) {

Serial.println ("Uunganisho umeshindwa!");

} mwingine {

Serial.println ("Imeunganishwa na seva!");

/ * tengeneza ombi la HTTP * /

mteja.println ("POST / vifaa / kifaaData HTTP / 1.1");

mteja.println ("Jeshi: api.thingsai.io");

//client.println ("Uunganisho: funga");

mteja.println ("Aina ya Maudhui: programu / json");

mteja.println ("cache-control: no-cache");

mteja.

alama ya mteja ("Urefu wa Yaliyomo:");

mteja.println (PostValue.length ());

mteja.println ();

mteja.println (PostValue);

//////////////////////////////////// KUWEKA data kwenye wingu kumalizika na sasa pata wingu la fomu ya majibu seva ///////////////////

Serial.print ("Kusubiri majibu");

wakati (! mteja anapatikana ()) {

kuchelewesha (50); //

Printa ya serial (".");

}

/ * ikiwa data inapatikana basi pokea na uchapishe kwenye Kituo * /

wakati (mteja anapatikana ()) {

char c = mteja.soma ();

Serial.write (c);

}

/ * ikiwa seva imetengwa, simamisha mteja * /

ikiwa (! mteja. imeunganishwa ()) {

Serial.println ();

Serial.println ("Seva imekatika"); javascript:;

mteja.acha ();

}

}

Serial.println ("//////////////////////// MWISHO //////////////////////////// ");

kuchelewesha (3000);

}

}

Hatua ya 4: PATO

PATO
PATO

Huu ndio uwakilishi wa grafu ya bar ya maadili yaliyosomwa kutoka kwa sensa katika kitusai, jukwaa la wingu la io,

Hatua ya 5: Grafu

Grafu
Grafu

Huu ndio uwakilishi wa picha ya maadili kutoka kwa sensa. Kutoka kwa grafu hapo juu tunaweza kuchambua matumizi ya sensorer. Asante

Ilipendekeza: