Introduction: Edison Makes Me a Coffee (code)

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
src/gz edison
src/gz 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 | 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.

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.

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:
Epilog Contest VII

Participated in the
Epilog Contest VII

Intel® IoT Invitational

Participated in the
Intel® IoT Invitational