Chuck Norris and the Internet of Things

In my last post I covered my experiences setting up the Intel Edison board and interfacing with the LCD and temperature sensor, but ran into a #fail when trying to make a REST call on site at the Intel IoT Roadshow in Somerville.

The issue was certainly network related and site-specific – a redirection to what would probably have been a network credentials dialog – but it wasn’t happening to everyone.  My resolution then was to call it a day and give it a shot at home… where it just worked.

Chuck NorrisIt occurred to me though that getting the current temperature from a web service was booooring, so rather than show you that, I opted to build the first ever (?) Chuck Norris IoT device!

ICNdb

These days there’s an API for everything, and who’d dare deny Mr. Norris his spot in the cloud! Yes indeed, there is an API targeting – what else – the Internet Chuck Norris Database. It’s a simple RESTful API that requires no registration or API keys making it quite easy to access. For instance, in your browser just navigate to

http://api.icndb.com/jokes/random?exclude=[explicit]

and you should get back a bit of JSON that includes a short joke. Feel free to leave off the query parameter if you’re ok with potentially NSFW material being returned.

Invoking the API in Node.js

Node junkies know this stuff like the back of their hand, but I had to reacclimate myself to the purely async nature of the execution flow. Basically, you provide the URL you want to fetch and then a callback routine that processes once the request has completed.. like:

  • linifyJoke takes the joke string and divides it into an array of strings that are no more than 16 characters each to facilitate display on the LCD.
  • outputLines takes that array and the current line to be output and successively writes the lines to the LCD with a delay so you can read through the joke.

There’s nothing magical about that code (and I covered writing to the LCD in my last post), but if you want to view all the gory detail, I’ve included the entire script in this gist.

On-demand Joke

Once you’ve heard one Chuck Norris joke, you’ll find you can’t get enough of them, so I realized I need to beef up my implementation to allow you to request joke after joke.

Enter the button sensor from the Grove Starter Kit. The button returns a high voltage (1) when pressed and low (0) when released, so getting the button state is a simple read from the GPIO context that’s exposed by the mraa interface.

You’ll need to continuously poll for the press though, and when pressed carried out the desired action – perhaps ignoring, as I do, subsequent presses until the current request is complete.

Here, processingRequest is a sentinel value that prevents reentry to showJoke, with the outputLines method mentioned earlier having the responsibility for resetting the flag once the current joke has finished displaying.

This is not Vaporware!

New England GiveCamp 2014

Pay no attention to the mounds of snow; spring is on its way and with it comes the 5th Annual New England GiveCamp. Once again – from April 4th through the 6th – Microsoft’s New England Research and Development (NERD) Center will play host to 120 or so software developers, designers, project managers, and non-profit representatives as they convene for a 48-hour “hackathon” focused on projects to help the charitable organizations better meet their goals.

GiveCamp has been the success it is because of three main ingredients, giving each of us a chance to contribute:

Non-profit organizations. Each year around two dozen non-profit organizations are on site with project needs including website creation or redesign, mobile application development, logo and graphic asset creation, database design, and more. This year more than 30  applicants are already in the midst of the vetting process, so at this point any new submissions will be put on a waiting list.

Sponsors. The majority of the expenses for this event are the cost of food (six meals and snacks) and beverages (yes, lots of caffeine) to keep the attendees fueled throughout the event. We’re always looking for additional cash donations or donations-in-kind to defray these costs and enable more organizations and volunteers to participate. Please visit the sponsors page at the GiveCamp website for details on how you or your company can help.

Volunteers. Got the weekend of April 4-6th free and want to lend your talents to some amazing local organizations? Sign up as a volunteer, and you’ll be placed on a team of folks focused on a project for a participating charity. Depending on your background and project needs you might be able to assist on multiple projects! All we ask is that you bring your enthusiasm, willingness to learn (potentially) new things, and the ability to commit to participating for the duration of the event. You can even camp out at the facility – though that’s not a requirement!

It’s a fantastic event; you’ll make new friends and be a part of making a difference in the New England community at large. Be sure to follow the event on Twitter and Facebook, and if you have any questions on the event itself, reach out to the coordinators at negivecamp@hotmail.com.

Boston Code Camp – Oct. 19th

Boston Code Camp

Boston Code Camp is just around the corner – another chance to attend your pick of nearly 30 sessions on topics ranging from Windows 8 to Azure to Neo4j and have the opportunity to network with over 200 area technologists.

This is the 20th edition of the Boston Code Camp, and like all its precursors, the event is completely free to attend, courtesy of sponsors such as ComponentOne and Microsoft. The event will be held at Microsoft’s New England Research and Development Center (NERD) on Saturday, Oct. 19th, from 8:30 a.m. to 6:30 p.m., and registration is now open.

For those traveling by car, note that the event coincides with the Head of the Charles Regatta which may result in additional traffic flow and travel time.  Additionally, the Longfellow Bridge is currently under construction and allows only one-way traffic from Cambridge to Boston (see detour map). For those travelling east on Memorial Drive and intending to use the left exit to Kendall Square, note that due to MIT construction, Wadsworth street is closed, but the detour on Ames Street to Amherst Street will lead you to the NERD building (see detour map).