Blog
IoT Based Home Automation Using Raspberry Pi 4
- February 11, 2020
- Posted by: Naveen PS
- Category: Learn Technology in 5 minutes

In this blog, we will learn how to build a simple IoT Home automation project using the Raspberry Pi 4. That too, without writing even a single line of code. Before we go into the blog, I want to set the expectations right. This blog will be purely procedure based, and we will not be covering the concepts in depth.
So let’s get started with the Project.
In this Project, we will be using a very intuitive online Drag and drop IoT Project Builder called Cayenne. We will use Cayenne to remotely control a Relay connected to the Raspberry Pi, which will turn a bulb ON or OFF based on the user input.
As Cayenne is a cloud platform, we can control the bulb from anywhere in the world as long as the Raspberry Pi is connected to the internet.
Now let’s start working with Cayenne. The First thing we need to do is to create a Cayenne myDevices online account. Go to the following link and create a myDevices account: https://accounts.mydevices.com/
Now you will be redirected to the Dashboard. As this is your first login, you will be redirected by default to create a new project. Select Raspberry Pi, then in step 2, before clicking Next, make sure your Pi is up and running and is connected to the internet. Now click next.
We are now going to install the different components of the Cayenne library on to our Raspberry Pi. Open the terminal in the Raspberry Pi and copy and paste the commands given in the Cayenne Dashboard.
While installing, the Cayenne Dashboard will get remote access to your Pi, and shows the status of the installation.
As soon as the installation process completes, the online Dashboard will automatically appear. Your Raspberry Pi is now ready to use. Yes, it’s that simple. How amazing, right! Now the Raspberry Pi is up and ready for IoT projects using Cayenne.
We are now in the dashboard overview tab of the Cayenne platform.
Now click “Add new” and then select the Device option from the submenu. As a relay is an actuator, select “actuators” from Devices list and then choose “Relay”. This will show you a Widget named Relay Switch. We need to configure this widget before adding it to our main Dashboard.
Leave the Widget name and device as default. For the Connectivity option, you need to select it as integrated GPIO. Next, you need to set the channel, which is essentially the GPIO pin that will be interfaced with the Relay Module. We will be selecting Channel 17. Finally, choose the widget type as a button and click add actuator. Once the widget is configured and created, you will be redirected to the dashboard overview. This is where the toggle button for controlling the Relay will appear.
The next step is to interface the Raspberry Pi 4 to a Relay and then connect the CFL in the normally open configuration. Here is the circuit diagram. Essentially we are connecting the VCC pin of the Relay to a 5 V pin of the Pi, then the GND pin to any Ground pins of the Pi, and finally, the IN1 pin to GPIO 17 pin of the Pi.
Now let’s test the Project out. Clicking the toggle button on the Dashboard indeed activates the Relay, which in turn switches the CFL to ON state.
This is just an example project. You can connect any high power appliances across the Relay and control them from anywhere in the world. Cayenne has even provided a mobile app so that you control and monitor your projects on the go.
You have now successfully learned to build an IoT based Home automation project using Raspberry Pi 4 without writing even a single line of code.
Learn Technology in 5 Minutes is a unique video series aimed at demystifying cutting edge technologies in the field of AI, IoT & Embedded Systems. Invest just 5 minutes of your time everyday and within a year you will have wide breadth and depth of knowledge on various topics.