Door Window Sensor¶
When you’re outside, you’ve probably had this confusion. “Are the doors and windows of my house closed?”
To solve this problem, in this project, we will build a door and window sensor with Reed Switch and magnets.
Install this sensor and magnet on both sides of the door or window. You will be able to check whether your doors and windows are closed or not from the Blynk APP on your phone.
Before starting this project, we recommend that you complete Get Start with Blynk. The following will give you a clear understanding of Blynk.
2. Create Datastream
Click on the menu icon in the upper right corner and select edit dashboard.
Go to the Datastreams page and create a New Datastream.
Create a Virtual Pin V4.
When finished, click Save And Apply at the top right.
3. Run the Code
Edit the code
cd /home/pi/blynk-raspberrypi-python sudo nano blynk_reed.py
Find the line below and past your
BLYNK_AUTH = 'YourAuthToken'
Run the code.
sudo python3 blynk_reed.py
4. Open Blynk APP
As datastreams can only be created in Blynk on the web, you will need to reference different projects to create datastreams on the web, then follow the tutorial below to create widgets in Blynk on your mobile device.
Open Google Play or APP Store on your mobile device and search for “Blynk IoT” (not Blynk(legacy)) to download.
After opening the APP, login in, this account should be the same as the account used on the web client.
Then go to Dashboard (if you don’t have one, create one) and you will see that the Dashboard for mobile and web are independent of each other.
Click Edit Icon.
Click on the blank area.
Choose LED widget.
Now you will see a LED widget appear in the blank area, even if it looks like a blank grid, click on it.
LED Settings will appear, select the V4 datastreams you just set in the web page. Note that each widget corresponds to a different datastream in each project.
Go back to the Dashboard page. Now if you see that the LED widget is filled with color, your door or window is open; if the LED widget is not filled with color, the door or window is closed.