Note
Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.
Why Join?
Expert Support: Solve post-sale issues and technical challenges with help from our community and team.
Learn & Share: Exchange tips and tutorials to enhance your skills.
Exclusive Previews: Get early access to new product announcements and sneak peeks.
Special Discounts: Enjoy exclusive discounts on our newest products.
Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.
👉 Ready to explore and create with us? Click [here] and join today!
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.
Note
Before starting this project, we recommend that you complete Get Start with Blynk. The following will give you a clear understanding of Blynk.
1. Wiring
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_TOKEN
.
BLYNK_AUTH = 'YourAuthToken'
Run the code.
sudo python3 blynk_reed.py
4. Open Blynk APP
Note
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.