Mundarija:

Esp32 va Thingsio.ai platformasi yordamida haroratni o'lchash: 6 qadam
Esp32 va Thingsio.ai platformasi yordamida haroratni o'lchash: 6 qadam

Video: Esp32 va Thingsio.ai platformasi yordamida haroratni o'lchash: 6 qadam

Video: Esp32 va Thingsio.ai platformasi yordamida haroratni o'lchash: 6 qadam
Video: Why ESP32's Are The Best Microcontrollers (ESP32 + Arduino series) 2024, Noyabr
Anonim
Esp32 va Thingsio.ai platformasi yordamida haroratni o'lchash
Esp32 va Thingsio.ai platformasi yordamida haroratni o'lchash

Ushbu qo'llanmada men esp32 ishlab chiqarish kartasida mavjud bo'lgan ichki harorat sensori yordamida atrofdagi haroratni o'lchash haqida tushuntiraman. esp32 yaqinlik sensori, sensorli sensor, harorat sensori sifatida ishlatiladigan zal sensori kabi ko'plab ichki sensorlarga ega. Ushbu qo'llanmada biz harorat sensori haqida gaplashamiz.

1 -qadam: QOMPONENTLAR:

KOMPONENTLAR
KOMPONENTLAR

Uskuna:

1.esp32 ishlab chiqish paneli

Dasturiy ta'minot:

1. Arduino IDE

2. Thingsio.ai

2 -qadam: Esp32 -ni blokirovka qilish

BLOCK DIAGRAMI Esp32 ning vakili
BLOCK DIAGRAMI Esp32 ning vakili

3 -qadam: kodlash:

#qo'shing

#qo'shing

#qo'shing

#qo'shing

#qo'shing

#ifdef _cplusplus

tashqi "C" {

#endif

uint8_t temprature_sens_read ();

// uint8_t g_phyFuns;

#ifdef _cplusplus

}

#endif

int soni = 0, i, m, j, k;

int t, t1, t2, t3;

int chiqish pin = A0; // ds18b20

///////////////////////////////////////// BARCHA BELGILAR

CLOUD uchun ///////////////////////////////

const char* host = "api.thingsai.io"; // YoKI host =

devapi2.thethingscloud.com

const char* post_url = "/devices/deviceData"; //

OR/api/v2/thingscloud2/_table/data_ac

const char* time_server =

"baas.thethingscloud.com"; // bu vaqt tamg'asini aylantirish uchun

const int httpPort = 80;

const int httpsPort = 443;

const char* server =

"api.thingsai.io"; // Server manzili

char vaqt belgisi [10];

Wi -Fi ko'p tarmoqli WiFi;

// TCP ulanishlarini yaratish uchun WiFiClient sinfidan foydalaning

WiFiClient mijozi;

///////////////////////////////////////// TIMESTAMP

Hisoblash funktsiyasi //////////////////////////////////////////////////////////////////////////

int GiveMeTimestamp ()

