When I started my IoT projects , one of the challenge was to build a IoT platform or use an existing IoT platform which can be used to monitor, control, manage your sensors & devices. Even though there are enterprise IoT platforms available, I have found mydevices Cayenne or Cayenne powered by myDevices is one of the best open source tools which gives very good features to run IoT projects.

"MyDevices" Cayenne is the world’s first drag and drop IoT project builder that empowers developers, designers and engineers to quickly prototype and share their connected device projects. Cayenne was designed to help users create Internet of Things prototypes and then bring them to production. Cayenne app is available in both mobile platform Android, IOS and also you can access Cayenne through web browser.

Lets start our work to setup Cayenne for Raspberry Pi . In this article we will cover how you install Cayenne to Raspberry to connect through Mobile app & Web browser to have it ready to control an LED & other sensors.

MyDevices Cayenne is an open source IoT Platform which is used as IoT Project builder that allows you to control Raspberry Pi & other sensors, relays, actuators connected to your Pi through graphical interface.

Main features of Cayenne:

Widget: A variety of widget are available & parameters can be customized by the user.Add remotely controlled sensors, actuators, relay,GPIO Pins etc.

Customizable dashboard & Visualization : Cayenne stores historical data that enables you to see meaningful patterns of behavior to help understand and guide improvements on your IoT projects and the devices and sensors connected & is easily customizable.

Drag-and-drop widgets: Cayenne uses widgets to visualize devices, their data, status and actions. Every device, sensor and actuator that gets added in Cayenne has one or more widgets associated depending on the hardware capabilities. Widgets are added to the Device list on the left hand side and to each device’s Dashboard.

Triggers: Create tiggers with threshold that can send email alerts.

Easy setup: Cayenne is easily integrated with Pi & installation is simple.

Sign Up to Cayenne:

To install Cayenne what you need is a or ( We will be focusing on Raspberry Pi in this article), Pi should be installed with Rasbian or NOOBS Operating system. If you not have done that yet, kindly refer the article how to install noobs on raspberry pi 3. The Raspberry Pi should be connected to Internet through Ethernet cable or through WiFi.With Cayenne I have to admit that DIY (Do it yourself) raspberry pi projects home automation complexity is simplified.

First create an account in mydevices.com. Go https://mydevices.com/ and click on Sign Up Free, Enter the First, Last name , Email address & password, agree the terms and click on get started free. you can also sign up through Mobile app. Go to play store and install Cayenne App ( App Store or Playstore), signup through the Cayenne app.

Cayenne Sign up page

Register for Cayenne mydevices

Install Cayenne through commands or Mobile app:

Once you login to Cayenne , you will not see any devices because we have not connected our raspberry Pi to the Cayenne dashboard. The easiest way to do this is through Mobile app.

Cayenne Google Playstore App

Once you login to the Mobile application, go to my devices  & click on the Plus icon on the top right corner -> Add device  .This will list you the devices which can be connect & select Raspberry Pi. Since our Raspberry Pi is already connected to WiFi, click on Search for devices.

 

Our cayenne raspberry pi is listed and click on it which will prompt you to enter Pi username & password . By default it is pi & raspberry however for security we have already changed this when we setup our Raspberry Pi with NOOBS. Enter the same and click on done.

Pi user name & password

Now you can select the Pi & click on Setup , which will start the installation & will take 5 to 10 min to complete the installation. The Raspberry will be rebooted & Cayenne dashboard will be available with basic information of the devices like CPU usage, memory usage etc.

Cayenne Installation

Cayenne dashboard

 

Manual installation method on Raspberry Pi: 

To install directly from Rasberry Pi, Connect to you Pi through SSH or open Terminal from Pi, enter the below commands.

wget https://cayenne.mydevices.com/dl/rpi_fqljxbqthj.sh

sudo bash rpi_fqljxbqthj.sh -v

This will take some time, Pi will be rebooted. You can login to the web brower and see the Cayenne dashboard.

Cayenne Dashboard & configuration:

We are now ready with Cayenne dashboard  and ready for cayenne iot project build. However before we proceed, let us see what are the features available and how we can add our sensors & create tiggers in Cayenne IoT.

Widgets:  go to add devices & select the respective device you want to add. We are going to add a Relay module, so go to actuators & select Relay.

Add widgets in Cayenne

In the next screen select the Raspberry Pi ( if you have more than one Raspberry Pi configured in Cayenne select the right device in which you are using the Relay) , Connectivity to Integrated GPIO, Channel should be selected to the right Pin number to which you are connecting the device and choose what type of button to control the action. Click on add actuator and you are done. its as simple as that, you can add in the similar way other devices as required.

Relay configuration

Now if you have all physical devices also configured to the pins defined in Cayenne, when you toggle the switch in Cayenne dashboard the Relay will switch On and Off accordingly.

Configure Trigger:

We can also setup triggers in Cayenne which have two section If an then part. If decide the condition on which what action to need to be that is defined in then part:

