The Arduino Yún is a curious addition to the Arduino family. There is a fairly widespread community surrounding the Arduino concept, platform and software. There's another popular community dedicated to hacking and improving inexpensive wireless routers, which often run Linux. The Yún combines the two...it's basically an Arduino Leonardo housed on the same PCB as an Atheros AR9331 wireless router (commonly found in TP-Link and other popular hackable routers). They're connected through a serial port and run independently, but the Linino team has developed a few ways to make them team up on some tasks.

Recently, we created our first Kickstarter campaign (RGB LED Shades). It's very exciting to see the "New Backer Alert!" emails roll in, and the notifications pop up on a smartphone. But we wanted to see our Kickstarter stats at a glance, and be notified whenever we have a new backer. The Linux side of the Yún can run scripting languages such as Python to scrape website data and control an LED marquee sign, and the Arduino side can control some I/O for an impossible-to-ignore new backer alert.

The following is a fairly complete guide to getting a Kickstarter tracking system up and running, as well as some details on using Python with the Arduino Yun.

Step 1: [Hardware] Statistics Display

We wanted to see the current total pledge amount, the current number of backers, and the percent our project was funded, so we needed some kind of display. We already had a Pro-Lite PL-M2014R LED Marquee display, a flea-market score with no remote, cables, or manual. It isn't made anymore (this one was likely made around 1992) but with some cable hacking and an old Playstation 2 power brick, it works great. It has an RJ12 jack that is NOT a phone jack, it is an RS232 access port. Fortunately the communication protocol is well documented by people on the internet (what isn't?). We built a DB9 to RJ12 adapter cable based on these instructions.

Step 2: [Hardware] Biggest Possible Alert Light

When we receive a new backer, we want to know about it right away. Enter another flea market score: a 120VAC green arrow traffic signal. These have to be visible during the day, so they're extremely bright and easy to see across an intersection, let alone an office.

Arduino and Linux go together like peanut butter and jelly, but neither can directly control this LED monster. We used a PowerSwitchTail 2 from Adafruit (also available from the Maker Shed, Sparkfun, Jameco, and many others). This device can switch AC power from a microcontroller pin, with isolation and no exposed AC wiring.

Step 3: [Hardware] Arduino Yún

Finally, the brains of our project. The Arduino Yún will connect to the wireless network, access information about our Kickstarter campaign, format the data and put it on the LED marquee, check whether there are new backers, and if so alert us to that fact. It's available from a wide range of distributors including Adafruit, Sparkfun, and the Maker Shed. We're securely mounting it to a piece of scrap plywood with screws and zUNO Clips from Digilent.

Step 4: [Hardware] FTDI Cable, Piezo, and Wiring

We're at a fork in the hardware planning process: the Pro-Lite sign could be controlled from either the Arduino side, or the Linux side. The Arduino has TTL-serial ability, so we'd need to build or buy an RS232 level converter, but the Yún's Ethernet port may be too tall for some premade shields. Linux on the Atheros chip can handle serial communications, but it doesn't have any pins available for that. However, it does have a USB host port. The simple/fast solution was to plug a USB-to-RS232 cable with FTDI chip into the USB host port.

We also wanted some audio notification, and rummaged through a junk box to find a small piezo speaker salvaged from an old computer.

With that solved, it's a matter of mounting and wiring everything correctly.

Output to LED marquee sign: FTDI USB-to-RS232 cable plugged into Yún USB host port. DB9 to RJ12 adapter cable runs from the FTDI cable to the LED marquee's RJ12 jack.

Output to LED traffic signal: PowerSwitch Tail "+in" wired to Yún digital pin 12, "-in" wired to Yún GND. We built a small WingShield-like terminal adapter using a piece of PCB cut from a failed prototype. The PowerSwitch Tail is plugged into a wall outlet, and the LED traffic signal is plugged into the other side of the PowerSwitch Tail.

