Slack Notification with BLE
Contents
Make things
This program notifies on Slack when you go out and return home.
Materials
- obniz Board
- power supply for obniz
- Slack account
- smartphone app which BLE advertising available
How to make
Hardware connection
Connect a power supply to an obniz Board. No parts are needed.
Software
At first, get Webhook URL to send messages on Slack. Please get it from here.
Choose a channel messages will be sent and click “Add Incoming WebHooks integration.”
Replace the WEBHOOK_URL_HERE
(line45) with displayed Webhook URL. Additionally, replace the CHANNEL_NAME_HERE
(line47) with the channel name you chose. Remember to write a channel name with “#.”
var url = 'WEBHOOK_URL_HERE'; var data = { "channel": 'CHANNEL_NAME_HERE', "username": 'obniz-bot', "text": msg };
Second, download a smartphone app which emits BLE advertisement such as LightBlue Explorer (→for iOS, →for Android).
If you emit a BLE advertisement from the smartphone app and run the program, you will receive notifications when you leave home and go back home.
The program detects BLE advertisement at this part and judges you are home or not. Change UUID_HERE
into UUID of the BLE advertisement from your smartphone.
obniz.ble.scan.onfinish = ((results) => { let find = "Leaving"; for (key in results){ let beacon = results[key].iBeacon(); if (beacon){ if (beacon.uuid === "UUID_HERE"){ find = "In home now"; } } }...
Please read BLE – obniz Docs for details about BLE of the obniz Board.