Cayenne for Raspberry Pi
Sensors, Triggers, and Schedules
The ability to monitor your Rasp Pi, access its graphical desktop environment remotely, and control GPIO is great, but that's not Cayenne's most interesting functionality. After all, it's not a mere server monitoring service, but an IoT platform. The GPIO port makes it possible to connect a wide range of sensors and peripherals to the Rasp Pi: from temperature and PIR sensors to motors and actuators. And using Cayenne, you can read and process data from sensors and control the attached peripherals. Better still, the platform lets you create triggers and schedule events.
To demonstrate Cayenne's capabilities, I'll build a simple project that works with a temperature sensor connected to the Rasp Pi. For this project, you need a DS18B20 digital temperature sensor, a 4.7Kohm resistor, a breadboard, and a handful of wires. Start with wiring the sensor and the resistor as shown in Figure 7. Connect the circuit to the 3.3V, GND, and GPIO4 pins. Next, you need to load the 1-Wire and thermometer drivers using the following commands:
sudo modprobe w1-gpio sudo modprobe w1-therm
To make sure that everything works, switch to the /sys/bus/w1/devices/
directory and run the ls
command:
cd /sys/bus/w1/devices/ ls
You should see the temperature sensor listed as an alphanumeric sequence (e.g., 28-00000452baa5). Use the following command to check whether the sensor transmits any data:
cd 28-00000452baa5 cat w1_slave
If the sensor works properly (Figure 8), you should see output that looks something like:
8e 01 4b 46 7f ff 02 10 02 : crc=02 YES 8e 01 4b 46 7f ff 02 10 02 t=24875
Cayenne is intelligent enough to detect a new data source (a temperature sensor in this case) automatically and add a widget for it. You can then adjust the widget's default settings, if needed. Now you can monitor the temperature directly from the Cayenne dashboard and view temperature data as a chart by clicking on the Details & Chart icon in the upper-right corner of the widget.
But that's not the only thing for which you can use Cayenne. The platform also makes it possible to create so-called triggers that perform certain actions when a specific event occurs. For example, you can create a trigger that sends you email or an SMS alert when the temperature level exceeds a specified threshold (Figure 9). To create a new trigger, select Trigger from the Add new drop-down list. If you have set up a separate project, you can create a trigger in the Triggers & Alerts section.
Triggers in Cayenne are based on a simple if-then rule. Drag the Rasp Pi item onto the if area and select the temperature sensor from the Select Trigger drop-down list. In the then area, click on setup notification and configure notification settings. Press Save Trigger to save and enable the trigger. Next time the temperature value exceeds the specified threshold, you'll receive an alert via email or SMS (or both, depending on the notification settings).
In addition to triggers, Cayenne also supports event scheduling. For example, if you want to turn the connected LED on and off at specific times, you can add the appropriate events to the schedule. After selecting Event from the Add new drop-down list (or use the Scheduling section in a project), you can configure the event as shown in Figure 10. Of course, you can configure the schedule and recurrence the way you like it and add a notification, if needed.
Final Word
Cayenne provides a perfect introduction to the IoT world. The platform is designed to work with Rasp Pi, the software is easy to deploy, and the accompanying mobile app is a boon for Android and iOS users. Building projects with Cayenne requires no particular skills, and you can use the platform free of change (at least for the time being). So what's not to like?
Infos
- Cayenne: http://www.cayenne-mydevices.com
« Previous 1 2 Next »