كيف يعمل؟
يرسل نبضة فوق صوتية ثم يقيس زمن عودة الصدى؛ يستخدم المتحكم زمن الرحلة لتقدير المسافة إلى الجسم.
It sends an ultrasonic pulse and measures the return-echo time; the controller uses the travel time to estimate distance.
HC-SR04
حساس مسافة بالموجات فوق الصوتية يستخدم عادة في الروبوتات وقياس المسافات القصيرة.
An ultrasonic distance sensor commonly used in robots and short-range distance-measurement projects.
خرج Echo قد يكون 5V؛ مع ESP32 يلزم خفض مستوى الإشارة قبل GPIO.
يرسل نبضة فوق صوتية ثم يقيس زمن عودة الصدى؛ يستخدم المتحكم زمن الرحلة لتقدير المسافة إلى الجسم.
It sends an ultrasonic pulse and measures the return-echo time; the controller uses the travel time to estimate distance.
صِل VCC وGND، ثم Trigger إلى خرج رقمي وEcho إلى دخل رقمي. مع ESP32 خفّض مستوى Echo من 5V إلى مستوى مناسب لـ3.3V.
Connect VCC and GND, Trigger to a digital output, and Echo to a digital input. With ESP32, reduce the 5V Echo level to a safe 3.3V-compatible level.
ضع جسمًا مسطحًا على مسافة معروفة، اقرأ عدة قياسات وقارن المتوسط بالمسافة الفعلية. تحقق من مستوى Echo قبل توصيله بمدخل 3.3V.
Place a flat target at a known distance, take several readings, and compare the average with the actual distance. Verify the Echo voltage level before connecting it to a 3.3V input.
قراءات صفرية أو متذبذبة بسبب الهدف أو التوصيل؛ إدخال Echo بجهد 5V مباشرة إلى ESP32 دون خفض مستوى.
Zero or unstable readings caused by target geometry or wiring; feeding a 5V Echo signal directly into an ESP32 input without level reduction.
مشروع مصغر: مؤشر اقتراب يعرض ثلاث حالات للمسافة قبل استخدام الحساس لاحقًا في روبوت تجنب العوائق.
Mini project: build a proximity indicator with three distance states before using the sensor in an obstacle-avoiding robot.