0Pricing
Arduino & IoT Academy · درس

الحصول على الوقت الحقيقي باستخدام NTP/RTC

أضف إلى البيانات تواريخ وأوقات دقيقة.

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

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

Why Time Matters

A reading like "24.3 C" is half a story. To make sense of logged data, every sample needs a timestamp telling you exactly when it happened. ⏰

Arduino Has No Clock

Your Arduino forgets the date the moment power drops. It only counts milliseconds since boot, so it has no idea what real-world wall-clock time it is.

Two Ways to Get Time

You can fetch the time from the internet with NTP, or keep it locally with a battery-backed RTC chip. Each fits a different situation.

What NTP Does

NTP (Network Time Protocol) asks a time server online for the current moment. It is accurate and free, but it needs an active WiFi connection to work.

Asking an NTP Server

On an ESP32 one line of setup points your board at a public time server and your timezone offset. Then the board syncs automatically.

configTime(0, 0, "pool.ntp.org");

Reading the Synced Time

Once synced, you pull the current time into a struct and read its fields. This gives you year, month, day, hour, and minute to label data.

struct tm now;
getLocalTime(&now);

What an RTC Does

An RTC module like the DS3231 keeps ticking on a tiny coin battery, even with the Arduino fully off. No network needed at all.

Wiring an RTC

Most RTC modules talk over I2C, so you connect just four wires: power, ground, SDA, and SCL. That keeps your build wonderfully simple.

Reading from an RTC

With the RTClib library you grab the current moment as a DateTime object, then read its fields just like the NTP version.

DateTime now = rtc.now();
int h = now.hour();

NTP or RTC?

Pick NTP when your device is always online and you want zero extra parts. Pick an RTC for offline or battery nodes that still need the right time.

Best of Both

Many strong designs use both: an RTC keeps time offline, and NTP gently corrects its small drift whenever WiFi is available. 🌐

Quick Check

Which time source still works with no internet connection?

Recap

Arduino has no real clock, so add time with NTP online or an RTC offline. Now every reading you log can carry an accurate timestamp. ✅

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

هل درس «الحصول على الوقت الحقيقي باستخدام NTP/RTC» مجاني؟

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

ماذا ستتعلم في «الحصول على الوقت الحقيقي باستخدام NTP/RTC»؟

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

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

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

كم من الوقت يستغرق درس «الحصول على الوقت الحقيقي باستخدام NTP/RTC»؟

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

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

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

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

  1. الحصول على الوقت الحقيقي باستخدام NTP/RTC
  2. كتابة CSV على بطاقة SD
  3. تخزين الرفعات وتجميعها
  4. تصوير البيانات المسجّلة
← العودة إلى Arduino & IoT Academy