Hi Dr Roboto,
I want to use raspberry pi 4B to control mblock Orion. But I can’t control either DC motor and get reading from ultrasonics sensor.
I have followed these materials: https://github.com/Makeblock-official/PythonForMegaPi
Here is what I have done:
-
download Arduino and makeblock library
-
move makeblock library into Arduino and upload the firmware to the board
(i tested with makeblock app on my iphone and confirm it is good) -
in /boot/cmdline.txt, i removed “console = serial0, 115200”
but I kept serial port: enable in raspberry pi configuration
(if I do both the top two actions, I will not have /dev/ttyAMA0) -
according to /boot/overlays/README, I added line “dtoverlay=disable-bt” to disable bluetooth
-
i reboot raspberry pi and sudo systemctl disable hciuart
-
I installed megapi
-
sudo chmod a+rw /dev/ttyAMA0
sudo chmod a+rw /dev/ttyUSB0
(to let megapi be able to access it in step 8) -
In python:
from megapi import *
Version:3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0]bot=MegaPi()
init MegaPibot.start(’/dev/ttyUSB0’)
<megapi_python3.mSerial object at 0xb6670030>
(I have the beep sound from makeblock Orion board)distance = 123
def onRead(v):
global distance
print(“distance:”+str(v)+" cm")
distance = vsleep(2)
bot.ultrasonicSensorRead(3, onRead)
[Errno 9] Bad file descriptor
(I plugged my ultrasonics sensor to port 3) -
I found some similar issue here: Megapi python raspberry pi 3B Problem,Please Help~
but I don’t know whether it applies to raspberry 4B or not.
Could you help me to resolve this issue please?
Thank you.