Grove - Electromagnet


5.0V Digital

An electromagnet is a type of magnet in which the magnetic field is produced by electric current. An electric current flowing in a wire creates a magnetic field around the wire, due to Ampere’s law(see drawing below). To concentrate the magnetic field, in an electromagnet the wire is wound into a coil with many turns of wire lying side by side. The magnetic field of all the turns of wire passes through the center of the coil, creating a strong magnetic field there. Grove - Electromagnet can suck 1KG weight and hold on. It is easy to use, to learn electromagnet principle.


  • Grove shape
  • 1KG peak suction
  • Low standby current


  • Working Voltage :DC 5V
  • Working Current : 400mA
  • Standby current : 200uA
  • Load Weight: 1KG

Platforms Supported


With Arduino


      Turns on an Electromagnet on for one second, then off for one second, repeatedly.

      This example code is in the public domain.

    int Electromagnet = 0;
    int LED = 13;

    // the setup routine runs once when you press reset:
    void setup() {                
      // initialize the digital pin as an output.
      pinMode(Electromagnet, OUTPUT); 
      pinMode(LED, OUTPUT);   

    // the loop routine runs over and over again forever:
    void loop() {
      digitalWrite(Electromagnet, HIGH); // turn the Electromagnet on (HIGH is the voltage level)
      digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);               // wait for a second
      digitalWrite(Electromagnet, LOW);// turn the Electromagnet off by making the voltage LOW
      digitalWrite(LED, LOW);  // turn the LED off by making the voltage LOW
      delay(1000);               // wait for a second

With Raspberry Pi

1.You should have got a raspberry pi and a grovepi or grovepi+.

2.You should have completed configuring the development enviroment, otherwise follow here.


  • Plug the sensor to grovepi socket D4 by using a grove cable.

4.Navigate to the demos’ directory:

    cd yourpath/GrovePi/Software/Python/
  • To see the code
    nano   # "Ctrl+x" to exit #
    import time
    import grovepi

    # The electromagnet can hold a 1KG weight

    # Connect the Grove Electromagnet to digital port D4
    electromagnet = 4


    while True:
            # Switch on electromagnet
            print "on"

            # Switch off electromagnet
            print "off"

        except KeyboardInterrupt:
        except IOError:
            print "Error"

5.Run the demo.

    sudo python


ArduinoWioBeagleBoneRaspberry PiLinkIt ONE


The platforms mentioned above as supported is/are an indication of the module's hardware or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.

Help us make it better

Thank you for choosing Seeed. A couple of months ago we initiated a project to improve our documentation system. What you are looking at now is the first edition of the new documentation system. Comparing to the old one, here is the progresses that we made:

  • Replaced the old documentation system with a new one that was developed from Mkdocs, a more widely used and cooler tool to develop documentation system.
  • Integrated the documentation system with our official website, now you can go to Bazaar and other section like Forum and Community more conveniently.
  • Reviewed and rewrote documents for hundreds of products for the system’s first edition, and will continue migrate documents from old wiki to the new one.

An easy-to-use instruction is as important as the product itself. We are expecting this new system will improve your experience when using Seeed’s products. However since this is the first edition, there are still many things need to improve, if you have any suggestions or findings, you are most welcome to submit the amended version as our contributor or give us suggestions in the survey below, Please don’t forget to leave your email address so that we can reply.

Happy hacking