How To Setup Raspberry Pi And Other Hardware Components?

As we have understood the basic aim of this project, now let’s move a step further towards collecting the components and assembling them.

Step 1: Components Required

Step 2: Selecting the Raspberry Pi Model

Several models of raspberry pi are available in the market. Except for raspberry pi zero, any model can be preferred. This is because on Pi zero setting up a network is a very tiring job. The latest models like 3A+, 3B+ or 4 can be purchased. The new Raspberry Pi 3 is the quickest and most dominant gadget the Raspberry Pi Foundation has released to date. So, in this project, we will use the Raspberry Pi 3B+.

Step 3: Choosing The Operating System

Firstly, we will need an SD card with an appropriate operating system. When picking the OS, nowadays there are various alternatives, from “conventional” Raspbian to devoted media working frameworks, and even Windows 10 IoT. Raspbian is preferred because it comes with over 35000 packages. Raspbian is a community project under active development, with an emphasis on improving the stability and performance of as many Debian packages as possible.

Step 4: Interfacing Raspberry With Laptop

External monitor or LCD using HDMI cable can be used as a display to connect with Raspberry Pi. If anyone doesn’t have LCD he/she can use a laptop to connect Pi but some configurations will need to be done for connectivity. We will use a Secure Shell (SSH) client known as Putty to connect Pi using a laptop. Interfacing is explained in steps mentioned below :

Step 5: Circuit Diagram

Now as we know how the components work let’s go ahead and assemble these components and make a circuit as shown below. Relay is powered by 5 V of Raspberry Pi and General Purpose Input Output (GPIO-14), is connected to the IN of the relay. It will tell the relay when to switch ON and OFF. We have connected 12V AC bulb to the output of the relay so that when the garage door is opened bulb is turned ON and when the garage door is closed the bulb is turned OFF.

Step 6: Flask Setup In Pi For Controlling Garage Door

We will create a Web server using Flask which will pave the way for sending commands from Webpage to Raspberry Pi to control our prototype over the network. Flask enables us to run our python contents through a website page and we can send and get information from Raspberry Pi to the internet browser and the other way around. It is a microframework for Python. This tool is Unicode based having built-in development server and debugger, integrated unit testing support, support for secure cookies and its easy to use, these things make it valuable for the specialist. For installing Flask on your Raspberry Pi type the following commands: Now, run pip command to install Flask and it’s dependencies :

Step 7: Create A Python Script For Door Opener

This script will cooperate with our Raspberry Pi GPIOs and sets up the webserver. It is the main script for our project. Python script will be explained in the parts below: Firstly, we will make a folder. All other required folders should be in this folder only. Run below commands to make a folder and then create a python file named app.py inside this folder: The above commands will open the Nano editor where will write the script below. Include important libraries: Now, create a dictionary as pins to store the PIN, name, and pin state. You can utilize more than one pin as per your need: Then, set the pin to output and set it to low initially: We will make the function to read pin state and store this state in a variable: We will pass this data to our HTML page so, that we can control the input button state: For handling requests from URL make a function with PIN and action in it: After that convert pin from the URL into an integer; If the action part of the URL is “open,” at that point do the following: I will attach the complete script at the end and if anybody wants to copy that he/she can do that by pressing ctrl+x and then pressing Enter. Now we are done with the python script and we will make an HTML page to interact with the python script.

Step 8: Creating HTML Page For Raspberry Pi Server

We will make changes in the garage_door folder that we created previously. We will create another folder named templates and inside this folder make a .html files using the following commands: Now, open the nano text editor and write the HTML code. We can editpart of the page and modify it according to our own choice. We have used the third party CSS scheme using the link tag. The complete code is given below: Click here to download the HTML code to create a web page.

Step 9: Creating A Button For Opening And Closing The Door

We will have to assign a state to open and close the button. That button will send and fetch the GPIO state from the python script. As we have completed the above HTML code now we can use it in the editor and save it and finally our web server is ready to launch. Open the terminal and navigate to garage_door folder and run the below command mentioned below: Open the browser and enter the IP address of Raspberry Pi and press Enter. This type of page will be shown:

Step 10: Setting Up The Hardware

As we are done with the software setup now let’s move a step ahead and assemble the hardware. make sure that the relay module is connected to the Raspberry Pi. For testing press open button to switch ON the relay and close button to switch OFF the relay. As soon as the relay is turned on the AC bulb lights up and we come to know that the gate is open and when the bulb is powered off we come to know that the gate is closed. To stop the server press ctrl+c. Click here to download the code to setup Hardware.

How to Make Curtain Opener and Closer Circuit?How To Make Home Theater Using Raspberry Pi?How To Make A Smart Stick For Blind People Using Arduino?How To Make A Smart Trashcan Using Arduino? How To Make IOT Smart Garage Opener Using Raspberry Pi  - 63How To Make IOT Smart Garage Opener Using Raspberry Pi  - 97How To Make IOT Smart Garage Opener Using Raspberry Pi  - 14How To Make IOT Smart Garage Opener Using Raspberry Pi  - 53How To Make IOT Smart Garage Opener Using Raspberry Pi  - 50How To Make IOT Smart Garage Opener Using Raspberry Pi  - 67How To Make IOT Smart Garage Opener Using Raspberry Pi  - 17How To Make IOT Smart Garage Opener Using Raspberry Pi  - 72How To Make IOT Smart Garage Opener Using Raspberry Pi  - 68How To Make IOT Smart Garage Opener Using Raspberry Pi  - 14