Internet of things on Raspberry Pi using Cayenne
In this article, we will control our Raspberry Pi using Cayenne. Cayenne uses MQTT API for interaction with Raspberry Pi.
We shall control PiRelay with Cayenne. PiRelay is a Raspberry Pi Shield with 4 Relays(5 Amp/240VAC or 10Amp/30VDC), with customizable GPIOs, LED indicators that can be used to operate almost all the domestic appliances.
What is Cayenne?
Cayenne is a drag-and-drop IoT project builder, developed by myDevices. Cayenne is available for smartphones and computers which helps the user to connect to there devices from anywhere in the world.
There are certain advantages of Cayenne for IoT integration, like-
- Remotely control sensors, motors, actuators, and GPIO Pins
- Customizable dashboards with drag-and-drop widgets
- Create triggers and threshold alerts for devices, events, and actions
- Schedule one-time or multi-device events for easy automation
- Connect your Pi quickly and easily
Things you need
Setup Cayenne for Raspberry Pi
Sign Up to Cayenne
Cayenne from Apple Store
Keep a Raspberry Pi ready with Rasbian, you can download Raspbian from raspberrypi.org
Download and install Cayenne
After the Sign up you will be redirected to the device selection menu,
Select Raspberry Pi,
Step 2 will appear
Click on the ‘Next’ button
You will be directed to step 3, where you will be asked to download the application or install Cayenne on Raspberry Pi.
Open Terminal or ssh to your Pi.
From option 2 Copy the text and paste to the terminal,
And execute the downloaded file using
sudo bash filename.sh -v
‘Please be patient 10 minutes to ultimate the installation process.’ The message will be displayed on the Cayenne web portal. After the installation, reboot the Raspberry Pi.
After the successful reboot, the Cayenne web or app interface will open the Overview tab of Raspberry Pi. In the overview section, you can see raspberry Pi’s CPU usage, RAM, Storage, temperature, Network Speed on your screen. You can also see a Reset and Shutdown button on the screen Reset button will restart your pi.
You can configure your Raspberry pi using the settings button on the right side.
Use the Add new option to Add new Devices, Events, Triggers, and Projects.
Using your smartphone download the application and sign in with the registered Email Id. After a successful login, you will be directed to the overview page.
Controlling PiRelay with Cayenne GPIO
Stack up PiRelay over the Raspberry Pi
A green led will glow if PiRelay is stacked properly and Pi is powered up.
Go to GPIO option on Cayenne on your Smartphone or web interface. Both the interfaces will look alike-
If the yellow jumpers on PiRelay are connected, the GPIO connection of PiRelay with Raspberry Pi is -Relay 1: Pin 15
Relay 2: Pin 13
Relay 3: Pin 11
Relay 4: Pin 7
Note: These are Board Pins
However, you can use Female to Female jumper wires to connect Pirelay with a GPIO Pin of your choice.
On the Cayenne interface, you can see the GPIO interface of Raspberry Pi with the pin description. You can use the GPIO pins, change the mode of pins(IN/OUT), and set the value high or low accordingly.
For controlling the PiRelay, set the pin mode to ‘OUT’ and change the value to high or low to switch relays on your PiRelay.
You can use other components and operate them from anywhere in the world. Cayenne uses MQTT API for controlling Raspberry Pi.
Enjoy controlling your home appliances and other devices with your Smart Phone.
Hope you enjoyed this article...