Multiple ultrasonic sensors on a GoPiGo

Hi,

I’ve just got a GoPiGo as a gift and I was thinking about getting some ultrasonic sensors. Is it possible to attach these sensors to any port other than the A1 port? I was hoping to have more than one, but would I be limited by only having a single analogue port to connect to? Is my only option to connect one to a GPIO port with some resistors to reduce the Voltage?

We haven’t tried using the multiple ultrasonic sensors but I think it should work with the analog, digital and the Serial ports but not the I2C one. Can you try it out and let us know if it works. You might not be able to poll the sensors very fast though.

-Karan

Thanks for the response, I’ve managed to get the HC-SR04 I bought working on the A1 and D11 port, by addressing pins 10 and 15 with us_dist, but I don’t get any response on 0 or 1 when I try with the same wiring on the serial port. Can you confirm whether I need to change the wiring layout? I found this post:

http://www.dexterindustries.com/topic/connecting-ultra-sonic-sensor-hc-sr04/

And from that I wired it as follows:

VCC -\ /- A1
Trig ----- A1
Echo -/ - VCC
GND ------ GND

Hey StockerRumbles,
Can you explain this a bit more " but I don’t get any response on 0 or 1 "

-Karan

Hi,

I meant pins 0 and 1, when I use:

us_dist(0)
us_dist(1)

I have seen this post stating you can only use 2 ultrasonic sensors, but earlier you said it might work with the serial port, is there a way to wire this device to work with the serial port?

I was planning on having one looking front-left and one front-right but I then thought about having one looking down to watch for falls, and hoped I could do this off the serial port.

Thanks

You might be able to use the Serial port but there can be problems with that. The Serial port is shared between the Atmega328 on the GoPiGo and the Raspberry Pi serial pins. In the default state, neither of them use it. So us_dist(0) and us_dist(1) might work but there can be interference from the Pi on that port too. Also, right now the code assumes that the two data pins are shorted (white and yellow), so that might be a problem too. Can you short the yellow and white pins and then try. A better option might be to use the data pin on the servo connector. That is still unused, so you can use that to read from the ultrasonic sensor.

-Karan

Hi, I’m using the servo as well, so I couldn’t use that. I’m not quite sure what you mean by shorting the yellow and white pins. Which pins are the yellow and white ones? Are these on the ultrasonic sensor or on the GoPiGo board?

Can you attach a picture of the servo that you are using. The grove ultrasonic sensor uses a grove cable http://www.seeedstudio.com/wiki/Grove_-_Ultrasonic_Ranger which has 4 wires. 2 of them, the yellow and white are for data. They are shorted on the GoPiGo. So the process might be a bit different if you have some other sensor. Normal ultrasonic sensors have 2 signals going out, Echo and Trig, so these would have to be shorted and the signal has to be sent to 1 pin on the UART port, D0 or D1.

-karan

I’m using a HC-SR04 the reason for this is that in the UK it costs around £15-£20 for the ultrasonic sensor you sell, and shipping from your site is prohibitively expensive. While I can pick up a HC-SR04 for £3. To connect it to my GoPiGo I used this cable and took one end off and replaced it with a grove connector.

I have attached photos of the servo and sensor, the servo is just connected directly to the connector on the front. The sensor Is wired:

VCC — VCC
TRIG — A1
ECHO — A1
GND — GND

This seems to work for me in testing, I didn’t check accuracy with measurements but it was changing as I moved my hand in front of the sensor and seemed to give distances up to 110cm which is fine for my uses.

Is it possible to use a I2C hub? If yes, you could attach 3 ore more sensors to it.

It wont we possible to attach an I2C hub because the sensors are digital and need some calculations done to get the distance value out of them. The GrovePi(www.dexterindustries.com/GrovePi/) might actually be a better option for this because it can support multiple ultrasonic sensors and you can connect it to the GoPiGo via I2C.

-Karan

Hey Karan,
So, if I’m using a GrovePi+, is it possible to connect multiple Ultrasonic Ranger sensors via I2C? Is their address fixed? how many would I be able to connect?

Yes, with the GrovePi+, you should be able to connect multiple ultrasonic sensors. I have tried two together but there is no reason why you should not be able to connect more. The address for I2Cwould be fixed, but you can just change the ports in the code and read from multiple sensors. Here is an example code: https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_ultrasonic.py.

-karan

Ok, but in that example they have to be connected to the digital ports, my question was if they could be handled as i2c sensors, which would mean that their i2c address could be assigned. It’s not really that big of a deal, but the way I wanted to wire them was using an i2c hub and use just one port on the grovepi.

I don;t think it would be possible to just connect them as such on the I2C port since they are not an I2C sensor. So they have to be individually connected as a digital sensor.