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 3.3 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


More details about Grove modules please refer to Grove System

Platforms Supported

Arduino Raspberry Pi


The platforms mentioned above as supported is/are an indication of the module's software 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.

Getting Started


If this is the first time you work with Arduino, we firmly recommend you to see Getting Started with Arduino before the start.

Play 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.


  • Step 1. Prepare the below stuffs:
Seeeduino V4.2 Base Shield Grove - Magnetic Switch
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now
  • Step 2. Connect Grove - Magnetic Switch to port D2 of Grove-Base Shield.
  • Step 3. Plug Grove - Base Shield into Seeeduino.
  • Step 4. Connect Seeeduino to PC via a USB cable.


If we don't have Grove Base Shield, We also can directly connect Grove-Magnetic-Switch to Seeeduino as below.

Seeeduino Grove-Magnetic_Switch
5V/3.3V Red
GND Black
NC White
D2 Yellow


  • Step 1. Copy the code into Arduino IDE and upload. If you do not know how to upload the code, please check how to upload code.

/*macro definitions of magnetic pin and LED pin*/
#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()
  • Step 2. Then the LED turns on when there is Magnetic approaches the switch. Have a try!

Play with Codecraft


Step 1. Connect a Grove - Magnetic Switch to port D2 of a Base Shield.

Step 2. Plug the Base Shield to your Seeeduino/Arduino.

Step 3. Link Seeeduino/Arduino to your PC via an USB cable.


Step 1. Open Codecraft, add Arduino support, and drag a main procedure to working area.


If this is your first time using Codecraft, see also Guide for Codecraft using Arduino.

Step 2. Drag blocks as picture below or open the cdc file which can be downloaded at the end of this page.


Upload the program to your Arduino/Seeeduino.


When the code finishes uploaded, move the magnet close to the magnetic switch and you will see the LED on the Arduino 13 pin turns on.

Play With Raspberry Pi


  • Step 1. Prepare the below stuffs:
Raspberry pi GrovePi_Plus Grove - Magnetic Switch
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now
  • Step 2. Plug the GrovePi_Plus into Raspberry.
  • Step 3. Connect Grove-Magnetic-Switch ranger to D2 port of GrovePi_Plus.
  • Step 4. Connect the Raspberry to PC through USB cable.



If you are using Raspberry Pi with Raspberrypi OS >= Bullseye, you have to use this command line only with Python3.

  • Step 1. Follow Setting Software to configure the development environment.

  • Step 2. Navigate to the demos' directory:

cd yourpath/GrovePi/Software/Python/
  • Step 3. 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 D2
tilt_switch = 2


while True:
        print grovepi.digitalRead(tilt_switch)

    except IOError:
        print "Error"
  • Step 4. Run the demo.
sudo python grovepi_tilt_switch.py
  • Step 5. Result

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

Grove-Magnetic Switch v0.9

Grove-Magnetic Switch v1.3


Tech Support

Please submit any technical issue into our forum.