I having an issue with the HC-SR504 ultrasonic sensor that accompanied the CamJam Robotics kit. Perhaps someone may have had a similar issue and resolved it.
The sensor emits a pulse but no echo is detected ever (verified using pigpio and piscope) - stuck in the first while loop per Pimoroni sample code. I substituted the sensor with two others in my collection and but these changes made no difference. I have used several flavors of code (posted in the public domain and most of these have the “uninitialized variables” bug sadly) but the results remained unchanged.
I am using 330 and 470 ohms resistors (and also other variations) with RPi3B+ (under current Raspbian Stretch). The same setup works fine with Arduino UNO (using the pulseIn method for the elapsed time). The assignment of the echo/trigger pins were rotated based on the available pins on the CamJam HAT. The pins were verified to be in working order (via HAT) by blinking LEDs. I even rearranged the initialization of the timer variables such that the emission of the pulse was followed immediately by the two while loops to eliminate latency (at the expense of some accuracy, of course). None of these adjustments made any difference.
The code is very simple and I wonder if Stretch has something against me. I gave up on using DHT11 temperature/humidity sensor with Python for a related timing issue. This family of sensors, DHTxx, worked thankfully to WiringPi after reading Gordon Henderson’s comments at his site. Has anyone else experienced any issue (apart from the “uninitialized variables” bug) with the HC-SR504 ultrasonic sensor using Python?