0Pricing
Arduino & IoT Academy · درس

قراءة درجة الحرارة والرطوبة

استدعِ المكتبة للحصول على قيم مناخية فعلية.

قراءة درجة الحرارة والرطوبة درس مجاني في Arduino & IoT Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Arduino & IoT Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Time to Read

Your sensor is wired and the library is ready. Now you will ask it for real numbers and print them to the Serial Monitor. 🌡️

Read Temperature

Call readTemperature() to get the current value in Celsius. Store it in a float because the reading often has decimals.

float t = dht.readTemperature();

Read Humidity

Call readHumidity() to get the moisture in the air as a percentage. Like temperature, save it in a float variable.

float h = dht.readHumidity();

Want Fahrenheit?

Pass true to readTemperature to get Fahrenheit instead of Celsius. One small argument switches the whole unit.

float f = dht.readTemperature(true);

Print the Values

Send your readings to the Serial Monitor so you can watch them live. Labels next to numbers make the output easy to read.

Serial.print("Temp: ");
Serial.println(t);

Show Both at Once

You can print temperature and humidity together on one line. A short label before each value keeps the data clear.

Serial.print(h);
Serial.println("% humidity");

DHT Is Slow

A DHT updates only about once per second. Reading faster than that just returns stale or failed values, so be patient.

Pace Your Loop

Add a short delay() at the end of loop so you read at a sensible pace. Two seconds is a safe, comfortable gap.

delay(2000);

Compute Heat Index

The library can also estimate the heat index, how hot it feels, from temperature and humidity together. It is one handy call.

float hi = dht.computeHeatIndex(t, h, false);

Use the Readings

Once you have the numbers, you can act on them: turn on a fan above a threshold or log values for later analysis.

Read Once, Reuse

Save each reading into a variable once per loop, then reuse it. Calling the sensor many times in a row only slows you down.

Quick Check

You want the temperature in Fahrenheit. Which call returns it?

Recap

You read temperature and humidity into floats, printed them with labels, paced the loop, and even computed how hot it feels. 🎉

الأسئلة الشائعة

هل درس «قراءة درجة الحرارة والرطوبة» مجاني؟

نعم — نص درس «قراءة درجة الحرارة والرطوبة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Arduino & IoT Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.

ماذا ستتعلم في «قراءة درجة الحرارة والرطوبة»؟

استدعِ المكتبة للحصول على قيم مناخية فعلية. تتمرن على Arduino & IoT Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Arduino & IoT Academy؟

لا تُشترط خبرة سابقة. Arduino & IoT Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «قراءة درجة الحرارة والرطوبة»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Arduino & IoT Academy هذا؟

نعم. كل درس في Arduino & IoT Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. توصيل DHT11/DHT22
  2. تثبيت مكتبة DHT
  3. قراءة درجة الحرارة والرطوبة
  4. معالجة القراءات الفاشلة
← العودة إلى Arduino & IoT Academy