Mundarija:
- 1 -qadam: komponentlar
- 2 -qadam: Ulanishlar
- 3 -qadam: KODLASH
- 4 -qadam: Chiqish
- 5 -qadam: Grafik
- 6 -qadam: Mana, Breifni tushuntirish videosi
Video: Thingsai.io Iot bulutli platformasi yordamida harakat detektori: 6 qadam
2024 Muallif: John Day | [email protected]. Oxirgi o'zgartirilgan: 2024-01-30 13:25
Ushbu qo'llanmada men PIR sensori va Esp32 yordamida Thingai.io IOT bulutli platformasi yordamida harakatni aniqlash haqida tushuntiraman.
1 -qadam: komponentlar
QO'ShIMChA KOMPONENTLARI;
1.esp32 Rivojlanish kengashi
2. PIR sensori
3. Jumper simlari
Dasturiy ta'minot:
1. Arduino IDE
2. Thingsai.io hisobi
2 -qadam: Ulanishlar
Ulanishlar oddiy.
PIR PIN-kodlari ------------ ESP32 PIN-kodlari
Esp32 da VCC ------------------- 3V3
Gp3 ------------------ GND esp32 da
OUT ------------------- D22 esp32 da
3 -qadam: KODLASH
Ushbu kodni Arduino IDE -ga bir oz yangilang va joylashtiring, shunda Motion sensori chiqishni muammosiz beradi.
#qo'shing
#qo'shing
#qo'shing
int soni = 0, i, m, j, k;
int t, t1, t2, t3;
int pin = 22;
//////////////////////////////////////// CLOUD uchun barcha deklaratsiyalar /////// //////////////////////////
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 HISOBIY HISOBI ///////// ////////////////////////////////
int GiveMeTimestamp ()
{
imzosiz uzoq vaqt tugashi = millis ();
// WiFiClient mijozi;
while (client.available () == 0)
{
if (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);
pinMod (pin, INPUT);
// Biz Wi -Fi tarmog'iga ulanishdan boshlaymiz
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);
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// qism qismlarga javob bering. /////////////////////
{
bool isDetected = digitalRead (pin);
agar (aniqlansa) {
Serial.println ("Mavjudlik aniqlandi");
}
kechikish (500);
}
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");
if (! client.connect (time_server, {
qaytish; //*-*-*-*-*-*-*-*-*-*-*
}
client.println ("GET/api/vaqt tamg'asi HTTP/1.1"); // Bu qism nima qilyapti, men tushunmadim
client.println ("Xost: baas.thethingscloud.com");
client.println ("Keshni boshqarish: keshsiz");
client.println ("Postman-Token: ea3c18c6-09ba-d049-ccf3-369a22a284b8");
mijoz.println ();
GiveMeTimestamp (); // u serverdan vaqt tamg'asi javobini oladigan funktsiyani chaqiradi
Serial.println ("vaqt tamg'asi qabul qilindi");
Serial.println (vaqt tamg'asi);
Serial.println ("ThingsCloudPost ichida");
String PostValue = "{" device_id / ": 61121695839, \" slave_id / ": 2";
PostValue = PostValue + ", \" dts / ":" + vaqt tamg'asi;
PostValue = PostValue +", \" ma'lumotlar / ": {" PIR / ":" +pin +"}" +"}";
Serial.println (PostValue);
/ * WiFiClientSecure misolini yaratish */
WiFiClientSecure mijozi;
Serial.println ("443 -port orqali serverga ulanish");
if (! client.connect (server, 443)) {
Serial.println ("Ulanish muvaffaqiyatsiz tugadi!");
} boshqa {
Serial.println ("Serverga ulandi!");
/ * HTTP so'rovini yaratish */
client.println ( POST/devices/deviceData
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);
/////////////////////////////////////////////// Bulutga ma'lumotlarni joylashtirish tugallandi va endi bulutdan javob shaklini oling. server ///////////////////
Serial.print ("Javob kutilmoqda");
while (! client.available ()) {
kechikish (50); //
Serial.print (".");
}
/ * agar ma'lumotlar mavjud bo'lsa, qabul qiling va Terminalda chop eting */
while (client.available ()) {
char c = client.read ();
Serial.write (c);
}
/ * agar server uzilgan bo'lsa, mijozni to'xtating */
if (! client.connected ()) {
Serial.println ();
Serial.println ("Server uzilgan"); javascript:;
client.stop ();
}
}
Serial.println ("/////////////////////// Oxiri //////////////////// ");
kechikish (3000);
}
}
4 -qadam: Chiqish
Bu sensordan o'qilgan qiymatlarning shtrixli grafikasi, bushay platformasida.
5 -qadam: Grafik
Bu sensordan olingan qiymatlarning grafik tasviri. Yuqoridagi grafikdan biz sensorning qo'llanilishini tahlil qilishimiz mumkin. Rahmat
Tavsiya:
Tank uchun DIY platformasi - Bluetooth nazorati + chiziqdagi harakat: 8 qadam
Tank uchun DIY platformasi - Bluetooth nazorati + chiziqdagi harakat: Arduino uchun DIY tank platformasi - Bluetooth nazorati (Android App Inventor 2 -dagi mobil ilova) + oflayn rejim - Robofest musobaqalari sxemalarida chiziq bo'ylab harakatlanish
Esp8266 (aREST, MQTT, IoT) yordamida Internet/bulutli uyni avtomatlashtirish: 7 qadam (rasmlar bilan)
Esp8266 (aREST, MQTT, IoT) yordamida Internet/bulut bilan boshqariladigan uy avtomatizatsiyasi: bulutli xizmat uchun http://arest.io/ saytidagi barcha kreditlar !! IoT hozirda dunyodagi eng ko'p muhokama qilinayotgan mavzu !! Bulutli serverlar va xizmatlar - bu hozirgi dunyoning diqqatga sazovor joyidir … DISTANCE BARRIER HUKUMI - bu shunday va shunday ham
DIY uy xavfsizligi - Qanday qilib oddiy harakat detektori qilish mumkin - Yangi versiya: 6 qadam
DIY uy xavfsizligi - Qanday qilib oddiy harakat detektori qilish mumkin | Yangi versiya: Men bu loyihada sizga qanday qilib arzon narxda DIY uy xavfsizligi to'g'risida signal berish signalini ko'rsataman! Eski versiyaga qarang: Uyda 10 dollarlik WiFi xavfsizlik tizimini qanday qilish kerak
NodeMCU yordamida harakat detektori: 5 qadam
NodeMCU yordamida harakat detektori: Ushbu loyihada, harakat sensori yordamida har qanday odam yoki hayvonning mavjudligini aniqlash mumkin. Va thingsio deb nomlangan platformada siz mavjudlik aniqlangan sana va vaqtni kuzatishingiz mumkin
Harakat boshqariladigan rozetka - Harakat sezuvchi nurdan: 6 qadam
Harakat boshqariladigan rozetka - Harakat sezuvchi nurdan: Tasavvur qiling, siz hiyla-nayrangchi bo'lib, blokning eng qo'rqinchli uyiga borasiz. Barcha arvohlar, arvohlar va qabristonlardan o'tib, siz oxirgi yo'lga borasiz. Siz oldingizda bir piyola ichida konfetni ko'rishingiz mumkin! Ammo keyin birdaniga gho