{

imzosiz uzoq

vaqt tugashi = millis ();

// WiFiClient mijozi;

vaqt

(client.available () == 0)

{

agar (millis () -

tanaffus> 50000)

{

client.stop ();

qaytarish 0;

}

}

while (client.available ())

{

String qatori =

client.readStringUntil ('\ r'); // indexOf () -smthngni qidirish funktsiyasi, topilmasa -1 qaytaradi

int pos =

line.indexOf ("\" vaqt tamg'asi / ""); // javob boshidan "\" vaqt tamg'asi / "" ni qidiring va shundan so'ng barcha ma'lumotlarni nusxa ko'chiring, bu sizning vaqt tamg'angiz bo'ladi

agar (pos> =

0)

{

int j = 0;uchun (j = 0; j <10; j ++)

{vaqt belgisi [j] = chiziq [pos + 12 + j];

}

}

}

}

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

bo'sh o'rnatish ()

{Serial.begin (115200);

kechikish (10);

tzset ();

// Biz boshlaymiz

WiFi tarmog'iga ulanishWiFiMulti.addAP ("dlink_DWR-113", "madhukar66");

Serial.println ();

Serial.println ();Serial.print ("WiFi kuting …");esa (WiFiMulti.run ()! = WL_CONNECTED) {Serial.print (".");

kechikish (500);

}Serial.println ("");Serial.println ("Wi -Fi ulangan");Serial.println ("IP -manzil:");Serial.println (WiFi.localIP ());

kechikish (500);

}

uint8_t temp_farenheit;

float temp_celsius;

char strftime_buf [64];

vaqt_t hozir = 0;

tm timeinfo tuzilishi;

char buf [256];

bo'sh halqa ()

{

// int analogValue =

analogRead (chiqish pin);

{

///////////////////////////////////////////////////////////////////////////////////////////////////// sahifalar

Javobni qabul qiling ///////////////////////

//

t1 = (analogValue/1024.0) *5000;

//

Serial.print ("temp:");

// Serial.println (t1);

/

/ t2 = (t1/ 10);

//

Serial.print ("celc:");

//

Serial.println (t2);

/

/ t3 = ((t2 *)

9)/5 + 32);

//

Serial.print ("fhrn:");

//

Serial.println (t3); // tanaffus;localtime_r (& hozir, & timeinfo);strftime (strftime_buf, sizeof (strftime_buf), "%c", & timeinfo);sprintf (buf, "skanerlashni boshlash%02d:%02d:%02d", timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec);

Ketma -ket chop etish

(buf);

temp_farenheit =

temprature_sens_read ();

temp_celsius = (temp_farenheit - 32) / 1,8;Serial.print ("Temp onBoard");Serial.print (temp_farenheit);Serial.print ("° F");Serial.print (temp_celsius);Serial.println ("° C");

kechikish (1000);

hozir ++;

Serial.print ( ulanmoqda

ga );Serial.println (mezbon); // teskari aniqlangan:- host = devapi2.thethingscloud.com yoki 139.59.26.117

///////////////////////////////////////////////////// TIMESTAMP KODI SNIPPET

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

Serial.println ("ichida vaqt tamg'asini olish / n");

agar

(! client.connect (time_server, {

qaytish;

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

}client.println ("GET/api/vaqt tamg'asi HTTP/1.1"); // Bu qism nima qilyapti, men tushunmadimclient.println ("Xost: baas.thethingscloud.com");client.println ("Keshni boshqarish: keshsiz");client.println ("Postman-Token: ea3c18c6-09ba-d049-ccf3-369a22a284b8");

mijoz.println ();

GiveMeTimestamp (); // u chaqiradi

serverdan vaqt tamg'asi javobini oladigan funksiya

Serial.println ("vaqt tamg'asi qabul qilindi");

Serial.println (vaqt tamg'asi);Serial.println ("ThingsCloudPost ichida");

String PostValue =

"{" device_id / ": 61121695920, \" slave_id / ": 2";

PostValue =

PostValue + ", \" dts / ":" + vaqt tamg'asi;

PostValue =

PostValue +", \" ma'lumotlar / ": {" TEMP / ":" +temp_farenheit +"}" +"}";Serial.println (PostValue);

/ * WiFiClientSecure misolini yaratish */

WiFiClientSecure mijozi;Serial.println ("443 -port orqali serverga ulanish");

agar

(! client.connect (server, 443)) {Serial.println ("Ulanish muvaffaqiyatsiz tugadi!");

} boshqa {Serial.println ("Serverga ulandi!");

/* HTTP yaratish

so'rov */client.println ("POST/devices/deviceData HTTP/1.1");client.println ("Xost: api.thingsai.io");//client.println("Ulanish: yopish ");client.println ("Kontent turi: application/json");client.println ("keshni boshqarish: keshsiz");client.println ("Avtorizatsiya: egasi eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9. IjVhMzBkZDFkN2QwYjNhNGQzODkwYzQ4OSI.kaY6OMj5cYlWNqC2PNT")client.print ("Content-Length:");mijoz.println (PostValue.length ());mijoz.println ();client.println (PostValue);

//////////////////////////////////////////////////////////////////////////// qism qismlarga ma'lumotlarni joylashtirish

bulut tugadi va endi bulutli serverning javobini oling /////////////////

Serial.print ( Kutilmoqda

javob uchun );

vaqt

(! mijoz.available ()) {

kechikish (50);

//Serial.print (".");

}

/* agar ma'lumotlar bo'lsa

mavjud, keyin qabul qiling va Terminalda chop eting */

vaqt

(client.available ()) {

char c =

client.read ();Serial.write (c);

}

/* bo'lsa

server uzildi, mijozni to'xtating */

agar

(! client.connected ()) {Serial.println ();Serial.println ("Server uzilgan");

client.stop ();

}

}

Serial.println ( ////////////////////// END

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

kechikish (3000);

}

}

4 -qadam: Chiqish:

Chiqish
Chiqish

Bu erda sensordan o'qilgan harorat qiymatlarining chiqishi.

5 -qadam: Grafika:

Grafika
Grafika
Grafika
Grafika

Bort harorat sensori orqali o'qilgan qiymatlarning grafik tasviri.

Tavsiya: