Skip to main content

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


Working Voltage3.35.05.25V
Switched Power10W
Switched Voltage AC,RMS value(max)< 140V
Switched Current DC< 500mA
Carry Current DC< 0.5A
Contact Resistance<200
Insulation Resistance>106
Operating Temperature-40-125
Operate Range10-40AT

More details about Grove modules please refer to Grove System

Platforms Supported

ArduinoRaspberry 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.2Base ShieldGrove - Magnetic Switch
enter image description hereenter image description hereenter image description here
Get One NowGet One NowGet 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.



  • 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 piGrovePi_PlusGrove - Magnetic Switch
enter image description hereenter image description hereenter image description here
Get One NowGet One NowGet 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   # "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
  • 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 & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...