1. How to create Boss-Detector
===========================
**XXXX XXXX**
2. ##How to create Boss-detector
-Objective: Create **Boss-
Detector**, using Pi-2, Bluemix, in
1-hour
-When your boss approaches; you are
notified.
>>>>>>>
5. ##Step-0: find out your boss’
bluetooth-enabled phone
1.Approach your boss, along with
Linux or mac laptop
2.Open “Terminal” program
– Run “$hcitool scan”
– Find out his phone’s bluetooth ID, in format of,
e.g. “F8:2F:A8:E2:FE:F5”
– Write it down
7. ##Step-2: configure wifi
1.Logon/pw: pi/raspberry
2.Find the correct wifi driver for your
device (..google it)
3.Install steps
– http://elinux.org/RPi_Peripherals#Wireless:_TP-
Link_TL-WN722N_USB_wireless_adapter_.28Debian_6.29
– https://www.raspberrypi.org/forums/viewtopic.php?
t=7592
4.Check
– Run “$ip addr”
– Check wlan0 is UP
– Ensure the wifi working in your office as
well
8. ##Step-3: install bluez
1.Run
– “$sudo apt-get install bluez”
– “$sudo apt-get install python-bluez”
2.Check
– Run “$hcitool dev”
– Check hci0 is running
– Turn on bluetooth of your mobile phone
– Run “$hcitool scan”
– Check your device’s id
Also see: http://www.instructables.com/id/Raspberry-Pi-
Bluetooth-InOut-Board-or-Whos-Hom/
9. ##Step-4: create a program
1.Program
– Go to home directory /home/pi
– Create a program, namely “usebluetooth.py”, with
below code. Adjust sleep(time)
– In the “bluetooth.lookup_name()”, fill in your
bluetooth ID (for testing); or your boss bluetooth
ID (for production)
10. ##Step-5: install Bluemix/NODE-
RED
1.Run
– “$curl –sL https://deb.nodesource.com/setup |sudo
bash -”
– “$sudo apt-get install –y build-essential python-dev
python-rpi.gpio nodejs”
– “node-red-pi –max-old-space-size=128”
2.Check visual editor
– Use browser upon http://your-pi-ip-address:1880/
Also see: http://nodered.org/docs/hardware/raspberrypi.html
11. ##Step-6a: edit NODE-RED
1.Add a dummy input node
- Drop “rpi-gpio” to main pane; double-click it
- Fill as below diagram (pin number is arbitrary)
13. ##Step-6c: Edit NODE-RED
1.Add switch node
– Drop “switch” node to main pane; double click it
– Fill in the filter criteria “Boss Detected”
14. ##Step-6d: Edit NODE-RED
1.Add twitter node
– Drop “twitter” node to main pane; double click it
– Click the pencil, to add your twitter credential
15. ##Step-6e: Edit NODE-RED
1.Finish it
– Wire them up
– Beware to wire first output hook in “exec”; this
is stdout
– Click “Deploy”, and you will see a pop-up
“successfully saved”
16. ##Step-4: Configure reboot
1.Add to init.d
– There are ways to do it; I pick this one
– Run “$sudo wget -O /tmp/download
https://gist.github.com/bigmonkeyboy/9962293/downloa
d && sudo tar -zxf /tmp/download --strip-components
1 -C /etc/init.d && sudo chmod 755
/etc/init.d/nodered && sudo update-rc.d nodered
defaults”
2.Reboot & Check
– You will see something like “Node-RED Started”,
after reboot
Also See
https://gist.github.com/bigmonkeyboy/9962293
http://nodered.org/docs/getting-started/running.html
18. ##Remark
1.The program does not handle repeated
“check-in/out” condition properly. You
may improve yourself.
2.The NODE-RED is installed on Pi2. A
better approach is to register your
device to Bluemix; and send payload to
directly to it, via MQTT, for twitter
processing. (I tried it as well; works
perfectly)
3.Have fun!