BrickPi3 and Grove electromagnet

Can I just plug in the Grove electromagnet into the Grove port on the BrickPi3? What Python code would I need in order to operate it?

Thank you.

1 Like

I’m not a BrickPi3 owner, but took a look at /home/pi/Dexter/BrickPi3 Projects and Examples - don’t see an electromagnet example but the website says it is supported.

" Use them with our robots, GoPiGo, GrovePi or BrickPi!"

Update: The Grove I2C sensors are probably supported, the analog and digital Grove sensors may not be.


The electromagnet got too hot to touch! Is this supposed to happen? Is it on or off by default? Is it port 4 for the BrickPi3?

Many thanks

1 Like

Update: Don’t plug it in there.

1 Like

It is on by default. And the program does not switch it off.

1 Like

Update: Don’t plug it in there.

1 Like

No - sorry. Don’t plug it in there.

1 Like

This is a BrickPi3, There is one Grove port, and my question is: what is the port number?

My bad - (I’ve never seen a BrickPi, BrickPi3, or GrovePi - I apologize for not being more attentive to it being BrickPi3 not a GrovePi).

Ok - the Grove I2C port is not where you plug the electromagnet into! That is only for Grove sensors that “speak” I2C.

To use the electromagnet you would need a custom “EV to Grove” cable, and need to set up the port for digital output and the 9v pin output.

(Or this and guidance from DI, or a BrickPi3 owner, on how to hook to a grove cable that will plug into the electromagnet:

and cut one of these in half:

If you don’t need 2 kilo holding force, you can run the Grove electromagnet with short “on” cycles for less battery drain, and less magnet heating.


Suggest posing question to

1 Like

But Grove electromagnet is on this list which says:
" These Grove modules have been tested by Dexter Industries and the GrovePi community and have examples available to try them out in our Github repository.
Use them with our robots, GoPiGo, GrovePi or BrickPi!"

This seems to be incorrect.

Ah, I see that you’ve edited your reply. So what would be the code for running the electromagnet on S1-S4? Oh but the electromagnet has a Grove connector so that won’t work either! And regarding your two links - the first is for a connector kit for NXT, and the second I don’t understand!

1 Like

You would need those two items to make a “BrickPi3_to_Grove_digital__or_analog_sensor_cable” this way:

Brickpi3_Port_4 <-EV3_cable-> NXT_EV3_Breadboard_kit ==solder==half_Grove_cable_with_“unbuckled”_connector==> Grove_Electromagnet

The problem is you seem to be the first person to explore this combination.

It is a really neat idea.

It seems like the BrickPi3 has 5v available on pin4 of the sensor connector which would connect to the red wire of grove cable.

Pin 3 (or 2) looks like GND and would connect to black wire of grove cable.

Pin 5 will be the on/off digital output which would connect to the yellow wire of grove cable.

I do know the Grove electromagnet can be powered by 5v up to 12v, so should work with building an adapter and the right code, which will look something like: (this is a guess - you need DI to chime in here):

from brickpi3 import BrickPi3
import time

BP = BrickPi3() # Create an instance of the BrickPi3 class. BP will be the BrickPi3 object.
    while True:
        BP.set_sensor_type(BP.PORT_4, BP.SENSOR_TYPE.CUSTOM, [(BP.SENSOR_CUSTOM.PIN5_OUT+BP.SENSOR_CUSTOM.PIN5_STATE)])  # turns electromag on
        BP.set_sensor_type(BP.PORT_4, BP.SENSOR_TYPE.CUSTOM, [(BP.SENSOR_CUSTOM.PIN5_OUT)])  # turns electromag off

except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
    BP.reset_all()        # Unconfigure the sensors, disable the motors, and restore the LED to the control of the BrickPi3 firmware

@cleoqc. Can you comment officially or is the only way?

1 Like

Well, technically it is not incorrect, but one implication is “Use [any of] them with [any of] our robots”, but it doesn’t actually say that.

Another point to note is that it does not mention the BrickPi3, only the BrickPi. Perhaps the statement was true for a prior version of the BrickPi.

Another implied reading of that statement is "Use [the supported subset of] them with our robots [since the BrickPi3 is a DI/ModularRobotics product and the Grove sensor set is not].

DI could very well tell you “The Grove Electromagnet is not a supported sensor with the BrickPi3” and cyclicalobsessive (me) should not have wandered into this unknown.

DISCLAIMER: This is pure conjecture. These thoughts are my own, and do not represent Dexter Industries or Modular Robotics.

1 Like