Remotely monitor the sensed temperature, humidity using DHT11 and also remotely control the fan (DC motor) speed using L293D.
- Raspberry Pi
- PHP + MYSQL for website
- Python
- DHT11 for temperature, humidity
- L293D to control DC motor speed.
- Make connections. You can make them as per the links provided in references.
- Modify pin numbers utilized in
rpi.py
, only if needed. site
folder contains website code, deploy it and change the related URLs declared ashttp://localhost/site/
inrpi.py
, if needed.- Import
site/iot.sql
to setup database and it's tables with dummy data. - Update database credentials declared in
site/api/database.php
. - Run
rpi.py
-
The graph on the same page, for comparison of humidity, temperature with reference to time.
-
Display previous automatic setting parameters and change them:
site/settings.html
-
Display previous manual settings and change it, the same page.
-
What is Auto & Manual Setting?
Auto takes 3 input pairs:
- Low humidity-temperature
(x1,y1)
- Medium humidity-temperature
(x2,y2)
- High humidity-temperature
(x3,y3)
Compares these 3 input pairs with currently sensed Humidity-Temperature
(x,y)
pair by using a modified form of Distance Formula in order to decide the speed of the fan: low, medium or high speed.Example, if the distance is
(x,y)
and(x1,y1)
is the lowest, then speed must be low.Manual takes one single input out of:
- Low
- Medium
- High
- None
If None is set, then it utilizes the latest auto setting parameters to decide the speed of the fan, otherwise, the Manual setting is considered over Auto Setting.
- Low humidity-temperature
When you execute rpi.py
, we fetch the manual setting from site/api/manual.php
.
If manual setting is set, we sense the temp-humidity but set the fan speed as per manual choice, and send the sensed temperature-humidity to site/api/data.php
.
If manual setting is not present or it is None, we fetch the latest auto setting parameters from sit/api/auto.php
, then sense the temp-humidity and use Distance Formula (as previously explained) to set the fan speed and then send the sensed temp-humidity to site/api/data.php
.
This cycle repeats every 5 seconds as defined in rpi.py
inside start
function.
Webapp is used to remotely displayed all the sensed temp-humidity record, graph and all the settings previously defined. User can redefine auto/manual setting. It also contains the api endpoints defined in api/*
files which is used to communicate between database, frontend and python, for:
- Fetching all the previous records of temperature-humidity
- Fetching all the previous records of settings (auto/manual)
- Set auto setting
- Set manual setting
- Truncate all previous records
- Delete all manual settings
- Delete all auto settings except latest one.