Notify LINE when your mail arrives!
Contents
Make things
Let’s make a system that notifies on LINE if you get mails or packages.
Related Article.:IoT x mail notification
The flow of the system is as follows.
-
- A distance sensor mounted on the ceiling of the mailbox constantly measures the distance to the floor of the mailbox.
- When the mail is placed in the mailbox, the distance between them is reduced so that it can detect that the mail has been delivered.
- When it detects that your mail has arrived, it will tap the LINE Notify API and notify LINE.
- You’ll be happy to know your mail has arrived from your smartphone!
(This implementation also reacts when you take out the mail because of the distance changes, but we assume that you run this program to receive the notification when you are not in front of the mailbox.)
Materials
- obniz Board
- Infrared distance sensor GP2Y0A21YK0F
- power supply for obniz Board
- LINE account
How to make
Hardware Connection
Connect the infrared distance sensor GP2Y0A21YK0F to an obniz Board like the table and the image below by referring to the infrared distance sensor GP2Y0A21YK0F Library.
obniz | infrared distance sensor GP2Y0A21YK0F |
---|---|
0 | Vcc |
1 | GND |
2 | signal |
Software
The program measures the distance between the floor and the ceiling of the mailbox every 300ms. Notify on LINE Notify if the amount of change goes over the threshold.
Go to the LINE Notify page and log in, then open My Page (LINE account required).
Scroll down to My Page and click on “Issue Access Token (for developers)”.
Enter the token name you want to display when you get the notification. And select “receive notifications as 1:1 from LINE Notify” (this time, the token name is posted).
When you click on “Publish“, a token will be displayed as shown below. Save it not to lose it. If you leave this page, you will not be able to check your token.
Replace the LINE_NOTIFY_TOKEN_HERE
(code.js line45) with the noted token.
Lastly, don’t forget to friend your LINE Notify account in the LINE app.
Program
The code is written in Node.js.
How to use
When you run the program, you’ll be notified by LINE Notify every time your mail arrives. (If it doesn’t respond well, try adjusting the value of POSTED_THOREHOLD in line 9.)
in the end
Thus, by using obniz Board and LINE Notify, you can easily send notifications to LINE based on the value of the sensor. I hope you’ll take advantage of it.