Door-open alerts on your iPhone
Connect a magnetic door contact to a XIAO ESP32-C3. Add it as a Door Sensor in the controller Web Portal and receive phone alerts when the door opens.
What you need
- XIAO ESP32-C3
- MC-38 two-wire magnetic contact and magnet. Check the variant: its contacts should close when the magnet is nearby. Use a passive dry contact, not a powered sensor output.
- USB-C data cable, a suitable USB power supply and connection wires.
- An iPhone with XIAO Cloud, an account created in the app and a 2.4 GHz Wi-Fi network with internet access.
Affiliate link: we may earn a commission at no extra cost to you.
Choose the matching firmware on the XIAO Chips page; release availability is shown there. For installation help, contact [email protected]
Seven simple steps
Install the app and create your account
Download XIAO Cloud from the App Store, create your cloud account in the app and sign in. Keep these credentials for the Cloud section of the controller Web Portal.
Install the matching controller firmware
Open Supported Controllers and select ESP32-C3. Use only its XIAO Cloud firmware and installation instructions when published. A generic Arduino sketch or another board image is not a replacement.
Mount the contact and magnet
Place the wired contact on the fixed door frame and the magnet on the moving door. Align them closely enough for the contact to close when the door is shut; test this before fixing them permanently.
1: wired contact on the frame. 2: magnet on the door. Keep the two parts aligned when closed. Connect two wires: D1 and GND
Disconnect controller power. Connect one contact wire to the board pin labeled D1 and the other to GND; a passive contact has no polarity. The firmware uses an internal pull-up. Do not connect this contact to 5 V. Use D1, not a chip pin guessed from its GPIO number.
USB-C at the top: connect the contact to D1 (GPIO3, second left pad) and GND (second right pad). The board SVG comes from the controller Web Portal. Verify the printed labels on your actual board. Set up Wi-Fi, then connect to the cloud
Plug the controller into USB for power. On your iPhone, join the XIAO-YQ-Setup Wi-Fi network created by the controller. Stay connected even if it has no internet. Open http://192.168.4.1 in Safari, choose your home 2.4 GHz Wi-Fi, enter its password and save.
http://192.168.4.1Reconnect your iPhone to your home Wi-Fi. Open the controller Web Portal at its new local address, available in your router device list. Log in to the controller, enable Cloud and use the cloud account created in the app to connect. Bluetooth pairing is not required for this setup.
Add Device → Door Sensor in the Web Portal
In the controller Web Portal, choose Add Device → Door Sensor, select D1, give it a name such as Front door and save. Your iPhone and controller should remain on the same home Wi-Fi while using the local portal.
Enable notifications and test the door
Allow XIAO Cloud notifications on your iPhone and enable the device door-open alerts in the app. Open the door: verify that its state changes to Open and a notification arrives. Close it and check that the state returns to Closed.
No state change? Check the contact type and magnet alignment, the selected D1 pin and controller connectivity. With this contact, closed reads LOW and open reads HIGH.
Push alerts require internet, phone notification permission and available account quota. Test the setup before relying on it; this project is not a certified security alarm. Support