Output to Piezo speaker: Piezo wired between Yún pin 10 and Yún GND.

USB Power Cable: The preferred power input to the Arduino Yún is a micro-USB cable. We have this running to a USB phone charger plugged into a wall outlet. This cable needs to be supported securely with no stress on the micro-USB connector, as the Yún's connector is prone to twisting off from the PCB (permanently).

Step 5: [Hardware] Prop It Up Somewhere Visible

Even though most of the electronics are mounted neatly on a piece of plywood, it's still a bit messy. The electronics are held in place with a super magnet, the LED marquee is resting on the shelf, and the LED traffic signal is held in place with hook-and-loop dots. This is enough for a temporary project, though.

Hardware is only half of this project, though. Next, we need to configure all the necessary software to get the required functions running.

Step 6: [Software] Configure the Arduino Yún

Before proceeding with any other actions, the Yún must be configured to work with your wireless network correctly. You should be able to, while connected to your home network, surf to http://arduino.local, see the login page above, and know a password that you can use to successfully log in. The Yún will also work on a wired Ethernet connection, but the steps below should still be followed.

If your Yún is fresh out of the box, you'll need to follow all of the steps below:

  1. Get the USB drivers installed
  2. Configure the wireless network
  3. Download and install Arduino 1.5.x (1.0.x branch will not work)
  4. Upgrade the Yún Linux firmware (optional but recommended)

Once that's done, you can use the Arduino 1.5 IDE to upload a Blink example sketch, or test one of the Bridge examples to verify network connectivity. If everything looks good, then the remaining Instructable steps should work.

Step 7: [Software] Log in and Install Needed Software

The Arduino Yún's Linux process is pretty full featured...it's possible to log in to a console and perform maintenance tasks. You will need a way to SSH into the Yún. On OSX and Linux the "ssh" command should already be available. On Windows you will need SSH software such as PuTTY.

The Yún user account (by default) is root. In fact, the Bridge script (used to communicate between the Arduino and Linux processors) runs as root, and everything it does (including scripts and processes you execute from Arduino code) is run as root. This makes a lot of things easier, which isn't always a good thing...it would be possible (easy, actually) to write Arduino code to brick the Linux side of things quite thoroughly, for example. Or attack other computers on your network. But increasing security on this device might require another Instructable.

We need to install some extra software for this project; fortunately it's very easy. We need to install a version of Python that supports SSL (Kickstarter uses HTTPS), add support for the FTDI cable, and we need to add Python support for serial communication.

Run each of the commands below, making sure there are no errors and they install successfully.

opkg update
opkg install python-ssl
opkg install kmod-usb-serial-ftdi
opkg install pyserial

Step 8: [Software] Upload "kicktracker.py" Script


import sys,urllib,json,serial,time

prolite = serial.Serial("/dev/ttyUSB0", baudrate=2400, bytesize=8, parity='N', stopbits=1, xonxoff=0, rtscts=0)

# get kickstarter stats url and goal amount

if len(sys.argv) > 1:
  url = sys.argv[1]
  goal = int(sys.argv[2])
  sys.exit("Missing arguments")

# receive data from url
r = urllib.urlopen(url)

# grab json data structure
data = json.loads(r.read())

# parse needed data
pledged = int(float(data['project']['pledged']))
backers = data['project']['backers_count']
percentfunded = pledged / float(goal)

# output data to console / Arduino
# integer pledges / currency-formatted pledges / backers / percent funded
print str(pledged)+'/'+'${:,}'.format(pledged)+'/'\

# write data to Pro-Lite PL-M2014R display
prolite.write("<CC><FI><SA>Backers: ")

The Python script above receives two arguments, a Kickstarter stats URL, and the campaign goal (because that info isn't available in the stats URL we're using). The stats URL returns a JSON response, which we can easily process for the needed data. The returned JSON data looks something like this:


The extracted data is printed to the console (which is fed directly back to the Arduino side), and also sent through the serial port with various formatting commands according to the Pro-Lite protocol.

