Safe drawer
Introductionβ
Do you have a diary, poems or a top secret government-issued document in your drawer? If it's something nobody should see, secure it. π Turn your IoT Start Kit into a drawer monitor and get alerts on your mobile phone. π²
This project teaches you how to create a drawer monitor that sends alerts to your mobile phone when some opens your drawer. π
You only need a box with a button and a Radio dongle. That's why the basic HARDWARIO Start Set is perfect.
Download the firmwareβ
- Upload special firmware to the Core Module, specifically bcf-radio-x-axis-detector (you can find it among other firmware in the Playground). Thanks to this firmware, the box will be more sensitive to movement. π
Our tip: Don't know how to download firmware or what it is? Find out here
- Pair the Core Module with the USB Dongle. Right after pairing, you'll see that your Core Module has changed its Alias to x-axis-detector.
Set up the mobile appβ
-
Continue on your mobile phone. The box will connect to your smartphone through the Blynk app. π± Learn how to use Blynk
-
From the menu, choose Styled button (fancy button). π¨ The button will be placed on your project canvas.
- When you click on the button, you'll get to the settings. Now pay attention. In the top line, name your detector.
Right below that, you'll choose PIN. Click on it. Select virtual and choose a number as you like. But remember it, you'll need to enter it on the computer later. Save the PIN and continue setting up the button.
Switch the button from push mode to switch, so you can conveniently start and stop the detector.
And then there are just those design nonsense. π You can choose the color of the button when it's off and on, its shape and other necessities.
Once you have everything set up, return to the canvas through the arrow at the top left.
- Tap on the canvas to add another element to the canvas. It will be a notification.
- Your entire canvas now looks like this.
- Tap on the button, it should switch from ON mode to OFF mode.
Set up the message in Node-REDβ
-
In the Playground, click on the Functions tab, where the Node-RED programming canvas is located.
-
Start as always: first place an MQTT node from the Input section on the canvas.
Double-click on it and copy the Topic into the line, which the box uses to detect movement changes:
node/x-axis-detector:0/accelerometer/-/event-count
- Next to this node, place a Switch node from the Function section. Thanks to this node, you can turn off detection when you're home and opening the drawer yourself.
- Inside the node, change the Property line to flow.active. In the line below, enter the number 1. With this number one, the notification will be sent when the button is on, otherwise it will be discarded. Look at the picture.
- After this, place another Change node from the Function section.
- In it, set up the message that will be sent to your mobile. Be careful, Blynk doesn't handle accents and special characters. π€·
- At the end of this food chain, place a Notify node from the Blynk ws section.
- When you double-click on it, the settings will open. Here click on the small pencil. You'll get to even deeper settings.
- You'll be interested in the first two lines. Copy the URL from the link below and copy the token from the email that was sent to you when you created the project in Blynk.
Our tip: Name the project in the Name line. You'll easily recognize it in other nodes later.
- Now connect this chain. And let's move on.
Set up the motion detector in Node-REDβ
- Start another chain. Place a Write event node from the Blynk WS section on the canvas. This controls the button.
- When you double-click on it, fill in the Virtual Pin line with the number you entered as PIN in Blynk (without the letter V).
In the Connection line, then select the project you named in the Notify node.
- And the last node to the party. Place a Change node from the Function section on the canvas.
- You'll set up the node to react to turning the button off and on in Blynk. Double-click to open it and set the Rules fields to flow.active and msg.payload respectively (look at the picture).
- Now connect these two beauties. Don't forget to also click the Deploy button at the top right so everything gets activated.
Start the trapβ
-
Place the box in the drawer lying flat.
-
Control everything else from your mobile phone. π± Turn on the project in Blynk (click the button so it gets to the ON position).
-
Start the entire flow in Blynk through the Play button at the top right. βΆοΈ
-
And wait for the mouse to get caught. π₯ Meanwhile, plan what you'll do with the sneaky troublemaker. We recommend making them do homework for you for a week. They deserve it.