Motozero and HC-SR04 Ultrasonic sensor

I build a remote controlled robot with a Raspberry Pi zero and a MotoZero in Node-red. Now I would like to automize the robot with some ultrasonic eyes (HC-SR04 sensor), but the pins are used by the MotoZero. has somebody an idea how to solve this?

Does somebody already have a code (node-red) for the HC-sro4 so the robot does not hit the wall and goes left or right?

Because the MotoZero covers all of the pins, it would be very awkward to add anything else to your PiZero

I've not seen anything recently that would economically/compactly sort that out for you

If you can get around the physical problem, this node should work to use it to measure distances

Note, unless you purchase the newer 3.3V version of the sensor, you'll need to add some resistors before plugging it into your Pi as most of them are 5V devices

This might give you an idea.
Here's a link to a write-up I did on HC-SR05 devices for my IoT students.

http://resources-area.co.uk/node-red-flows/ultrasonic_distance_sensor.pdf

You mentioned you are using a RPi-Z-W.
By adding a Wemos D1 Mini (ESP8266-based microcontroller) and flashing it with ESP-Easy you get all the routines to control an HC-SR04/05 and MQTT.
This means the Wemos could send distance readings via MQTT to Node-RED running in the Pi.

Note:
As Simon pointed out be careful about the logic levels between the ultrasonic device and the Pi.
The very last page on the above document gives details on how to overcome this issue.

2 Likes

This might be a bit (hahaha) of work, but you could remove the header and put on a stacking header in it's place. Or you could build your own pcb board and use a staching header on it. Plug your new board onto the Pi and plug the MOTOzero into yor new board's headers.

This way you could wire up your sensor on the new pcb.