How.to.create.boss.detector
-
Upload
ross-tang -
Category
Technology
-
view
83 -
download
0
Transcript of How.to.create.boss.detector
How to create Boss-Detector===========================
**XXXX XXXX**
##How to create Boss-detector-Objective: Create **Boss-Detector**, using Pi-2, Bluemix, in 1-hour-When your boss approaches; you are notified.
>>>>>>>
##Equipment-Raspberry Pi-2: US$35-Bluetooth dongle: US$2-Wifi dongle: US$5-8G micro-SD/NOOBS: US$7-Total: US$49-(optional) enclosure: US$8
##Pre-requisite-Linux or mac laptop-register free trial [Bluemix](http://console.ng.bluemix.net)
##Step-0: find out your boss’ bluetooth-enabled phone1.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
##Step-1: setup Pi-21.Ground yourself
2.Connect Pi-2: bluetooth, wifi, keyboard, hdmi display, 5V/2A DC power supply, Ethernet
3.Install onto enclosure
##Step-2: configure wifi1.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
##Step-3: install bluez1.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/
##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)
##Step-5: install Bluemix/NODE-RED1.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
##Step-6a: edit NODE-RED1.Add a dummy input node
- Drop “rpi-gpio” to main pane; double-click it- Fill as below diagram (pin number is arbitrary)
##Step-6b: edit NODE-RED1.Add an exec node
– Drop “exec” node to main pane; double click it– Fill in the program name
##Step-6c: Edit NODE-RED1.Add switch node
– Drop “switch” node to main pane; double click it– Fill in the filter criteria “Boss Detected”
##Step-6d: Edit NODE-RED1.Add twitter node
– Drop “twitter” node to main pane; double click it– Click the pencil, to add your twitter credential
##Step-6e: Edit NODE-RED1.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”
##Step-4: Configure reboot1.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/download && 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
##Step-4: Install-Check1.Pack it in enclosure
2.Install it silently with 5V/2A DC
3.Check your twitter, if your boss approaches
##Remark1.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!