Cayenne triggerGo to add new and select Trigger, give a specific name for the trigger. Drag the Raspberry Pi device to the If box and select the sensor , actuators which is configured on which you need to create the trigger. In this case we selected Relay . Next part is then, we have options to setup notifications or setup webhook. Click on Setup notification and you have options to send text message, send email . This is really a great feature in Cayenne and really useful.

I hope you all had a good understanding on Cayenne & how to setup for our cayenne raspberry pi projects. One of the question asked to me is that Cayenne is not free and what is cayenne mydevices pricing? . I would like to re-itrate that Cayenne is free for signup and I am not paying a penny at this point, I am not sure if they will change it in future. One of the words I saw from the post in http://linuxgizmos.com/free-iot-development-and-management-platform-adds-arduino/ is “As for pricing, the product will always be free to makers but we will be rolling out an Enterprise solution with pricing to be announced at that time,” wrote Bromber in an email. We see you in next posts on setting up projects using Cayenne devices.

As we have completed the setup of Raspberry Pi now & we are ready for running the projects using Raspberry pi. Let us proceed with our first simplest project. In this tutorial we will light a LED light which is connected to Raspberry Pi GPIO Pin using python programming.

What do you need:

  • Raspberry Pi
  • Bread Board
  • LED
  • Resistor -220 ohm
  • Jumper wires - Male to Female

Using a breadboard is the best way to do prototyping the electronic circuits rather soldering the components together on a PCB.We use breadboard to test circuit design & it is easy to make the changes , as we just need to re-plug the wires.

Below is the picture of breadboard & I have marked how the holes in the breadboard are interconnected. The top & bottom row holes are interconnected in the row & not in columns. However in the middle section in between, they are not interconnected in row hole , they are interconnected in the column holes.

Breadboard

We are also using a LED ( Ligh emitting diode), if you notice the LED one of the leg of LED is longer that the other. The longer leg is positive or called as Anode & shorter leg will negative or connected to ground which is called as Cathode. LED will glow when current is passed through it.

LED

We will be using 220 Ohm resistor in the circuit, we must always use the resistor to control the current flow between Raspberry Pi & LED. Resistor controls the current flow, Raspberry can only give a limited amount of current. The resistor value are calculated based on the color coding on the resistor, you can google around to find more details.

Resistor

We are using male to female jumper wires, as it is easy to connect to GPIO pins in Raspberry Pi & other end to breadboard.

Male to female Jumper wire

The details for GPIO pins I have described in my previous post, refer the post my IoT devices .

You can test the LED by connecting the LED to a power source like battery through a resistor.
I have used a 9V battery for testing, connect the positive to LED anode( Long led) , the LED cathode (shorter leg) is connected to 220 Ohm resistor & other end of resistor is connected to the negative point of battery. Refer the below pic.

Testing LED with Battery

Now in actual circuit with Raspberry pi ( I have used Raspberry Pi zero W), I have used the GPIO pin 7 for the circuit. Connect the GPIO PIN 7 to the anode of LED & the GPIO PIN 6 which the GND(ground) connect to the other end of resistor. Refer the below screenshot. Once we have the circuit setup & the raspberry pi is powered on, it is now time to write the python code.

LED circuit with Pi

To write the python code you can use python IDLE or you can even use text editor & save the file with extension .py. I prefer python IDLE as it comes with Raspbian libraries & it is easy to debug, also the errors in syntax can be easily identified.

Lets create a file LED.py & start our python program. I will start with a simple program to turn on the LED when we run the script.

Script 1 : Turn on LED

import RPi.GPIO as GPIO
# We are importing the library , which will be telling the python interpreter how to work with Raspberry PI GPIO Pins.
GPIO.setmode(GPIO.BCM)
# This will inform on how pin numbering on board to be used.
GPIO.setup(7, GPIO.OUT)
# we are setting GPIO Pin 7 as an Out Pin
GPIO.output(7,True)
# Setting the GPIO Pin 7 as True will make the GPIO pin 7 to High

Save the file & run the LED.py file. We need to run the script in superuser. To run the code

sudo python LED.py

The LED will be lit & will always on until we close the program.

Script 2: Keep the LED lit for 5 seconds & then turn off.

import RPi.GPIO as GPIO
# We are importing the library , which will be telling the python interpreter how to work with Raspberry PI GPIO Pins.
import time
# We are improting the time library in this script to define the duration of the LED to be lit.
GPIO.setmode(GPIO.BCM)
# This will inform on how pin numbering on board to be used.
GPIO.setup(7,GPIO.OUT)
# we are setting GPIO Pin 7 as an Out Pin.
GPIO.output(7,GPIO.HIGH)
# Setting the GPIO Pin 7 to High
time.sleep(5)
# Setting the duration to 5 sec to keep the LED lit.
GPIO.output(7,GPIO.LOW)
# Setting the GPIO Pin 7 to Low.
GPIO.cleanup()
# This is used to cleanup the GPIO Pin state.

Run the script using sudo python LED.py

