Zeroborg + ultrasonic sensor

Hello,

I would like to use the Zeroborg to power a few motors.
Can I also hang the ultrasonic sensor on the Zeroborg ?
And can I program It's distance so that a motor has to move or something like that ?

Thanks
Sam Devolder

piborg's picture

Unfortunately no, there are no digital output pins on the ZeroBorg which could be used to control an Ultrasonic sensor.

You could use an UltraBorg with a ZeroBorg to get the desired result.
The UltraBorg has an example script which sets servos from the distance readings, this could be easily adapted to control a DC motor on the ZeroBorg instead.

I'm not quite certain if I understand what you mean by your reply to the previous query! I am looking to connect an HC-SR04 to the ZeroBorg for either the obstacle avoidance and/or the straight line test.
I am plodging through my second "Tiny" inspired by the MagPi51 and MagPi52 articles. Bearing in mind that their "Tiny" morphs from 4 to 6 wheels and back again and through various unexplained layout changes, the task has been a confusing one!! On my first version I was not using a ZeroBorg and I connected the HC-SR04 via the GPIO. Everything was fine-ish. But in an effort to follow the MagPi articles more closely I thought to use the exact kit recommended. Things were OK until I tried to connect the HC-SR04 to the ZeroBorg. In one part of the MagPi52 article they describe connecting the module via the I2C expansion and give some sort of very iffy connection schedule. That done - nothing works!! I had no coding ready (by the way their link to the "Full Coding" does not lead to anything relating to the Ultrasonic module and the ZeroBorg) but thought just to see if the thing was rejected - and of course it was! If what you say in reply to the previous questioner is still valid, why do MagPi suggest otherwise. I can guess but maybe you can confirm it one way or the other.
Do I just connect the HC-SR04 via the GPIO and code accordingly and give the ZeroBorg the job of controlling the motors as I did before with a MotoZero?
Do I need to use a voltage divider as before?
I am mystified by the description in the article but maybe you can clarify the ZeroBorg's part in their piece! By the way I've tried to ask MagPi but without reply.

piborg's picture

You should not connect the HC-SR04 sensor to just the daisy-chain connector on the ZeroBorg, it will probably stop the ZeroBorg working normally as these are the pins used for power and I2C communications.

The HC-SR04 should really be connected to the GPIO pins, like you had originally. The problem may be that you need access to the 3.3V or 5V pins on the GPIO, which are now used by the ZeroBorg. You can still access these power pins from the daisy-chain connector without causing problems.

One other thing that might be confusing, the pins on the second connector are not quite in the same order as the one that plugs onto the Raspberry Pi:

Be careful when using these pins that you connect to the correct ones!

Thanks for that reply. I'm really impressed and on a Saturday as well!!

I have three questions; two you will be able to answer and the other maybe not.
Do I need a voltage divider as I understand that the HC-SR04 "replies" at 5V and the pi only likes 3.3V? I can simply make up the divider if needed.
Can I use the power supply pins and the Ground from the I2C expansion? I understand which pins are which. Or it that what you call the daisy chain connector.
Why has MagPi detailed the connection of the HC-SR04 to the I2C expansion if it simply won't work? They even detail the use of a multiplexer to use more then one!!

Thanks

HyFy

piborg's picture

We are always happy to help when we can. I must admit we do not usually manage to reply on the weekends though :)

In answer to your questions:

You do need a voltage divider to drop the 5V down to 3.3V so the Raspberry Pi is happy. There is a good post on how this can be done with two resistors here: https://www.pubnub.com/blog/2015-06-16-building-a-raspberry-pi-motion-se...

Yes you can use the power pins on the i2C expansion header. We have always called this header the daisy-chain connector as it allows more ZeroBorgs (or other PiBorgs) to be attached to the same Raspberry Pi. Brian has called it the I2C expansion header, but it is the same thing :)

I think Brian has confused things slightly by talking about different sensors. On the same page he talks about the time-of-flight (ToF) sensor as a different alternative. This sensor is actually I2C based and can be directly connected to the header as he described. What he did not make clear is that the HC-SR04 sensor cannot. The GPIO multiplexers are usually I2C based as well and can be connected to that header.

Hopefully that clears up the confusion.

Thanks again.

I understand what you are saying and describing and I can get on with it.

I will let you know when success is achieved. My second "Tiny" is slightly less tiny than the original but none-the-less it seems to turn well and appears more stable; especially on acceleration.

Thanks

HyFy

PS Have a good rest of the weekend.

Subscribe to Comments for "Zeroborg + ultrasonic sensor"