{"id":13660,"date":"2026-10-31T12:00:00","date_gmt":"2026-10-31T11:00:00","guid":{"rendered":"https:\/\/kiloelectronics.com\/?p=13660"},"modified":"2026-10-13T14:01:48","modified_gmt":"2026-10-13T12:01:48","slug":"door-window-sensor-how-it-works","status":"publish","type":"post","link":"https:\/\/kiloelectronics.com\/en\/door-window-sensor-how-it-works\/","title":{"rendered":"Door Window Sensor: How Does It Work and Where Should You Mount It?"},"content":{"rendered":"<article lang=\"en\">\n<p>You stick a door window sensor to the frame, close the window, and the app still says &#8220;open.&#8221; The device is rarely the problem. A few millimeters usually are. A door window sensor has two parts: a sensor unit with electronics and battery on the fixed frame, and a magnet on the moving sash or door. While the magnet is close enough, the device reports &#8220;closed&#8221;; when it moves away, it switches to &#8220;open.&#8221; It is mounted correctly when gap, depth offset and alignment stay within the manufacturer&#8217;s limits and you have tried every way your window or door actually opens.<\/p>\n<p>The running example is the Milesight WS301, a LoRaWAN door sensor that sends every state change over radio to a gateway. The principles apply to any contact sensor, whether it is a battery-powered wireless door sensor or a wired magnetic contact in an alarm system.<\/p>\n<figure><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/kiloelectronics.com\/wp-content\/uploads\/2026\/10\/kilo-202610-topic-044-hero.png?resize=1130%2C753&#038;ssl=1\" alt=\"Door window sensor Milesight WS301 mounted on a window frame, with the smaller magnet aligned on the sash beside it\" width=\"1130\" height=\"753\" title=\"\"><figcaption>Sensor on the fixed frame, magnet on the moving sash: the notches on both housings face each other and the gap stays narrow.<\/figcaption><\/figure>\n<h2>How does a magnetic door and window sensor work?<\/h2>\n<p>The classic component inside is a reed switch: two thin reeds of magnetizable metal sealed in a small glass tube. When a magnet comes near, the reeds become magnetic, pull together and close a circuit. When the magnet leaves, they spring apart and the circuit opens. Some devices use a Hall-effect sensor instead, which measures field strength electronically. For installation it hardly matters, because either way the magnet&#8217;s field has to reach the sensing point with enough strength.<\/p>\n<p>That is why mounting matters so much. The field of a small permanent magnet drops off steeply with distance, so a few extra millimeters of gap or a sideways offset can stop the contact from switching reliably. There is also a little hysteresis: a reed switch closes at a slightly shorter distance as the magnet approaches than the one at which it reopens as the magnet leaves. A magnet sitting right at the limit can therefore report one state one day and the other the next.<\/p>\n<p>Know what a magnetic contact sensor cannot tell you. It only detects whether the magnet is nearby, not whether the window is locked, whether the handle is turned, or who opened it. The WS301 adds a tamper button that reports when the housing is pulled off its mounting plate, which is information about the device, not the window.<\/p>\n<h2>Door and window sensor installation: where do the sensor and magnet go?<\/h2>\n<p>Milesight is specific for the WS301: the sensor goes on the fixed part, the window frame or door frame, and the magnet on the moving sash or door leaf. The notched side of the magnet has to face the notched side of the sensor; otherwise, according to the manufacturer, detection sensitivity can suffer.<\/p>\n<p>Along the sash, the pair belongs on the opening side, where the handle is, not on the hinge side. Near the hinges the sash barely moves during a small opening, so a contact there will often report a slightly open window as closed. On the handle side, the magnet moves clearly away within the first couple of centimeters.<\/p>\n<p>For double doors and two-sash windows, Milesight specifies a separate pair for each leaf; a contact on the active leaf says nothing about the inactive one. Before you commit to adhesive, mark both positions with a pencil, close the window and check that handle, seal and hardware stay clear of the housings.<\/p>\n<h2>What is the maximum magnet gap for a door sensor?<\/h2>\n<p>The gap has two dimensions. The plane distance is the space between the two housings when they sit side by side at the same level. The height difference is how far apart the mounting surfaces are in depth, for example because the sash stands proud of the frame. Together they decide whether the magnet reaches the switching point. For the Milesight WS301, the manufacturer&#8217;s documents give different limits depending on the version:<\/p>\n<table>\n<thead>\n<tr>\n<th>Milesight document<\/th>\n<th>Plane distance<\/th>\n<th>Height difference<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Older online installation guide<\/td>\n<td>15 mm maximum<\/td>\n<td>under 7.5 mm<\/td>\n<\/tr>\n<tr>\n<td>Current quick start guide and user guide<\/td>\n<td>20 mm maximum<\/td>\n<td>under 20 mm<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The takeaway: there is no universal maximum, not even for one model across its documentation. Follow the guide that belongs to the hardware you received. If you are unsure, plan with the stricter 15 mm and 7.5 mm.<\/p>\n<p>The margin matters more than the limit. Set the gap to 19 mm because 20 mm is allowed, and you are asking for trouble: hinges develop play, seals compress, wooden frames move over the years. Plan so the pair sits well within the range when the window is closed. Measure with the window fully closed and locked, between the two notched sides, not between whichever edges are easiest to reach. If the sash stands far proud of the frame, make up the height with a solid spacer bonded flat.<\/p>\n<h2>Can a window sensor detect a tilted or partly open window?<\/h2>\n<p>That depends almost entirely on placement. A tilt-and-turn window tilts around its bottom hinges: the top edge of the sash moves a few centimeters inward while the bottom edge barely moves. A contact in the lower half of the handle side will often stay &#8220;closed&#8221; when the window is tilted. A contact at the top of the handle side, near the upper corner, moves away from its magnet both when the window tilts and when it swings open.<\/p>\n<p>If every opening matters, the pair belongs at the top of the handle side. A single contact still cannot tell tilted from fully open, because it only knows two states. If you need that distinction, add a second pair at the bottom of the handle side. Top open and bottom closed means tilted; both open means swung open. That logic lives in your application, not in the device.<\/p>\n<p>Always check the tilt position on your own window; on a small sash with a short tilt arm, the magnet can stay close to the limit.<\/p>\n<h2>Should you mount a door sensor with adhesive or screws?<\/h2>\n<p>The WS301 supports both 3M tape and screws. For tape, Milesight&#8217;s requirements are clear. The surface must be dry, smooth, firm and free of oil, dust and dirt; rough, crumbling or greasy surfaces and soft materials such as wallpaper or fabric are ruled out. Clean the spot with alcohol, don&#8217;t touch the adhesive side, and press both parts firmly for at least 30 seconds. The tape needs 24 hours to cure before the window goes back into normal use.<\/p>\n<p>Application temperature counts too. The recommended range is 20 to 40 \u00b0C (68 to 104 \u00b0F); in the cold, warm the tape to about 30 \u00b0C (86 \u00b0F) first. If the surface is unsuitable or the location stays cold long term, the manufacturer explicitly recommends screws.<\/p>\n<p>Adhesive leaves no holes, which often decides it in a rental. Screws hold more reliably and make the position repeatable when you remove the device for a battery change. Vinyl frames often hide reinforcements and hardware inside the profile, so use short screws in the visible, flat part of the frame. Either way, the WS301 is rated IP20 for indoor use, with an operating range of -20 to +60 \u00b0C (-4 to 140 \u00b0F), so the outside face of a window is not a mounting location.<\/p>\n<figure><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/kiloelectronics.com\/wp-content\/uploads\/2026\/10\/kilo-202610-topic-044-support.png?resize=1130%2C753&#038;ssl=1\" alt=\"Door window sensor Milesight WS301 before installation: sensor unit and smaller magnet side by side on a wooden table\" width=\"1130\" height=\"753\" title=\"\"><figcaption>The sensor measures 50.5 \u00d7 31 \u00d7 18.5 mm and the magnet 50.5 \u00d7 13.5 \u00d7 13 mm. Both housings carry the notch that must face the other part.<\/figcaption><\/figure>\n<h2>Do door sensors work on metal doors and frames?<\/h2>\n<p>They can, but metal has two effects. Steel is magnetizable and diverts some of the magnet&#8217;s field lines, so less field reaches the sensor and the effective switching distance can become much shorter than on wood or vinyl. Aluminum is not magnetizable and hardly disturbs the field. For radio, both metals are an obstacle: a closed steel door in a steel frame shields the signal more than a wooden one.<\/p>\n<p>Milesight gives no separate gap values for metal surfaces on the WS301, so test at the final spot first. Hold sensor and magnet in place with painter&#8217;s tape, open and close the door several times, and watch the LED and the app. If the field is too weak on steel, a non-metallic spacer that lifts the magnet a few millimeters off the steel helps, as does a narrower gap. Mount the pair on the latch side, ideally near the top, where the door moves most. If a door with a closer slams shut, check after a few days that the tape has held.<\/p>\n<p>Range depends on the wireless standard. A LoRaWAN door sensor sends short packets to a gateway that can be much farther away: Milesight states up to 2 km (1.2 miles) in urban areas and up to 15 km (9.3 miles) in rural areas for the WS301, assuming good conditions and a clear line of sight. Indoors, walls, floors, reinforced concrete and metal frames cost a lot of range, so the signal quality your network server shows for each packet tells you more than any distance figure. Across large buildings, basements or outbuildings, a single gateway often covers every contact.<\/p>\n<h2>Where should you place a window sensor on sliding and casement windows?<\/h2>\n<p>On a casement window, which swings open on side hinges, the magnet goes on the face of the sash right next to the seam and the sensor on the frame opposite, on the handle side. The upper part of that side is the safest spot if you also want to catch small openings.<\/p>\n<p>A sliding window or sliding door moves parallel to the frame instead of swinging away. Mount the sensor on the frame edge that the sash meets when it closes, and the magnet on the edge or face of the sash so it slides sideways away from the sensor as the window opens. Check that neither housing sticks out into the track or catches on the passing sash. If two sliding panels both move, each needs its own pair. Whatever the type, the right spot is where the magnet leaves the sensing range at the smallest opening you care about.<\/p>\n<h2>How do you test a door window sensor after installation?<\/h2>\n<p>Start at the device. Once the WS301 has joined the network, its LED blinks green once each time you open or close the window. A red blink means it detected the change but is not registered on the network yet. That separates two sources of trouble: if the LED responds, the magnet is in the right place; if nothing shows up in the application, look at radio coverage, the gateway or the integration.<\/p>\n<p>Next, compare the display with reality. In the WS301&#8217;s data packet, magnet status 00 means closed and 01 means open. Open the window visibly and check that the application really shows &#8220;open,&#8221; then the reverse. Swapped labels in a dashboard are a common error unrelated to mounting. Then open slowly and note the gap at which the state changes, close slowly, then with a normal swing. Test tilt and swing positions and, with two sashes, each one separately.<\/p>\n<p>Besides state changes, the WS301 sends a regular status report with magnet status, tamper status and battery level. The factory interval is 1,080 minutes, or 18 hours, adjustable from 1 to 1,080 minutes over NFC with the Milesight ToolBox app. A shorter interval reveals a failed device sooner but uses more battery. Power comes from a 1,200 mAh ER14250 lithium battery; alkaline cells are not allowed as a replacement. Milesight rates battery life at around 6.8 years at SF7 and around 4.2 years at SF10 in the EU868 band, measured in the lab.<\/p>\n<p>If you build a rule on the contact, such as &#8220;window open longer than 30 minutes, then send a reminder to my phone,&#8221; test both directions: the reminder must arrive after the delay and must not arrive if the window closes before then. Also check what happens when a message goes missing. An old &#8220;closed&#8221; value must not count as current indefinitely.<\/p>\n<h2>Why does my door sensor show the wrong state?<\/h2>\n<p>If it shows &#8220;open&#8221; all the time while the door is shut, the gap or height difference is out of range or the notches are not facing each other. Often the magnet ended up on the frame and the sensor on the door, so the geometry shifts differently than expected when it closes.<\/p>\n<p>If the state occasionally flips while the door is closed, the pair is sitting at the switching limit, and a little play in the sash or wind pressing on the window is enough to trigger a message. The fix is more margin, meaning a narrower gap, not a more sensitive sensor.<\/p>\n<p>If it reports &#8220;closed&#8221; while the window is open, it is too close to the hinges or in the lower half of a tilted sash. On steel, the diverted field can also make the contact switch late. A housing that has crept on yielding tape causes similar effects, often weeks after installation.<\/p>\n<p>If the LED is right but the app is wrong, check the radio path and the software: gateway coverage, lost packets, the wrong decoder or swapped labels. A low battery can also make messages go missing, and a tamper alarm means a housing has come loose from its mounting plate.<\/p>\n<h2>Where can you buy door window sensors?<\/h2>\n<p>The choice follows from the questions you answered at the window. Start with the wireless standard: if you have a LoRaWAN gateway or plan to add one, a LoRaWAN door sensor that reaches across large buildings and several floors is a good fit. Then the geometry: check the permitted plane distance and height difference in the manual and compare them with the offset between sash and frame on your windows and doors. Look for both mounting options, tape for rentals and screws for cold or difficult surfaces. The protection rating tells you whether the device belongs indoors only, like the WS301 with IP20. Battery type and rated battery life show how often you will swap cells. A tamper button and an adjustable reporting interval make failures and tampering visible. If you are looking for a suitable door window sensor, you will find our models in the <a href=\"https:\/\/kiloelectronics.com\/en\/product-category\/sensors-en\/door-window\/\">door and window sensors<\/a> category.<\/p>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>How a door window sensor works, where the sensor and magnet go, which magnet gap is allowed, and how to test it on tilted, sliding and metal frames.<\/p>\n","protected":false},"author":2,"featured_media":13412,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[791350634],"tags":[],"class_list":["post-13660","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-smart-buildings-air-quality"],"acf":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/kiloelectronics.com\/wp-content\/uploads\/2026\/10\/kilo-202610-topic-044-hero.png?fit=1536%2C1024&ssl=1","_links":{"self":[{"href":"https:\/\/kiloelectronics.com\/en\/wp-json\/wp\/v2\/posts\/13660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kiloelectronics.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kiloelectronics.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kiloelectronics.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kiloelectronics.com\/en\/wp-json\/wp\/v2\/comments?post=13660"}],"version-history":[{"count":2,"href":"https:\/\/kiloelectronics.com\/en\/wp-json\/wp\/v2\/posts\/13660\/revisions"}],"predecessor-version":[{"id":14114,"href":"https:\/\/kiloelectronics.com\/en\/wp-json\/wp\/v2\/posts\/13660\/revisions\/14114"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kiloelectronics.com\/en\/wp-json\/wp\/v2\/media\/13412"}],"wp:attachment":[{"href":"https:\/\/kiloelectronics.com\/en\/wp-json\/wp\/v2\/media?parent=13660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kiloelectronics.com\/en\/wp-json\/wp\/v2\/categories?post=13660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kiloelectronics.com\/en\/wp-json\/wp\/v2\/tags?post=13660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}