Mundarija:

Yaqinlik o'lchami: 5 qadam
Yaqinlik o'lchami: 5 qadam

Video: Yaqinlik o'lchami: 5 qadam

Video: Yaqinlik o'lchami: 5 qadam
Video: 🤔 Erim har kuni 2-3 marta qo'shilaylik, birga bo'laylik, yaqinlik qilaylik deydi. | Fayoz Aminov 2024, Dekabr
Anonim
Yaqinlik o'lchami
Yaqinlik o'lchami

Ushbu qo'llanmada men qurilmaning yaqinligini o'lchash va qiymatlarni Thingsai, io bulutli platformasida zal sensori va esp32 ishlab chiqish paneli yordamida e'lon qilish haqida tushuntiraman.

Hall effekti sensori - bu magnit maydonining kattaligini o'lchash uchun mo'ljallangan qurilma. Uning chiqish kuchlanishi magnit maydon kuchiga to'g'ridan to'g'ri proportsionaldir. Zal effektli sensorlar yaqinlikni aniqlash, joylashishni aniqlash, tezlikni aniqlash va joriy sezish uchun ishlatiladi.

1 -qadam: QOMPONENTLAR

KOMPONENTLAR
KOMPONENTLAR
KOMPONENTLAR
KOMPONENTLAR
KOMPONENTLAR
KOMPONENTLAR

Uskuna komponentlari:

1. Zal sensori

2. esp32 ishlab chiqish taxtasi

3. Jumper simlari

Dastur komponentlari:

1. Arduino IDE

2. narsalar AI. AI

2 -qadam: Ulanishlar:

Ulanishlar
Ulanishlar

Zal sensori ---------------------- esp32

Yo'q ------------------------------ vp

Gnd ---------------------------- Gnd

Vcc ------------------------------ 3V3

3 -qadam: kodlash:

#qo'shing

#qo'shing

#qo'shing

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

int o'lchami;

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"; // YoKI

/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);

// Biz boshlaymiz

WiFi tarmog'iga ulanish

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

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);

}

bo'sh halqa ()

{

int analogValue =

analogRead (chiqish pin);

{

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

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

int o'lchov

= 0;

o'lchov =

hallRead ();Serial.print ("Zal sensori o'lchami:");Serial.println (o'lchov);

kechikish (1000);Serial.print ("ulanish");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 funktsiyani chaqiradi

bu serverdan vaqt tamg'asi javobini oladi

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

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

String PostValue =

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

PostValue =

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

PostValue =

PostValue +", \" ma'lumotlar / ": {" yaqinlik / ":" +o'lchov +"}" +"}";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

/qurilmalar/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:

Tashuvchi eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9. IjVhMzBkZDFkN2QwYjNhNGQzODkwYzQ4OSI.kaY6OMj5cYlWNqC2PNTkXs9fKy6_m9)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 ( Javob kutilmoqda

);

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);

}

/ * agar server uzilgan bo'lsa, mijozni to'xtating */

agar

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

}

}

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

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

kechikish (3000);

}}

4 -qadam: Natija:

Natija
Natija

Sensordan o'qiladigan qiymatlar IOT bulutiga muvaffaqiyatli yuborilmoqda va grafik vaqtga yaqinlik sifatida yaratilmoqda. Bu bilan sensorning ishi tahlil qilinadi va kerakli dastur sohalariga muvofiq ishlatiladi.

5 -qadam: To'liq darslik:

Bu esp32 zali sensori va thingsai.io bulutli platformasi yordamida qurilmaning yaqinligini o'lchashning to'liq loyihasi. rahmat

Tavsiya: