The Internet of things is a system of interconnected things that communicate with each other. It’s a buzz word presently. It allows data transfer without the involvement of human-human or human-machine interactions. There’s been an upsurge of many IoT platforms that bring our ideas and thoughts into existence. Cayenne is one of such platforms that makes working with IoT a cakewalk even for a newbie. This tutorial is a getting started guide for Cayenne Raspberry pi and it explains the concepts with led switch example.
What is Cayenne?
Cayenne is an online IoT platform that permits one to control IoT devices. At first, it was solely for Raspberry pi but now it works with Arduino, LoRa and your own thing as well. It’s drag and drop feature makes it attractive. It standardizes the connection among devices such as sensors and motors and makes sure that drivers are in place. In this sense, it makes the programming and the hardware a lot easier.
Widgets are used to monitor, visualize device data and actions. One also can incorporate custom code into it. Python script can also be used along with Cayenne by using Raspberry Pi in MQTT mode which is slightly different from this tutorial.
A wide line-up of actuators(output devices) can be added into this along with relays, motors, etc. It supports a mixture of Arduino and Raspberry Pi hardware in the same project. Hence it becomes possible to use a combination of hardware in, say, a home automation project and have a sensor on one device, trigger a control device on another. To make things automatic one can define triggers – which are ‘if-then’ rules that can take the state of sensor in the ‘if part’ and the state of an actuator in the ‘then part’. Things like turning one thing off when the temperature reaches a threshold and sending notifications to the outside world using messages or email are also available. Besides, custom messages together with photos can also be sent.
Once the Cayenne agent is put in, i.e. installed on the Pi, you can interact with it via the mobile app or the website.
Getting started with Cayenne
Before moving to Cayenne agent installation on your Raspberry Pi,
- Enable SSH on the pi. This may be done as:
Go to Menu –> Raspberry Pi Configuration –> Enable SSH.
Now reboot Pi.
- Then find your IP address (optional) by heading into a terminal and writing the command:
hostname -I
Keeping these things in mind let’s head onto Cayenne agent installation.
1. Go here and click on ‘sign up free’.
2. This takes you to the bottom of the page. Enter your details and click on ‘Get Started for Free’.
3. You will be now required to choose your device. In this article, we opt for Raspberry Pi.
4. In the next prompt, click on ‘Next’ as shown below.
5. You will be directed below.
You can prefer either of the installation procedures but here we will use Option 2. In option 2, just open Terminal on your Pi and enter the following commands:
wget https://cayenne.mydevices.com/dl/rpi_73ig502fv4.sh sudo bash rpi_73ig502fv4.sh -v
Wait for a moment. You’ll get an email from ’myDevices’ upon a complete and successful installation.
LED switch using Cayenne
1. Connect a resistor between ground and LED negative(shorter lead). Connect the LED positive(longer lead) to the GPIO PIN 26 of Pi.
Follow the image for reference. Turn Raspberry Pi ON after making those connections.
Head on to the Cayenne dashboard and choose your device. Here we use the Cayenne app for Android. The same process can be adopted for the iOS app and website as well.
Click here to access the Cayenne dashboard on your Computer.
2. Sign in on your mobile device.
3. Then click on ‘Add’ and choose Raspberry Pi.
The cayenne app searches for devices and displays the search results. Then you select your device after which you’ll be asked to enter SSH username and password. You can also search for your device( Raspberry pi) using the IP address without ambiguity.
4. When the dashboard appears click on Add Device.
5. Select Light switch from Actuators.
6. Fill as below and click on ‘Add Sensor.
7. You can now control the LED from your Cayenne dashboard sitting anywhere in the world via the Internet.