RaspberryPi 3 Magnet Sensor With Mini Reed Sensor


Introduction: RaspberryPi 3 Magnet Sensor With Mini Reed Sensor

In this Instructable, we will create an IoT magnet sensor using a RaspberryPi 3.

The sensor consists of an LED and a buzzer, both of which turn on when a magnet is sensed by the mini reed sensor.

Step 1: Gather Supplies

To begin, make sure that you have all of the necessary supplies. You will need:

  • A RaspberryPi 3
  • A T Cobbler
  • A Breadboard
  • A Ribbon Connector
  • A Mini Reed Sensor
  • An LED
  • A Buzzer
  • Assorted Wires (including some with at least one female end)

Step 2: Connect Pi and Breadboard

Next, you will connect the RaspberryPi and the Breadboard. In order to do this, you will put one end of the ribbon connector into the T Cobbler, and the other over the pins on the RaspberryPi. Then put the T Cobbler into the breadboard.

Step 3: Wire the Mini Reed Sensor

Now, wire the mini reed sensor. You will want to use wires with a female end to achieve this, as the sensor has male pins. From left to right, the sensor's pins are output, power, and ground.

Wire the output pin to the T Cobbler GPIO24, power to any 5V T Cobbler pin, and ground to any GND T Cobbler pin.

Step 4: Wire the LED

The LED can be a bit tricky if you aren't familiar with it! The LED itself has a long end and a short end. The long end should be connected to GPIO26 through a 330k ohm resistor, and the short end connects directly to ground, as shown above. You may choose to use additional wires to make sure that everything stays nice and neat!

Step 5: Wire the Buzzer

You will notice that your buzzer has both a + and a - symbol on the bottom. The + shows which buzzer pin should be connected to power, and the - shows the pin that should be connected to ground.

Connect the + pin to GPIO25, and the - pin to GND. I chose to use the same pathway I wired my LED to GND on, but you don't have to do this!

Step 6: Run Some Code!

The python code provided here runs our device exactly as we expect it to; when the mini reed sensor finds a magnet, the LED and buzzer turn on. When the magnet is removed, both turn off. Note that we need to invert the values input from our mini reed sensor. This is because the sensor is normally open, and goes low when it senses a magnet.

You should now have a working magnet sensor!



    • Casting Contest

      Casting Contest
    • Make it Move Contest

      Make it Move Contest
    • Microcontroller Contest

      Microcontroller Contest

    We have a be nice policy.
    Please be positive and constructive.