Simple Diy Smartfan Using Raspberrypi
by DNA TECH in Circuits > Raspberry Pi
190 Views, 0 Favorites, 0 Comments
Simple Diy Smartfan Using Raspberrypi
This project demonstrates the use of Raspberry Pi as an IoT device. First we control the turning ON/OFF of LEDs using a cgi scripts and then control the turning ON/OFF of FAN using a webpage that can be accessed from any device over the same network onto which Raspberry Pi is connected. The concepts of this project can be used to further implement various home automation projects.
Supplies
Hardware components
- Raspberry Pi 3B+ - https://www.raspberrypi.com/products/raspberry-pi-3-model-b-plus
- Motor Driver - https://robu.in/product/l293d-motor-driver-module/
- Jumper Wires
- LEDs
- Memory card(SD card) for Raspberry Pi
Install Raspbian OS in the SD Card
STEP 1: Download the raspberry Pi imager from this official raspberry pi website https://www.raspberrypi.com/software/
STEP 2: Follow this official video on Raspberry Pi os installation on SD card https://youtu.be/ntaXWS8Lk34
Install the Apache Web Server on Raspberry Pi
First we need to update and upgrade our Raspberry Pi using the following commands
sudo apt-get update
sudo apt-get upgrade -y
To install the Apache web server on our Raspberry Pi use the below command
sudo apt install apache2 -y
After the installation we need to enable the cgi mod to execute our CGI scripts through webpage
sudo a2enmod cgi
Run the CGI Scripts by Turning ON/OFF LEDs
Change the working directory to /usr/lib/cgi-bin
cd /usr/lib/cgi-bin
create a new .cgi file using the below command
sudo nano on.cgi
The cgi scrpit is attached below
change the permission of the CGI script using the below command
sudo chmod +x on.cgi
To execute the CGI script use ./on.cgi command
./on.cgi
Downloads
Create a Webpage to Controll FAN
change the working directory to /var/www/html
cd /var/www/html
To list the files in the directory use command
ls
There we can find a html file named index.html
use the command ifconfig to find the Raspberry Pi's IP address before that the raspberrypi should be connected with local network either through LAN or WIFI.
open the webpage with the Raspberry Pi's IP address and we can see the default Apache Webpage.
we need to create our own html page to control the FAN.use the below pdf which contains simple html code
move the downloaded images for on.jpg and off.jpg to the directory /var/www/html
sudo mv on.jpg /var/www/html
sudo mv off.jpg /var/www/html
That's it we mad our simple webpage to control our fan.
Downloads
Working Demonstration and Steps
Here is the step by step video tutorial to make simple diy smart fan using Raspberry Pi.
Follow through the tutorial to make your own home automation projects.
connect GPIO PINS 17 and 18 (Wiring Pi) to the motor driver input I1 and I2