There are several ways to get the kicktracker.py file into the Yún. It's recommended to place files in a micro-SD card, but since this is such a small script we dumped it directly into root's home folder. You could use the "nano kicktracker.py" command and then paste the code from the console, Ctrl-X and then Y to save and exit. Alternately you could transfer the file over SSH from your local computer using a command like this:

scp kicktracker.py root@arduino.local:kicktracker.py

This has to be done from your local computer, not typed into the Yún's console. The command above should work on OSX and Linux, for Windows you will need to use an FTP program that supports transfer over SSH (FileZilla is one).

Step 9: [Software] Upload Arduino Sketch

The attached Arduino sketch will run the "kicktracker.py" process, receive the returned data, parse it for desired information, and perform any other required actions. Currently, it only monitors the number of backers and triggers a celebration (fanfare music and flashing LED traffic signal).

Some interesting excerpts from the code (download the attached ZIP file for runnable code):

Process p; // Create Process object
p.begin("python"); // Start Python p.addParameter("/root/kicktracker.py"); // Run the kicktracker.py script p.addParameter("https://www.kickstarter.com/projects/macetech/rgb-led-shades/stats.json"); // Specify the Kickstarter stats URL p.addParameter("12000"); // Specify the Kickstarter goal amount p.run(); // Run the process

The above code actually runs the "kicktracker.py" script from the previous step. It starts Python, supplies the name and location of the script, provides the Kickstarter stats URL, and the campaign goal amount (since that information is not part of the returned data).

// Read incoming bytes and split into strings when forward slash is found
// (Stream).readStringUntil() does not seem to work here while (p.available() > 0) { char c = p.read(); if (wordcount < 5) { if (c == '/') { wordcount++; } else { switch (wordcount) { case 0: pledgedRawStr += c; break;

case 1: pledgedFormattedStr += c; break;

case 2: backersStr += c; break;

case 3: percentFundedFormatted += c; break; } }

} }

The above code will parse the data sent by the kicktracker.py script, which will be strings separated by a forward slash. At the moment, only backer data is used by the Arduino, but other actions could be tied to the data (stretch goals reached, a new comment, etc).

Please download the attached zip file for the full code listing.

Step 10: Conclusion

Here's the final result: every 60 seconds, the Yún will ask Kickstarter for statistics. It will keep streaming the pledge and backer data over the LED marquee, and if there are more backers since the last check, it will play a fanfare and flash the big LED traffic signal.

This was a fairly painless project, as we've had a good amount of both Arduino and Linux experience, plus some previous hacking around with cheap wireless router firmware and Python scripting.

The code and hardware works as advertised, though of course there is room for improvement. We could add some error handling in case a network connection isn't available; we could modify the OS for more restrictive security settings (stop running all Bridge processes as root). We could also add some special modes for when stretch goals are reached, or add some sad music if a backer cancels their pledge.

For now, it's fun to hear the happy bleeps and get temporarily blinded by the traffic signal every time someone backs RGB Shades!

Please leave comments if anything in this Instructable is inscrutable. And if you make something similar, we'd love to check it out!

<p>very very nice </p>
Smart idea! Thanks for shearig :)
<p>5 for trying! </p><p>But what about bear market? ))</p>
<p>Nice work,is there a way i can wire up and led to be notified for new emails and social media notificatons ?</p>
<p>Absolutely! The Arduino Y&uacute;n comes with a few examples to do exactly that, using a service called &quot;Temboo&quot; with their &quot;Choreos&quot; services. However, they don't have a Kickstarter Choreo so we needed to use the homegrown approach.</p>
<p>Nicely done. Thanks for sharing this!</p>

About This Instructable




More by macetech:Super-Sized Musixel Wall Save 81 Seconds: Fast Arduino Bootload/Program for Production Kickstarter Backer Alert with Stats Scroller, using Arduino Yun 
Add instructable to: