Run Python on Raspberry Pi3B, two ultrasonic sensor return the same distance,Why?


#1

I got two ultrasonic sensor connect with my ultimate2.0 megapi board. I run the python code on raspberry pi 3B:

def onReadLeft(v):
print v

def onReadRight(v):
print v

bot = Megapi()
bot.start(’/dev/serial0’)
while 1:
sleep(1)
bot.ultrasonicSensorRead(8, onReadLeft)
bot.ultrasonicSensorRead(6, onReadRight)

but the two ultrasonic sensor return the same distance. If I run only each one ultrasonic sensor, it’s work good. When two work together, return the same distance value.

How to fix this? Thanks.


#2

[Wrong advice deleted]
Sorry for giving false advice here, one should not answer after 3 glasses of wine and after midnight. :joy:


#3