Grove - Magnetic Switch

This is a Grove interface compatible Magnetic switch module. It is based on encapsulated dry reed switch CT10. CT10 is single-pole, single throw (SPST) type, having normally open ruthenium contacts. The sensor is a double-ended type and may be actuated with an electromagnet, a permanent magnet or a combination of both. The magnetic switch is a wonderful tool for designers who would like to turn a circuit on and off based on proximity.


  • Grove compatible interface
  • 2.0cm x 2.0cm Grove module
  • Minimum external parts
  • 10W rating
  • Rugged encapsulation


More details about Grove modules please refer to Grove System

Application Ideas

  • Proximity Sensor
  • Security Alarm Sensor
  • Level Sensor
  • Flow Sensor
  • Pulse Counter


Items Min Norm Max Unit
Working Voltage 4.75 5.0 5.25 V
Switched Power 10 W
Switched Voltage AC,RMS value(max) < 140 V
Switched Current DC < 500 mA
Carry Current DC < 0.5 A
Contact Resistance <200
Insulation Resistance >106
Operating Temperature -40 - 125
Operate Range 10 - 40 AT

Platforms Supported

Arduino Raspberry Pi BeagleBone Wio LinkIt 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.


With Arduino

The SIG pin of the module output LOW normally. When a magnet approaches the switch, the magnetic switch close and the SIG pin output HIGH.

The following sketch demonstrates a simple application of using the Magnetic switch to control the led. When you put a magnet that has enough magnetic power close to the module, the switch is closed .Then the SIG pin out put a high voltage. You can use this to control the led.

As the picture on the below indicates, the Magnetic switch is connected to digital port 9 of the Grove - Base Shield and the LED is connected to digital port 13. When a Magnet approaches the switch, the SIG pin outputs a High voltage. Then the LED lights up. The hardware installation is as follows:

  • Copy and paste code below to a new Arduino sketch.

    /*macro definitions of magnetic pin and LED pin*/
    #define MAGNECTIC_SWITCH 9
    #define LED 13//the on board LED of the Arduino or Seeeduino

    void setup()

    void loop() 
        if(isNearMagnet())//if the magnetic switch is near the magnet?
    void pinsInit()

    /*If the magnetic switch is near the magnet, it will return ture, */
    /*otherwise it will return false                                */
    boolean isNearMagnet()
        int sensorValue = digitalRead(MAGNECTIC_SWITCH);
        if(sensorValue == HIGH)//if the sensor value is HIGH?
            return true;//yes,return ture
            return false;//no,return false
    void turnOnLED()
    void turnOffLED()
  • Upload the code.
  • Then the LED light when there is Magnetic approaches the switch. Have a try!

With Raspberry Pi

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

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


  • Plug the Magnet Switch to grovepi socket D3 by using a grove cable.

4.Navigate to the demos' directory:

    cd yourpath/GrovePi/Software/Python/

  • To see the code (this demo has the same usage with tilt switch)
        nano grovepi_tilt_switch.py   # "Ctrl+x" to exit #
        import time
        import grovepi
        # Connect the Grove Tilt Switch to digital port D3
        # SIG,NC,VCC,GND
        tilt_switch = 3
        while True:
                print grovepi.digitalRead(tilt_switch)
            except IOError:
                print "Error"

5.Run the demo.

    sudo python grove_tilt_switch.py


Put a magnet upon the sensor, the SIG pin will output HIGH.


Tech Support

Please do not hesitate to contact techsupport@seeed.cc if you have any technical issue. Or submit the issue into our forum.