An Arduino garage door sensor is a do-it-yourself door monitor: a small microcontroller board, usually an Arduino or a Wi-Fi board like the ESP32, reading a magnetic switch that tells it whether the garage door is open or closed. It isn’t a garage door brand, and it isn’t the pair of safety eyes near the floor. This guide covers what to build, how to wire it, and how to fix the problems these projects run into most.
Short Answer: Mount a magnetic reed switch on the door frame and its magnet on the door, wire one lead to a digital pin and the other to ground, and set the pin to INPUT_PULLUP. False readings usually mean a floating pin, contact bounce or a magnet set too far away. A relay can’t trigger openers with a yellow learn button.
Last verified: November 16, 2026, against Arduino’s digital pin and digitalRead documentation, Chamberlain’s door control troubleshooting page, and ratCloud’s ratgdo product page. How we research.
What an Arduino Garage Door Sensor Is, and What It Isn’t
The sensor itself is simple. A reed switch is two thin metal contacts sealed in a small case. When a magnet comes close, the contacts touch and the circuit closes; when the door moves the magnet away, it opens again. The board watches that switch and does something with the result: lights an LED, sounds a buzzer, or sends a phone alert over Wi-Fi.

What it isn’t: the safety reversing sensors, the two small “photo eyes” near the floor that stop a closing door when something crosses the beam. Those belong to your opener, and your opener won’t close the door without them. If your door won’t close and a light on one of those eyes is blinking, skip to the last section, because that’s a different problem with a different fix.
Parts You Need
A basic open-or-closed monitor needs very little. The choice that matters most is the board: a plain Arduino Uno or Nano is fine for an LED or buzzer in the garage, but if you want a phone alert you need a board with Wi-Fi.
| Part | What it does | Notes |
|---|---|---|
| Arduino Uno or Nano | Reads the switch, drives an LED or buzzer | No Wi-Fi on its own |
| ESP32 or ESP8266 board | Same job, plus Wi-Fi for phone alerts | Most garage projects end up here |
| Magnetic reed switch and magnet | Detects the closed position | Garage-rated “overhead door” contacts tolerate a wider gap than small hobby switches |
| Second reed switch (optional) | Detects the fully open position | Lets you tell open, closed and stuck halfway apart |
| Two-conductor wire, 5V USB supply | Connects the switch and powers the board | Keep the wire run short or twisted |
Some builders use an ultrasonic distance sensor on the ceiling instead of a reed switch, reading whether the door panel is overhead. It works without touching the door, but a reed switch is cheaper, simpler and far less fussy, so start there.
How to Wire and Code the Reed Switch
Mount the reed switch on the door frame near the bottom or top of the opening, and the magnet on the door so the two line up when the door is fully closed. Then run one lead of the switch to a digital pin and the other to GND. No resistor is needed if you use the board’s built-in pull-up.

Arduino’s documentation explains why that pull-up matters. A pin set to plain INPUT with a loose wire attached “will report seemingly random changes in pin state” from electrical noise. Setting the pin to INPUT_PULLUP turns on an internal resistor, which Arduino says is between 20k ohm and 50k ohm on most AVR boards, and the other side of the sensor goes to ground. The pin then reads HIGH when the switch is open (door up) and LOW when the magnet closes it (door down).
A minimal sketch that prints one message each time the door changes state, with a short debounce so a single closing doesn’t register several times:
const int DOOR_PIN = 2;
int lastState = -1;
void setup() {
Serial.begin(9600);
pinMode(DOOR_PIN, INPUT_PULLUP); // switch between pin 2 and GND
}
void loop() {
int state = digitalRead(DOOR_PIN); // LOW = magnet near = door closed
if (state != lastState) {
delay(50); // let the contacts settle
if (digitalRead(DOOR_PIN) == state) {
Serial.println(state == LOW ? "Door closed" : "Door open");
lastState = state;
}
}
}If your readings come out backwards, you have a normally closed switch rather than a normally open one. Swap the two messages in the code; the wiring stays the same.
Can the Arduino Open and Close the Door Too?
Monitoring is the easy half. Controlling the door is where most projects stall, and the reason is printed on the opener: the color of its learn button.

