loading
This project will allow you to trigger an action (like serving coffee) once a WiFi client is detected in a WiFi network (like when you or your employees get to your office).

Step 1: Setup Your Intel Edison

Connect the two usb cables from your computer to the Edison board (one for power, one for serial data). In OSX, open a serial connection to the board from your terminal:

screen /dev/tty.usbserial-AJ035OK6 115200 -L

The default Edison login is root. Once you're in, configure the wifi network:

configure_edison --wifi



Let's add the sources list to be able to download packages from the Edison. Open this file:

root@edison:~# vi /etc/opkg/base-feeds.conf

And add these lines to it (type "i" to be able to insert text in the vi editor):

src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/edison
src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32

Then update the sources and install the required libraries for our project:

root@edison:~# opkg update

root@edison:~# opkg install libmraa0 nano

root@edison:~# opkg install python-pip

root@edison:~# curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | python

root@edison:~# pip install ubidots

Done! now we're ready to code.

Detect when I arrive to my office

We'll use the Scapy packet sniffer to be able to detect ARP traffic in the local wifi network. Scapy is a great tool that allows you to handle network packets from the ease of a Python script. Without it, we would have to parse lots of binary code when sniffing network traffic.

Our first script will look out for MAC addresses stored in a csv file called "dictionary.csv", and then send the value "1" to a Ubidots variable, meaning that the person arrived. If the MAC address is seen for the first time, then the script will automatically create a Ubidots variable to store the data.

Note the line:

sniff(prn = arp_count, filter="arp", store = 0)

which triggers the function "arp_count(pkt)" every time an ARP packet is sniffed. That function is where we fire multi-processes to update the Ubidots variable.

The reason I used Multiprocessing is because I needed a parallel function so that, if two users arrive at the same time, then both packets can be sniffed and updated in Ubidots.

The option "store = 0" is very important because otherwise the packets would start filling the Edison's RAM and Swap memory and it would freeze after a few hours.

https://halckemy.s3.amazonaws.com/uploads/document/file/46958/dictionary.csv

https://halckemy.s3.amazonaws.com/uploads/document/file/46543/wifi_sniff.py

Step 2: Trigger a Servo When the ARP Packet Is Sniffed

The second script will poll that Ubidots variable all the time (the one we are sending "0" or "1" to) and activate the servo when the variable is equal to "1". I'm using the MRAA library (suggested by the Intel folks) which allows you to handle all the GPIO pins of your Edison from the Linux shell or a python script (really, no need to code in Arduino!). This allowed me to quickly handle a Servo motor from Python.

https://halckemy.s3.amazonaws.com/uploads/document/file/46556/pour_coffee.py

The Servo is attached to pin D3 in the Grove Kit. You can setup this Servo to trigger any physical valve, like a coffee machine. I made a simple cup holder for the sake of the demo.

Btw you can also create a "Switch" in your dashboard and control the coffee pourer manually:

Step 3: Please Vote

Please vote!!!

For the video: https://vine.co/v/emjaE9HUzg9

About This Instructable

1,353views

10favorites

License:

Bio: Just an ordinary teen who likes to work with Arduino and other programming electronics and 3D Printers
More by Slk_Stephane:Arduino Car Controlled Via Bluetooth App CardBoard the Hero (Solar Powered) Portable Potty 
Add instructable to: