IN THIS ARTICLE
Subscribe to Our Newsletter
Originally designed to be a small and inexpensive computer for students and hobbyists to play around with, a whole new world has recently opened up for the Raspberry Pi: The Internet Of Things.
As Raspberry Pi makes solid inroads into its original consumer markets, this exciting new market of IoT is developing fast. In many cases, the Raspberry Pi has become a “go-to” device for adding brains to embedded and autonomous devices. For example, startups have started using the device to offer a connected house for a new living experience.
With the Raspberry Pi 2 moving into these dramatic new use cases, it has become more and more clear that a hardware upgrade is necessary – the original tech specs just aren’t sufficient for applications and systems with growing sophistication.
In this article we review the changes brought to you in the new Raspberry Pi 2, and give you a glimpse of how it can be used to create connected applications using PubNub.
Raspberry Pi 2: What’s New
The Raspberry Pi lineup has evolved significantly over the past couple years. The original Raspberry Pi has two derivatives: the model A and B which have both been upgraded to A+ and B+ over time, with the “B” model being the more performant device.
Now in 2015, Raspberry Pi has released a new device: the Raspberry Pi 2 Model B. It replaces the first generation model B+ (although the first-generation devices will be available for quite a while to provide stability in industrial/consumer products).
So what’s new in the new Pi 2?
Let’s actually start with what did not change.
Form Factor and Connectivity
The form factor is the same. This is a key element which not only insures compatibility with the previous model (and related hardware) but underlines Raspberry Pi’s goal to keep their computer within a minimal size: no bigger than a credit card!
This choice allows the Raspberry Pi 2 to still be a first choice in integrating a computer into your coffee machine or any sensor and embedded use case you can think of. The Internet of Things is growing rapidly, and Raspberry Pi is poised to be a key actor in the revolution of our daily lives.
When it comes to connectivity, not a lot has changed: 4 USB plugs, a 3.5mm audio jack, a microSD port, an HDMI plug and 40 GPIO pins.
Note that the one thing missing from the Raspberry Pi 2 is WiFi connectivity. Although it wouldn’t be surprising to see an integrated WiFi antenna soon, one can still buy a compatible WiFi or Bluetooth dongle: there are 4 USB ports, might as well make good use of them!
These all seem like reasonable and straightforward technical specs, but what does the Raspberry Pi 2 bring to the table?
Dramatically Increased Performance
CPU and RAM
The biggest change with the new Raspberry Pi 2 is its raw performance. The Raspberry Pi has always had somewhat modest specs, however these new upgrades allow the Raspberry Pi to achieve much more with its computational power.
The RAM has been upgraded from 512MB to 1GB. Not bad, that’s about a quarter of the RAM a top-end Apple MacBook Air provides.
But the biggest update is the CPU: a Broadcom BCM2836 ARMv7 Quad Core Processor running at 900MHz. Raspberry Pi claims it is in average about 6 times faster than the previous model. Not bad. Tech reviewers like to compare that increase to what would have been expected from Moore’s Law. Raspberry Pi achieved 6x instead of 4x over 3 years.
People have already built clusters and “supercomputers” by wiring 64 Raspberry Pis together. Think of what can be done now!
Last but not least, the new CPU will allow to use more varied OS. The most commonly used OS being Raspbian, a Raspberry Pi flavor of Debian Wheezy, is seeing an expected competitor: Snappy Ubuntu Core. It’s still early to see whether Canonical’s OS will become the most used OS for Raspberry Pi, especially considering their current success for Linux machines.
However Ubuntu is not the only new OS compatible with Raspberry Pi 2. Somewhat surprisingly to us, Windows 10 will also be supported on the device!
This was surprising to us at first, but what it really reveals is that Windows is also trying to be part of the race to the Internet Of Things market, and everyone is betting on the Raspberry Pi. It’s a safe bet to use Raspberry Pi 2 as a target platform when developing new embedded and sensor applications.
So with Raspberry Pi 2, we have a new platform with improved hardware capabilities. One challenge that remains is in the configuration, connection and coordination of embedded devices.
This is where PubNub comes in.
PubNub and Raspberry Pi 2
If we take a moment and take a step back, we see that the Raspberry Pi 2 has overcome one of its biggest weaknesses: very limited computational power. This creates a new horizon of possibilities. But it also requires us to rethink the architecture of our connected system.
In the past, a large share of connected devices have been merely actuators connected to bluetooth or WiFi. Any type of larger computation requires a dedicated central device, a brain to control all the connected appliances. This causes many issues, the first one being the dependence of all the devices on one machine – a potential bottleneck and single point of failure.
Now that the Raspberry Pi offers extended computing capabilities at a low price point, connected devices using Raspberry Pi are able to enjoy greater independence and autonomy. The need for a master device is greatly reduced, and may be reserved for the most computation-, energy- and network-intensive use cases.
The first-generation Raspberry Pi was already able to perform tasks such as facial recognition, now that its performance is 6 times faster, there is so much more we will be able to do!
The missing link is command, control, coordination and communication.
It’s easy to imagine that a large share of these devices will be monitored and controlled from your smart phone, and even smart watches in a growing number of use cases. PubNub offers a very easy way to have all these devices connected and communicating with one another.
How PubNub Works
You can picture a PubNub channel like a room. When you want to say something to the people (or other devices) in the channel, you publish a message. On the other hand, if you want to listen to what people (and devices) are saying in the channel, you subscribe to the channel and pass it a callback function to receive the incoming message data. Whenever something happens in the channel, such as new messages being sent or people leaving or entering, the application will be notified via the callback functions that carry the new message data.
This system allows all types of devices to subscribe to PubNub channels and the number of supported languages is enormous. Any Raspberry Pi device with access to WiFi can share its status and send messages to a PubNub channel. PubNub serves as a realtime communications backbone among all devices, eliminating the need to configure each device to communicate in an ad-hoc network.
An Example: Home Automation
Let’s look at a brief illustrative example using the connected home as a use case. Let’s imagine an alarm clock app on your phone is installed and connected via PubNub. As soon as the alarm goes off, the app sends a message to the room’s light (possibly a Philips Hue or similar device) which will gradually turn on. Earlier that morning, the app notified the thermostat in the bathroom to turn up, allowing for a more graceful morning without having to race through the cold to the shower. Motion detectors, home alarm systems and/or connected light bulb status may be used to infer room occupancy.
This information is sent via Raspberry Pi to a PubNub channel to trigger switches in IoT-enabled devices, such as the all-important coffee machine. When the coffee is finished, fill the dishwasher and close it. The dishwasher also has a Raspberry Pi or similar device connected to it, so it may start as soon as everyone has left the house. To signal departure, a garage door “open and close” event accompanied by a car “ignition on” event and a geofencing “out of range” event means you’re on your way!
These possibilities are compelling – with the Internet of Things, our surroundings are developing the capability to interact with and adapt to us, where previously it was the other way around. PubNub allows developers to start doing this with minimal coding and integration. You can get your own subscribe and publish keys for free here, start coding and connect your devices together.
The Raspberry Pi 2 is available now and the platform is bound to evolve even more rapidly in the months to come. Give the Raspberry Pi 2 a try with PubNub, and let us know how it turns out. Check out our Raspberry Pi 101 blog series, or our extensive library of Raspberry Pi tutorials!