Distance Sensors

  • Infrared example.

  • Another IR example using the KY-032 sensor.

  • Accustic Sensor HC-SR04 example using ultrasound giving a range from 2cm to 4m with an accuracy up to 3mm. Since the HC-SR04 runs on 5V and the Raspberry Pi gpio pins use 3.3V resistors are needed: image of wiring After setting up the wiring a simple python script will do the job with rather high precision with an error in the few millimeter range for 10, 20 and 30cm.