Orodha ya maudhui:

Upimaji wa Maudhui ya Unyevu wa Udongo Kutumia Esp32 na Jukwaa la Thingsio.ai: Hatua 6
Upimaji wa Maudhui ya Unyevu wa Udongo Kutumia Esp32 na Jukwaa la Thingsio.ai: Hatua 6

Video: Upimaji wa Maudhui ya Unyevu wa Udongo Kutumia Esp32 na Jukwaa la Thingsio.ai: Hatua 6

Video: Upimaji wa Maudhui ya Unyevu wa Udongo Kutumia Esp32 na Jukwaa la Thingsio.ai: Hatua 6
Video: Zifahamu Aina za udongo na Mazao yanayo faa kulimwa katika kila aina 2024, Novemba
Anonim
Upimaji wa Maudhui ya Unyevu wa Udongo Kutumia Jukwaa la Esp32 na Thingsio.ai
Upimaji wa Maudhui ya Unyevu wa Udongo Kutumia Jukwaa la Esp32 na Thingsio.ai

Katika mafunzo haya nitaelezea juu ya usomaji wa unyevu kwenye mchanga kwa kutumia esp32 na kisha kutuma maadili kwenye jukwaa la wingu la thingsio.ai IoT.

Hatua ya 1: VIFAA

VIFAA
VIFAA
VIFAA
VIFAA

Vipengele vya vifaa:

1. esp32 bodi ya maendeleo

2. Sensorer ya mchanga

3. waya za Jumper

Programu:

1. Arduino IDE

2. Thingsio.ai

Hatua ya 2: Uunganisho

Viunganisho
Viunganisho

Sensorer ya Unyevu wa Udongo ---------------------- Bodi ya esp32

VCC ----------------------------------- 3V3

GND -------------------------------------- GND

A0 ---------------------------------------- VP

Hatua ya 3: CODING:

# pamoja

# pamoja

# pamoja

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

int t;

sensor_pin = A0;

thamani ya int;

/////////////////////////////////////////// MATANGAZO YOTE

kwa CLOUD //////////////////////////////////

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 * muda_server =

"baas.thethingscloud.com"; // hii ni kubadilisha muhuri wa muda

const int httpPort = 80;

const int httpsPort = 443;

const char * seva =

"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 ()

{

bila saini ndefu

muda wa kumaliza = millis ();

// 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);Serial.println ("Kusoma Kutoka kwa Sensor…");

kuchelewa (2000);

// Tunaanza na

kuunganisha kwenye mtandao wa WiFi

WiFiMulti.addAP ("Jina la Wifi", "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 ( IP

anwani: );Serial.println (WiFi.localIP ());

kuchelewesha (500);

}

kitanzi batili ()

{

{

////////////////////////////////////////// TUMA SWALI NA

POKEA MAJIBU //////////////////////////

thamani =

AnalogRead (sensor_pin);

// thamani =

ramani (thamani, 550, 0, 0, 100);Serial.print ("Mositure:");Serial.print (thamani);Serial.println ("%");kuchelewesha (1000);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");

kama

(! mteja.connect (time_server, {

kurudi;

//*-*-*-*-*-*-*-*-*-*

}mteja.println ("GET / api / timestamp HTTP / 1.1"); // Je! Sehemu hii inafanya nini, sikupatamteja.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");

Thamani PostValue =

"{" kifaa_id / ": 61121695918, \" mtumwa_id / ": 2";

Thamani ya Posta =

Thamani ya Posta + ", \" dts / ":" + muhuri wa muda;

Thamani ya Posta =

Thamani ya Posta + ", \" data / ": {" MOIST / ":" + thamani + "}" + "}";Serial.println (PostValue);

/ * tengeneza mfano wa WiFiClientSecure * /

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

kama

(! mteja.connect (seva, 443)) {Serial.println ("Uunganisho umeshindwa!");

} mwingine {Serial.println ("Imeunganishwa na seva!");

/ * tengeneza

ombi * /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 ( udhibiti wa cache:

hakuna-cache ");mteja.alama ya mteja ("Urefu wa Yaliyomo:");

mteja.println (PostValue.length ());mteja.println ();mteja.println (PostValue);

///////////////////////////////////// KUTUMIZA data kwa

wingu imefanywa na sasa pata fomu ya majibu seva ya wingu ////////////////////

Serial.print ( Inasubiri jibu

);

wakati

(! mteja anapatikana ()) {

kuchelewesha (50);

//Printa ya serial (".");

}

/ * ikiwa data ni

inapatikana kisha pokea na uchapishe kwa Terminal * /

wakati

(mteja anapatikana ()) {

char c = mteja.soma ();Serial.write (c);

}

/ * ikiwa

seva imekatika, simamisha mteja * /

kama

(! mteja.meunganishwa ()) {Serial.println ();Serial.println ("Seva imekatika");

mteja.acha ();

}

}

Serial.println ( //////////////////////// MWISHO

///////////////////// );

kuchelewesha (3000);

}

}

Hatua ya 4: PATO:

PATO
PATO

Pato la nambari linaonyeshwa.

Hatua ya 5: GRAPH

GRAPH
GRAPH

Huu ndio uwakilishi wa picha ambazo zinasomwa kutoka kwa sensa.

Hatua ya 6:

Hapa kuna video kamili ya mradi huo. Asante.

Ilipendekeza: