Cayenne for Raspberry Pi

Lead Image © realmccoy, 123RF.com

Easy IoT

New to the whole Internet of Things (IoT) idea? The Cayenne platform provides a friendly gateway to the world of IoT. Built specifically for Raspberry Pi, this IoT platform can help you transform the little machine into a versatile IoT device and put it to some practical uses.

The IoT is one of the most hyped technologies at the moment. Established manufacturers and start-ups alike are doing their best (and sometimes their worst) to capitalize on the trend by bringing us everything from smart light bulbs that can be controlled via the Internet to toothbrushes that post updates when you brush your teeth. While the future may look bleak for some of these products, the underlying idea of turning dumb hardware into intelligent devices does sound sensible. And if you decide to dip your toes into the IoT waters, the next logical question is where do you start?

A number of IoT platforms are in circulation, but Cayenne [1] is a good choice for a number of reasons. First, it's designed to work with Raspberry Pi (Rasp Pi), so it allows you to use your favorite single-board computer as an IoT device. Second, Cayenne developers went to great lengths to make the deployment process as easy and smooth as possible. Third, the entire platform is designed to be easy to use, so you can devise simple and complex projects with a minimum of effort and without any coding.

The Cayenne platform consists of four key components. The Cayenne agent software runs on the Rasp Pi, and it's responsible for communicating with the server as well as managing incoming and outgoing commands, triggers, and alerts. The Cayenne cloud processes and stores user and sensor data from the device, while the online dashboard provides a graphical environment for working with your IoT project, as well as monitoring and managing the Rasp Pi. Finally, the Cayenne app for Android and iOS is used to set up and manage Cayenne on the Rasp Pi.

Installing Cayenne

The first step is to install the Cayenne agent on the Rasp Pi, and the easiest way to do this is to use the Cayenne app for Android or iOS. Start by installing the app on your mobile device from either Google Play Store or the App Store. Make sure that the Rasp Pi running the full version of the Raspbian system is properly configured and connected to the Internet. After ensuring that the mobile device and Rasp Pi are on the same network, you then launch the Cayenne app. Create a new Cayenne account and then use the Find Raspberry Pis button to find the Rasp Pi on the local network. If the app fails to do that, you can use the Search with an IP address option to specify the Rasp Pi's address (Figure 1). Once the Rasp Pi has been detected, you provide the username and password and hit Setup. Once the setup process finishes, you are done.

Figure 1: The Cayenne app makes it supremely easy to install Cayenne on the Rasp Pi.

Instead of using the app, you can install Cayenne on the Rasp Pi in a more traditional way: from the terminal via a secure shell (SSH) connection. To do this, log in to your Cayenne dashboard using a browser and create a new project by pressing the Plus icon next to the Cayenne title. From the Add new drop-down list, select Device, choose Micro Computer | Raspberry Pi, and press Generate new Raspberry Pi installer. This generates commands for downloading and running the installer script. After establishing an SSH connection to the Rasp Pi from your Linux machine, you use the provided commands to install Cayenne.

Getting Started with Cayenne

Once Cayenne is up and running on your Rasp Pi, you can use both the Cayenne app and the online dashboard to access and manage the device as well as build projects. When you log in to the dashboard (or launch the app), you are immediately dropped into the Overview section (Figure 2). For your convenience, Cayenne automatically adds a couple of default widgets, so you don't have to start from scratch. The default widgets include Memory, Processor, Storage, and Network gauges that let you monitor your Rasp Pi's vitals. By clicking on the Settings icon (it looks like a cog) in the upper-right corner of a widget, you can tweak the available settings. Instead of the gauge, you can choose either the Value or Graph widget, and you can specify the minimum and maximum thresholds. The Details & Chart icon sitting next to the Settings icon allows you to peruse detailed info about the monitored resource and study a graph of the received values. In the Memory widget, for example, the overview shows a pie chart and a lowdown of memory usage, along with a chart displaying memory usage over time (Figure 3). On a side note, you can rearrange widgets in the overview area by dragging them with the mouse.

Figure 2: Cayenne dashboard.
Figure 3: Each widget in Cayenne features a detailed view with a chart.

The commands in the dedicated palette in the Overview section of the dashboard can be used to reboot and shut down the Rasp Pi remotely. Better still, the Remote Access command allows you to access the Rasp Pi's desktop remotely (Figure 4). By clicking on the Remote Access link, you can work with the Rasp Pi's graphical desktop environment directly in the browser.

Figure 4: Cayenne gives you remote access to the Rasp Pi's desktop.

General purpose input/output (GPIO) is an important part of the Rasp Pi's functionality, and Cayenne features the dedicated GPIO tab that allows you to monitor and control GPIO pins (Figure 5). Among other things, you can see and change the state of each pin. For example, by wiring a simple LED circuit to the GND pin and GPIO22 pin, you can turn the LED on and off by toggling the state of pin 22.

Figure 5: The GPIO section allows you to control individual GPIO pins.

While you can use the GPIO section to control the LED (or any peripheral connected to GPIO pins for that matter), it's hardly the most sensible way to do this. A much better approach is to create a dedicated widget in the dashboard for that. Switch to the Overview section, choose Device from the Add new drop-down list in the left sidebar, switch to the Actuators | Light section, and choose the Light Switch item. Then configure the widget as shown in Figure 6 and press Add Sensor.

Figure 6: Adding a light switch.

You can then turn the LED on and off using the created widget. Now imagine that instead of a single LED you have a series of light switches that control the lights in different rooms of your house. You can add widgets for each light switch and control the lights from the convenience of the Cayenne dashboard.

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Power to You

    Small-board computers (SBCs) are getting more and more powerful. The Raspberry Pi 3 (RPi3), which just came out in February of this year, is a case in point. This latest in the Rasp Pi line now has four cores running at 1200MHz with 1GB of RAM and on-board WiFi and Bluetooth. If you need even more power in a small computer, however, you are not left wanting. In this issue, we look at three SBCs with more cores, more memory, more ports, and more possibilities.

  • Building a Raspberry Pi greenhouse

    A greenhouse environment has to be just right. The temperature can't climb too high or sink too low, and the plants need water. Why not put your Raspberry Pi to work as the gardener?

  • Reporting Rasp Pi data on a Node.js web server

    Combine great hardware projects that use the Raspberry Pi GPIO pins and a Node.js web server that interacts with the underlying operating system and hardware, and you have a winning team.

  • Roasting beans in a repurposed air popper

    Transform an old air popcorn popper into a coffee bean roaster controlled by a Raspberry Pi and a slick user interface.

  • Create amazing Pi apps without writing code

    Create super easy Pi programs to turn on lights, speak to you, or control motors.