Mundarija:
2025 Muallif: John Day | [email protected]. Oxirgi o'zgartirilgan: 2025-01-13 06:58
Komponentlar talab qilinadi-
1. Arduino NANO:
2. DHT11 sensori:
3. OLED displeyi:
4. Non paneli:
5. Jumper simlari:
Xarid qilish havolalari faqat Hindiston uchun.
1 -qadam: O'chirish diagrammasi
Barcha kerakli komponentlar yig'ilgandan so'ng. Yaxshi tushunish uchun ushbu sxemani yuklab oling.
2 -qadam: Ulanishni boshlang
Elektr sxemasini oldingizga qo'ying va simlarni ulashni boshlang.
3 -qadam: Arduino IDE sozlamalarini sozlang
Endi, ulanish tugagandan so'ng, ochiq arduino IDE -ni tanlang va karta turini va COM -ni tanlang. Shuningdek, kutubxonalarni yuklab oling va kiriting.
4 -qadam: Kodni yuklash
Endi kodni tuzing va yuklang.
KOD:
#clude "DHT.h" #include "U8glib.h" U8GLIB_SSD1306_128X64 u8g (U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0);
#DHTPIN 2 ni aniqlang
#DHTTYPE DHT11 ni aniqlang
DHT dht (DHTPIN, DHTTYPE, 6); char str [10];
void drawTest (bekor) {
u8g.setFont (u8g_font_unifont);
u8g.drawStr (0, 30, "Harorat &");
u8g.drawStr (0, 50, "Namlik o'lchagichi");
u8g.setFont (u8g_font_helvB08); //
u8g.drawStr (7, 60, "PR ROBOTICS");
}
bo'sh o'rnatish () {
dht.begin ();
u8g.firstPage ();
qil {
drawTest ();
}
while (u8g.nextPage ());
kechikish (3000); }
void loop () {
kechikish (500);
float h = dht.readHumidity ();
float t = dht.readTemperature ();
agar (isnan (h) || isnan (t))
{
qaytish;
}
u8g.firstPage ();
qil {
u8g.setFont (u8g_font_helvB08);
u8g.drawStr (0, 15, "Namlik:");
u8g.drawStr (80, 15, dtostrf (h, 5, 2, str));
u8g.drawStr (120, 15, "%");
u8g.drawStr (0, 30, "Harorat:");
u8g.drawStr (80, 30, dtostrf (t, 5, 2, str)); u8g.drawStr (120, 30, "\ 260C");
u8g.drawStr (10, 60, "BY: PR ROBOTICS");
}
while (u8g.nextPage ()); }
5 -qadam: Sinov
Endi loyihangizni sinab ko'ring.