On many older openers the wall button is a plain switch: pressing it briefly connects two wires. A relay module wired across those two terminals does the same thing, so the board can “press the button” for you. Chamberlain and LiftMaster openers with a yellow learn button use Security+ 2.0, and their wall controls send coded data instead. Chamberlain’s own troubleshooting page says that touching the wires together on these encrypted serial door controls will not activate the opener, which is exactly what a relay does. So the relay clicks and nothing happens.
Your options on a yellow-button opener:
- A Security+ 2.0 board. ratgdo, sold by ratCloud, is an ESP-based board that speaks the opener’s protocol. Its maker says it controls the door, light and lock on yellow-button openers, reads the door’s position, and works locally with no subscription.
- A spare remote. Hobbyists wire a relay across the button of a spare Security+ 2.0 remote so the board “presses” it. It works but needs soldering and a battery or power supply for the remote.
- An off-the-shelf hub. If you’d rather not build anything, a myQ hub or a meross controller does the same job; our garage door monitor comparison covers them.
Two safety rules apply to any build that can close the door. Closing a door you can’t see is what door makers call unattended close, and Chamberlain’s manuals limit it to sectional doors, not one-piece doors. And never wire anything into the safety sensor terminals or jumper them out: those eyes are what stop the door on a child, a pet or a car. Our guide on why a doorbell button won’t work as a garage door button covers the wall-terminal side in more detail.
Arduino Garage Door Sensor Not Working? Common Faults and Fixes
Most problems with these builds come down to a handful of causes. Work down the table from the top; the first two cover the majority of “it says open when it’s closed” complaints.

| What you see | Likely cause | Fix |
|---|---|---|
| Readings flicker between open and closed with nothing moving | Floating input pin or electrical noise on a long wire | Use INPUT_PULLUP (or a 10k ohm external pull-up), shorten or twist the wire, keep it away from the opener’s power cord |
| Reads “open” even though the door is shut | Magnet too far from the switch, or misaligned | Close the door and move the magnet until it sits within the switch’s rated gap; use a garage-rated contact for wide gaps |
| Several alerts every time the door closes | Contact bounce | Add a debounce delay or state-change check, as in the sketch above |
| Reads “closed” when the door stopped a few inches short | One switch can only see one position | Add a second switch at the fully open position, or move the closed switch so it only triggers at the very bottom |
| Alerts stop for hours, then come back | Weak Wi-Fi in the garage; metal doors block signal | Check signal where the board sits, move it toward the house, add an extender, or use a board with an external antenna |
| Relay clicks but the door doesn’t move | Yellow learn button (Security+ 2.0) | Use a Security+ 2.0 board or a spare remote, as described above |
| Door won’t close at all after you installed the project | Wires landed on the safety sensor terminals, or a safety eye got knocked | Disconnect your project wires from the opener and check the photo eyes |
To check the switch itself, set a multimeter to continuity and touch the probes to the switch’s two terminals with the door closed. It should beep (closed circuit) with the magnet near and go silent when you open the door. If it never changes, the switch or magnet is the problem, not your code. The fault homeowners hit most often with these builds is simply magnet distance: a switch that works on the bench can fail on a door that closes a little differently each time.
If You Meant the Opener’s Safety Sensors
If you searched for this because your garage door won’t close and a sensor light is blinking, the problem is your opener’s safety eyes, not an Arduino. Those are fixed by cleaning the lenses, realigning the two eyes until both lights are steady, shading the receiver from low sun and checking the wires.

Our step-by-step guide on how to fix a garage door sensor covers every major brand, and if you have a Genie, our page on a Genie sensor blinking red explains each blink count.
Frequently Asked Questions
Do I need a resistor for a reed switch on an Arduino?
Not if you set the pin to INPUT_PULLUP. That turns on a resistor built into the chip, and you wire the switch between the pin and ground. If you use plain INPUT instead, add an external pull-up or pull-down resistor; Arduino’s documentation suggests 10k ohm as a good value. Without one, the pin floats and gives random readings.
Can an Arduino garage door sensor work with myQ?
Not directly. myQ is Chamberlain’s cloud service, and a homemade sensor can’t join it. You can run your own sensor alongside a myQ opener, since the reed switch only watches the door. For control as well as status on a yellow-button myQ opener, a Security+ 2.0 board such as ratgdo is the route most builders take.
Is it safe to control a garage door with an Arduino?
Monitoring is completely safe because the board only reads a switch. Control is safe as long as the opener’s own safety system stays in charge: leave the photo eyes and their wiring alone, test that the door still reverses on an obstruction, and only close the door remotely if it’s a sectional door, as the opener manuals require.