Script 3: Blinking the LED for 10 times with delay of 5 sec in between.

import RPi.GPIO as GPIO
# We are importing the library , which will be telling the python interpreter how to work with Raspberry PI GPIO Pins.
import time
# We are improting the time library in this script to define the duration of the LED to be lit.
GPIO.setmode(GPIO.BCM)
# This will inform on how pin numbering on board to be used.
GPIO.setup(7,GPIO.OUT)
# we are setting GPIO Pin 7 as an Out Pin
for i in range(0,10):
# Run loop 10 times
         GPIO.output(7,GPIO.HIGH)
         # Setting the GPIO Pin 7 to High.
         time.sleep(5)
         # Setting the duration to 5 sec to keep the LED ON.
         GPIO.output(7,GPIO.LOW)
         # Setting the GPIO Pin 7 to Low.
         time.sleep(5)
         # Setting the duration to 5 sec to keep the LED OFF.
GPIO.cleanup()
# This is used to cleanup the GPIO Pin state.

We have successfully completed the first projects with LED in multiple variations. I hope you guys have enjoyed this.


Wow!, its great that now we are going to talk about IoT projects. We have spend enough time to speak about what is IoT, what is IoT platforms, IoT devices, IoT sensors & we are ready to start with Internet of Things Projects. We will be using lot of sensors, devices which we have described before. If you have not gone through my previous post kindly go through it to get an understanding.

We will be doing IoT home projects using Raspberry Pi, Arduino or ESP8266 boards mainly.

Let me list out some of the common projects we can do easily & its really interesting. If you are playing in AC its really suggested to work with some one who knows about electric current & circuits. Be very careful in those projects, we don't want to get hurt. Its very risky.

If you know some basics of electronics, electrical circuits, programming it will be very easy for you complete these projects. If you are really a beginner don't worry at all, its not too much to take in, you can easily cope up with the projects.

Lets start with some of Raspberry Pi Projects , below are few

Components needed:

  1. Raspberry Pi
  2. Micro USB adapter
  3. Bread Board
  4. LED
  5. Resistor

Components needed:

  1. Raspberry Pi
  2. Micro USB adapter
  3. Bread Board
  4. LED
  5. Resistor
  6. Cayenne software

Components needed:

  1. Raspberry Pi
  2. Micro USB adapter
  3. Bread Board
  4. AC Bulb
  5. 5 V Relay
  6. Cayenne software
  • Buzzer & raspberry Pi

Components needed:

  1. Raspberry Pi
  2. Micro USB adapter
  3. buzzer
  4. Transistor /Resistors as needed
  • Motion detected buzzer sound

Components needed:

  1. Raspberry Pi
  2. Micro USB adapter
  3. buzzer
  4. Transistor /Resistors as needed
  5. Motion Sensor
  • Temperature & Light Control using Raspberry Pi

Components needed:

  1. Raspberry Pi
  2. Micro USB adapter
  3. Temperature Sensor
  4. LED
  5. Resistor
  6. Bread Board

Components needed:

  1. Raspberry Pi
  2. Micro USB adapter
  3. Motion Sensor
  4. Camera module
  5. Bread Board
  • Surveillance Camera with live feed using Open CV

Components needed:

  1. Raspberry Pi
  2. Micro USB adapter
  3. Camera module
  4. Bread Board
  • Smart Mirror

Components needed:

  1. Raspberry Pi
  2. Micro USB adapter
  3. Monitor
  4. Two way glass mirror
  5. HDMI cable
  6. Mouse & Keyboard for setup
  • Automatic Plant watering system

Components needed:

  1. Raspberry Pi
  2. Micro USB adapter
  3. Soil Moisture sensor
  4. Temperature sensor
  5. watering pump
  6. Flexible water pipe

Lets start with these simple one first & as we move forward we can go more & more complicated technical projects

As you see we are talking about other devices like LED, Sensors, Resistors, Camera Module, buzzer , bread board etc which are required for the projects. Let me give some samples which I have used for my projects, you can refer them & purchase which suits your need.

LED:

Moisture Sensor:

Temperature Sensor:

Temperature & Humidity Sensor:

Motion Sensor:

Camera module for Raspberry Pi 3

Buzzer:

Resistors:

Breadboard:

HDMI Cable:

For Pi zero you need HDMI mini to HDMI convertor:

Once you have the devices in hand, first thing you will need is to setup Rasperry Pi. You need to install the Operating system on Pi before we can start any of the process. You can install NOOBS or Raspbian OS, you can download from https://www.raspberrypi.org/downloads/raspbian/ . I will add another post to describe the step by step procedure on installing Operating system on Raspberry Pi & do the initial configuration. It is very simple & not that complicated. You need to have a Micro SD card to install the Operating system, I would suggest to buy a 8 GB one so that you will have enough space to install Open CV and other required software.

For compact projects you can select Raspberry Pi zero with wireless , for more performance needed projects i would suggest to go with Raspberry pi 3.