Tuesday, March 10, 2015

Make a Twitter-controlled desk lamp with open source tools

http://opensource.com/life/15/3/internet-of-tinkerers-twitter-desk-lamp

Image by : 
opensource.com
Think about the Internet today. Websites and web services are in deep conversation with each other through the so-called API (Application Program Interface) economy. Websites such as Facebook, Weather.com, and ESPN all offer APIs that the rest of the cloud can leverage and interact with.

Through this API economy, the exchange of data is free-flowing and massive.

However, the only things that are taking part in this conversation are typically computers, laptops, and smartphones. What happens when other electronic devices can start to take part in this data exchange?

This is a question that has been answered by the open source community. Through open source hardware and software, developers have created embedded solutions that can leverage these pre-existing APIs. This means developers can blink an LED when a package arrives by querying FedEx.com, or data-log accelerometer sensor values to Dropbox or Google drive, or call your cell phone when water is detected at the bottom of a faulty water heater.

Twitter-controlled desk lamp

Open source tools and Twitter used can be used to control a desk lamp:
  • SimpleLink™ Wi-Fi® CC3200 LaunchPad wireless microcontroller (MCU) from Texas Instruments
  • Digitally-controlled Relay
  • Energia IDE for developing embedded firmware
  • Node-RED graphical programming tool for developing cloud-side applications
Several open source tools come together to create a simple cloud-controlled appliance. With the relay, developers can control common household equipment such as a desk lamp or coffee maker. In addition to being open source, the hardware above can be attained for less than $40 USD. This is an example of how the barrier of entry has been lowered for enabling the Internet of Tinkerers. With easily accessible hardware and open source tools, developers are able to leverage existing designs and perhaps even add their own unique twist and contribute back to the community.
How to: Twitter controlled desk lamp
Twitter-controlled desk lamp, less than $40 of open hardware, enabled by free and open source software.
Let’s take a closer look at this example.

Role of the cloud

First, we need to leverage the Twitter API to check for any public tweets that features the hashtag #myLight. To do this, we are going to use an open source graphical programming tool called Node-RED. Node-RED is a graphical environment based on Node.JS, which enables developers to “string together the Internet of Things” through graphical nodes that can be wired together.

To query Twitter, this application uses the “Twitter” node that is available in Node-RED’s palette of nodes. The Twitter node periodically pings Twitter using the Twitter APIs. If the Twitter node sees a public tweet that features the desired hashtag, the entire Twitter string is returned and sent to the next node. The next node in our Node-RED “flow” is a generic JavaScript function node. When this JavaScript function node is double-clicked, developers are presented with a full JavaScript IDE (integrated development environment). At this point, open source code can be copy and pasted into the IDE that will enable us to parse the incoming Twitter string. To find this code, I simply searched the Internet for, “parse string JavaScript code example." And, lo and behold, there were dozens of example code waiting to be leveraged. With this code example, we were able to see if the string includes a specified keyword (e.g. ON or OFF). If so, this JavaScript function node can return a ‘1’ or a ‘0’ to the next node that is connected in the flow—the MQTT node.

MQTT is a standardized publish/subscribe communication protocol for the Internet of Things. In this example, the node-RED-based cloud application can publish a ‘1’ or a ‘0’ to a subscriber. In this case, the subscriber is an Internet-connected MCU development kit, called the LaunchPad. The LaunchPad is one of many available microcontroller development kits that are open source hardware.

The schematics and design files are all available for download, which makes it easy for developers to productize or manufacture their own if desired.

Role of open hardware

The LaunchPad in this example has been programmed using Energia, an open source, community-driven IDE. Using an open source MQTT library, the LaunchPad has been programmed to subscribe to the ‘1’ or ‘0’ message that the cloud-based application is publishing to. If a ‘0’ or ‘1’ is received, the LaunchPad can toggle the pin that is connected to the relay to open or close the circuit. Energia offers a wide range of easy-to-use APIs that are documented online, which enable developers to control the many input and output pins that are available on the LaunchPad target MCU.

The Internet of Tinkerers
Refrigerators that tweet, sprinkler systems that check the forecast, and thermostats that sync with your phone are starting to become viable and available solutions at big box retailers. Products beyond the cell phone in our pockets or the tablet on our coffee table are just now starting to get connected to the all-knowing cloud. However, Internet-enabled homes are nothing new and homebrewed solutions have been around for years, many of which are open source and fully documented on websites and forums, ready to be duplicated.

While the Internet of Things (IoT) is a trending topic as we enter 2015, it is arguable that the Internet of Tinkerers is something even bigger. These communities of tinkerers are the first dominoes. Not just the early adopter, but the people who conceive and create innovation. The Internet of Tinkerers has paved the way for the Internet of Things, and concepts such as crowdfunding, open source hardware, and free, stream-able on-demand education will only accelerate more waves of new ideas and their fulfillment through rapid prototyping. In this article, we will explore how these concepts will lead to the inevitable fruition of the Internet of Things and beyond.

As the Twitter-controlled desk lamp demonstrates, the Internet of Tinkerers has enabled a vibrant community of re-usable hardware and software building blocks. These open source tools have lowered the barrier of entry towards innovation. With open source tools like Node-RED, traditionally hardware-savvy developers can do meaningful things in the cloud, like ping Twitter or other cloud services through abstracted visual nodes. Conversely, open source tools such as the LaunchPad MCU development kit, paired with the Energia IDE, are enabling traditionally software-only developers to interface with embedded hardware that can interact with the real-world through sensors, actuators and more.

As open source tools continue to make powerful technology more accessible, problem solvers in industries outside of engineering and computer science will have access to tools once only available to traditional engineers and computer scientists. With this accessibility to new tools and hardware, healthcare workers can potentially solve problems only they have visibility to and the experience to fully understand and comprehend. Assembly line workers or industrial plant employees can help to make processes more efficient. Teachers can explain complex concepts to students in new ways through innovative mediums.

Open source hardware and software is revolutionizing the way people across all industries solve problems and the community of the internet of tinkers are going to support each other within and across industry lines.

No comments:

Post a Comment