Megapi+Raspberry Power


#1

Hi,
I got a Megapi and my plan was to use it to control two encoder motors, and attach it to a Raspberry Pi. However, after reading the FAQ it turns out I shouldn’t power the Raspberry by using the GPIO:

“When supplying power to Raspberry Pi through MegaPi and controlling motors at the same time, the voltage will be unstable and Raspberry Pi will reset. Just supply power to Raspberry Pi directly.”

How should this be done exactly? Isn’t one of the pins connecting the two boards the 5V for the Raspberry? Should it just be cut? Has anyone done something already with this setup? Thanks!


#2

Hi Tomatito.

Yes, it is strongly suggest that you supply power to raspberry directly in this case sine the supply ability to raspberry is weak. You can give a test.


#3

Thanks for your reply!
My question was actually how should the two boards be connected then. You provide a connector:


which connects the 5V from the MegaPi to the Raspberry. Should it not be used then? Which pins should be connected and which not?


GPIO pins on the Raspberry Pi
#4

Hi @tomatito,

Imho you just need to plug a power source to the 5V micro USB port of the raspberry pi. This could either be a power supply or one of these smartphone recharging batteries which you find in every electronics shops nowadays.

@tec_support, please correct me if I am wrong here, but there is no need to cut any pins.


#5

Hi! but wouldn’t that mean having two power supply sources at the same time at the raspberry? one from the micro usb and one from the megapi…


#6

@Srothe is correct.
@tomatito, you can just connect the 2*5 pins on MegaPi to Raspberry Pi, you don’t need to worry about the power, you can connect refer to the picture below:


Controlling Ultimate 2.0 Kit MegaPi from Raspberry
#7

Thanks a lot for your answers! My worry was that I can either fry the raspberry or the megapi


#8

@tomatito: you can safely connect both supplies at the same time, in parallel.


#9

Hi,

How do we communicate or send code from the Raspberry Pi to the MegaPi board? What are the detailed steps that would help do that??


#10

Hi,Does it work? Megapi + Raspberry


#11

Not exactly sure what your question is, but here is are the basics.

The Megapi is a microcontroller that does a good job with it’s limited resources to run the motors and sensors attached to it. It is NOT a general purpose computer. Most of the demos and example you see are of a general purpose computer (tablet, phone, pc, mac) sending commands via (bluetooth, wifi, usb, serial port) to a simple “firmware” running on the MegaPI.

The raspberry pi takes the general purpose computer role in this. So, for instance, if you install the standard firmware on the MegaPI, then connect it to the raspberry pi either through a USB cable or the GPIO serial connect (pictured in a post above), you can then send the commands that the standard firmware can understand through that serial connection.

Makeblock is supplying a python class (called MegaPI) that will run on your raspberry pi to send those commands and handle the callbacks (for sensor calls).

There are numerous examples in the makeblock git repository here: https://github.com/Makeblock-official/PythonForMegaPi

But the basics are…(once you have the two devices connected), in python:

from megapi import *

bot = MegaPi()
 # if you are using the USB port
bot.start('/dev/ttyUSB0'), 
# otherwise ttyS0 or ttyAMA0 depending on your configuration

There is a good post on setting up the serial port on your RPi here: MegaPi Firmware / Python Interface

Fergus


#12

Not true… I connected both and smoke started to come out of an encoder motor


#13

So you obviously had a problem with your wiring, which would be your own mistake, or you possibly had a defective component. What exactly makes you think the statements in this thread were wrong? Could you post a schema of your wiring, this would make it easier to identify the problem?


#14

I connected a power source to the Raspberry Pi and the battery pack to the megapi. wiring was working fine until I added the power bank. The battery pack alone is sufficient to power both the raspberry and the megapi.


#15

What voltage was the encoder motor designed for? Andwhich port did you connect it to?


#16

9V… port 3… the battery pack was connected to the Megapi and my powerbank (5v) was connected to the raspberry pi.


#17

Hi, is there something I am doing wrongly? I have performed all the necessary setup and I ran the following commends and got no results. Would you be able to shed some light please?

pi@raspberrypi:~ $ cd Documents
pi@raspberrypi:~/Documents $ python motorRun.py
init MegaPi
<megapi.mSerial instance at 0x766ead50>


#20

megapi.mSerial instance at 0x766ead50


#21

andrew, you simply cannot fry a 9V motor with using a 5V power supply. So either your battery pack was designed for higher voltage, or you missed out something else.
From the information we got from you, we can not give you better advice than to re-check your wiring and make sure you do not apply too much currency and power to the encoder.


#22