2025 Muallif: John Day | [email protected]. Oxirgi o'zgartirilgan: 2025-01-13 06:58
Hozirgi vaqtda IoT trendda va ko'plab mashinalarda bulut orqali yuklash va ma'lumotlarni tahlil qilish uchun ma'lumotlar mavjud. Kichik datchiklar bulutdagi ma'lumotlarni yangilaydi va boshqa uchida harakatlantiruvchi vosita ishlaydi, men IoT misolidan birini tushuntirmoqchiman.
Men ushbu maqolada va ESP8266 yordamida Thingspeak -ga ma'lumotlarni joylashtirish uchun ko'rsatma beraman.
1 -qadam: kerakli komponent
ESP8266ESP8266 Hindistonda-
Buyuk Britaniyada ESP8266 -
AQShda ESP8266 -
MLX90614MLX90614 Hindistonda-
MLX90614 Buyuk Britaniyada -
AQShda MLX90614 -
Non taxtasi
Hindistondagi non taxtasi-
AQShdagi BreadBoard- https://amzn.to/2MW0Opb Buyuk Britaniyadagi BreadBoard-
2 -qadam: kod
#qo'shish #qo'shish #qo'shish
ApiKey qatori "7CDCTE2767Z8AUIL"; // ThingSpeak -dan Write API kalitini kiriting
const char *ssid = "yashirin"; // wifi ssid va wpa2 kaliti bilan almashtiring
const char *pass = "qwerty12"; const char* server = "api.thingspeak.com";
WiFiClient mijozi;
Adafruit_MLX90614 mlx = Adafruit_MLX90614 ();
int objTemp;
int ambTemp;
bo'sh o'rnatish ()
{Serial.begin (115200); kechikish (10); Serial.println ("Ulanish"); Serial.println (ssid); WiFi.begin (ssid, pass); while (WiFi.status ()! = WL_CONNECTED) {kechiktirish (500); Serial.print ("."); } Serial.println (""); Serial.println ("Wi -Fi ulangan"); mlx.begin (); Wire.begin (D1, D2); } void loop () {
if (client.connect (server, 80)) // "184.106.153.149" yoki api.thingspeak.com
{objTemp = mlx.readObjectTempC (); ambTemp = mlx.readObjectTempC (); String postStr = apiKey; postStr += "& maydon1 ="; postStr += String (objTemp); postStr += "\ r / n / r / n";
client.print ("POST /yangilash HTTP /1.1 / n");
client.print ("Xost: api.thingspeak.com / n"); client.print ("Ulanish: yopish / n"); client.print ("X-THINGSPEAKAPIKEY:"+apiKey+"\ n"); client.print ("Content-Type: application/x-www-form-urlencoded / n"); client.print ("Content-Length:"); client.print (postStr.length ()); client.print ("\ n / n"); client.print (postStr);
Serial.print ("Atrof muhit ="); Serial.print (ambTemp);
Serial.print ("*C / tObject ="); Serial.print (objTemp); Serial.println ("*C");
}
client.stop (); kechikish (2000); }