Arduino Temperature Control

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 35

Arduino Temperature Control - Adjust Fan Speed based on

Temperature

Published  August 3, 2015    |    Last Modified on April 14, 2022  94


Saddam
Author

In this arduino based project, we are going to build a temperature-controlled fan using

Arduino. With this circuit, we will be able to adjust the fan speed in our home or

office according to the room temperature and also show the temperature and fan speed changes

on a 16x2 LCD display. To do this we will be using an Arduino UNO Board, LCD, DHT11

sensor Module, and DC fan that is controlled by using PWM. Let's discuss more on this is done
so that you can build one on your own. We have also built a project to perform Automatic AC

temperature control, you can also check that out if you are intrested. 
 

Components Required
The following are the materials required to perform a temperature-based fan speed control

using Arduino. Most of the components should be easily available in your local hardware shop 

1. Arduino UNO

2. DHT11 sensor

3. DC Fan

4. 2n2222 transistor

5. 9 volt battery

6. 16x2 LCD

7. 1K resistor

8. Connecting wires

Arduino Fan Speed Control using Temperature Sesnor 


This project consists of three sections. One senses the temperature by using humidity and

temperature sensor namely DHT11. The second section reads the dht11 sensor module’s

output and extracts temperature value into a suitable number in Celsius scale and control

the fan speed by using PWM. And last part of system shows humidity and temperature on LCD

and Fan driver.


Here in this project, we have used a sensor module namely DHT11 that already has discuss our
previous project namely “Humidity and Temperature Measurement using Arduino”. Here

we have only used this DHT sensor for sensing temperature, and then programmed our arduino

according to the requirements.

Working on this project is very simple. We have created PWM at pwm pin of arduino and

applied it at base terminal of the transistor. Then transistor creates a voltage according to the

PWM input.

Fan speed and PWM values and duty cycles values are showing in given table

Temperature Duty Cycle PWM Value Fan Speed


Less 26 0% 0 Off

26 20 % 51 20%

27 40% 102 40%

28 60% 153 60%

29 80% 204 80%

Greater 29 100% 255 100%

What is PWM? PWM is a technique by using we can control the voltage or power. To

understand it more simply, if you are applying 5 volt for driving a motor then motor will moving

with some speed, now if we reduces applied voltage by 2 means we apply 3 volts to motor then

motor speed also decreases. This concept is used in the project to control the voltage using
PWM. (To understand more about PWM, check this circuit: 1 Watt LED Dimmer)
The main game of PWM is digital pulse with some duty cycle and this duty cycle is responsible

for controlling the speed or voltage.

Suppose we have a pule with duty cycle 50% that means it will give half of voltage that we

apply.

Formula for duty cycle given below:

Duty Cycle=  Ton/T

Where T= total time or Ton+Toff

And Ton= On time of pulse (means 1 )


And Toff= Off time of pulse (means 0)
 
Arduino Temperature Controlled Fan Circuit Diagram 
Connections of this temperature controlled fan circuit is very simple, here a liquid crystal

display is used for displaying temperature and Fan speed Status. LCD is directly connected to
Arduino in 4-bit mode (Check this tutorial for more details: LCD Interfacing with Arduino

Uno). Pins of LCD namely RS, EN, D4, D5, D6 and D7 are connected to Arduino digital pin
number 7, 6, 5, 4, 3 and 2. And a DHT11 sensor module is also connected to digital pin 12 of

Arduino. Digital pin 9 is used for controlling fan speed through the transistor.
 

If you are looking for something simple and more cost-effective you can check out
the temperature controlled LED using LM35 and Temperature controlled Automatic AC

switch projects, both of them are very easy to built and does not need a microcontroller. 
 

Arduino Code for temperature-controlled fan 


First, we include the library for LCD and DHT sensor and then define pin for lcd, dht sensor and

for fan.

Then initialize all the things in setup loop. And in loop by using dht function reads DHT sensor

and then using some dht functions we extract temperature and display these on LCD.

After this we compare the temperature with pre define temperature digit and then generate PWM

according to the temperature value.


For generating PWM we have used “analogWrite(pin, PWM value)” fuction in 8 bit. Mean if

PWM value is equivalent of analog value. So if we need to generate 20% of duty cycle then we

pass 255/5 value as PWM in “analogWrite” Function. 

Code
#include<dht.h>      // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
#define dht_dpin 12 
dht DHT;
#define pwm 9
byte degree[8] = 
       {
                0b00011,
                0b00011,
                0b00000,
                0b00000,
                0b00000,
                0b00000,
                0b00000,
                0b00000
              };
void setup()
{
 lcd.begin(16, 2);
 lcd.createChar(1, degree);
 lcd.clear();
 lcd.print("   Fan Speed  ");
 lcd.setCursor(0,1);
 lcd.print("  Controlling ");
 delay(2000);
 analogWrite(pwm, 255);
 lcd.clear();
 lcd.print("Circuit Digest ");
 delay(2000);
}
void loop()
{
  DHT.read11(dht_dpin);
  int temp=DHT.temperature;
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.print(temp);   // Printing temperature on LCD
  lcd.write(1);
  lcd.print("C");
  lcd.setCursor(0,1);
  if(temp <26 )
    { 
      analogWrite(9,0);
      lcd.print("Fan OFF            ");
      delay(100);
  }
    
    else if(temp==26)
  {
      analogWrite(pwm, 51);
      lcd.print("Fan Speed: 20%   ");
      delay(100);
  }
    
     else if(temp==27)
  {
      analogWrite(pwm, 102);
      lcd.print("Fan Speed: 40%   ");
      delay(100);
  }
    
     else if(temp==28)
  {
      analogWrite(pwm, 153);
      lcd.print("Fan Speed: 60%   ");
      delay(100);
  }
    
    else if(temp==29)
  {
      analogWrite(pwm, 204);
      lcd.print("Fan Speed: 80%    ");
      delay(100);
  }
     else if(temp>29)
  {
      analogWrite(pwm, 255);
      lcd.print("Fan Speed: 100%   ");
      delay(100);
    } 
  delay(3000);
}
Video
Tags
arduino
 
arduino uno
 
DHT11
 
sensors

Comments
Submitted by Mohamed on Mon, 08/10/2015 - 03:05
Permalink
Mistake in diagram
Diagram mistake is that there is no ground in fan motor circuit

 Log in or register to post comments

Submitted by vikram on Mon, 08/31/2015 - 00:11


Permalink
something wrong with dht library
arduino ide is showing compilation error due to the dht library. kindly specify the library used in
your program code as dht.h is not a valid library

 Log in or register to post comments


Submitted by Jayant on Mon, 09/14/2015 - 22:36
In reply to something wrong with dht library by vikram
Permalink
Please install the DHT
Please install the DHT library properly, and make sure that dht.h file is there in the folder.
Remember that header file name is case sensitive, if file in the DHT library folder is DHT.h then
use DHT.h not dht.h

 Log in or register to post comments

Submitted by ameer on Mon, 11/02/2015 - 01:01


In reply to Please install the DHT by Jayant
Permalink
i already change dht.h to DHT
i already change dht.h to DHT.h but i got another error:
pwn_fan.ino:6:1: error: 'dht' does not name a type
pwn_fan.ino: In function 'void loop()':
pwn_fan.ino:39:6: error: expected unqualified-id before '.' token
pwn_fan.ino:40:15: error: expected primary-expression before '.' token
pwn_fan.ino:87:14: error: expected '}' at end of input
Error compiling.
how can i fix this? can you help me please... thanks in advance

 Log in or register to post comments

Submitted by teja on Fri, 02/02/2018 - 19:23


In reply to i already change dht.h to DHT by ameer
Permalink
how do you rectified your error ,please tell me,i am doing that
how do you rectified your error ,please tell me,i am doing that project

 Log in or register to post comments

Submitted by omar on Sun, 12/06/2015 - 04:57


In reply to Please install the DHT by Jayant
Permalink
help
please help error library dht to DHT

 Log in or register to post comments

Submitted by NISHANt on Sun, 03/18/2018 - 00:11


In reply to Code is working fine, please by Abhishek
Permalink
regarding project
bro please give me the code and all detail how to do pleass

 Log in or register to post comments

Submitted by KAUSHAL KISHORE on Tue, 06/05/2018 - 20:20


In reply to Code is working fine, please by Abhishek
Permalink
arduino code
plz send me rectified code . i m doing this project . i requst you plz send me code which is edited
by you

 Log in or register to post comments

Submitted by saleem on Tue, 10/27/2015 - 12:54


Permalink
hello, i want to ask. how did
hello, i want to ask. how did you show the data on digital oscilloscope? is it the interface that
allow us to manipulate the temperature setting or anything like that? thank you

 Log in or register to post comments

Submitted by Hajara on Thu, 10/29/2015 - 01:58


Permalink
pls could you modify the
pls could you modify the codes if a heater is added to the system in other to activate if temp is
low. thanks

 Log in or register to post comments

Submitted by saddam4201 on Mon, 11/02/2015 - 11:12


Permalink
Compling.....
There is no problem in compiling the code. You need to add DHT library in arduono ide library
folder.
Thank you

 Log in or register to post comments

Submitted by omi on Wed, 11/25/2015 - 13:20


Permalink
the fan still running in same speed
I've already run your codes without any error... but the fan spinning at the same speed even
though in different temperature. could you help me with the problem please... this technique is so
crucial to my project. thank you

 Log in or register to post comments

Submitted by saddam4201 on Thu, 11/26/2015 - 11:34


In reply to the fan still running in same speed by omi
Permalink
solution
Please check your connections and try to change your transistor.

 Log in or register to post comments

Submitted by syafiq on Thu, 12/17/2015 - 19:36


Permalink
hello.. i have problem.. in
hello.. i have problem.. in my proteus, does not have DHT11. How to put that sensor in my
proteus library. anyone can help me?

 Log in or register to post comments

Submitted by Maddy on Fri, 01/01/2016 - 18:52


In reply to hello.. i have problem.. in by syafiq
Permalink
Proteus 8 supports the DHT
Proteus 8 supports the DHT library, no need to add. For Proteus 7 you can find the DHT library
on Internet and can add.

 Log in or register to post comments

Submitted by dhea on Fri, 01/01/2016 - 18:10


Permalink
Cannot Compile
hallo, by the way thank you for your shared
i have a problem when i want to compile the source code, arduino says 'dht' was not name a type
what should i do?
please your advice
thank you anyway

 Log in or register to post comments

Submitted by Maddy on Fri, 01/01/2016 - 18:43


In reply to Cannot Compile by dhea
Permalink
Please check the above
Please check the above comments...

 Log in or register to post comments

Submitted by jpaul on Thu, 02/11/2016 - 17:22


Permalink
Error
please assist,
Even after downloading and installing the DHT file,when i compile the code,i get this error
Exit status 1
'dht' does not name a type
Can you assist please? Thank you

 Log in or register to post comments

Submitted by Jayant on Tue, 02/23/2016 - 22:28


In reply to Error by jpaul
Permalink
Please read all the above
Please read all the above comments carefully, and install the DHT library properly, and make
sure that dht.h file is there in the folder. Remember that header file name is case sensitive, if file
in the DHT library folder is DHT.h then use DHT.h not dht.h

 Log in or register to post comments

Submitted by Rakesh on Sat, 02/13/2016 - 20:13


Permalink
Output
Does anyone compiled this using proteus if done Please mail to me Thanks in advance. please
this is my final year project.you can save my ass.

 Log in or register to post comments

Submitted by Balwant deshmukh on Sun, 04/03/2016 - 15:58


Permalink
Garbage value
Display shows garbage value and fan does not rotate
connection and program written as per given
And compiled and uploaded properly

 Log in or register to post comments


Submitted by saddam khan on Mon, 04/04/2016 - 13:06
In reply to Garbage value by Balwant deshmukh
Permalink
Use well regulated Power
Use well regulated Power supply for your circuit for better results.

 Log in or register to post comments

Submitted by AZDD on Sun, 04/10/2016 - 18:36


Permalink
when i compile, it shows me
when i compile, it shows me this error:
'class DHT' has no member named 'read11'
can someone tell me what does it mean?

 Log in or register to post comments

Submitted by saddam khan on Thu, 04/21/2016 - 18:07


In reply to when i compile, it shows me by AZDD
Permalink
Add dht11 library for arduino
Add dht11 library for arduino in arduino ide.
then try again.
best of luck

 Log in or register to post comments

Submitted by Austin Melhado on Mon, 05/16/2016 - 21:58


Permalink
FAN connection
it terms of the diagram connection for the fan, is everything correct does there need a ground
added to the fan as mention in the first comment or is everything correct

 Log in or register to post comments

Submitted by Maddy on Sat, 06/11/2016 - 18:30


In reply to FAN connection by Austin Melhado
Permalink
Circuit is correct, used
Circuit is correct, used Motor is DC motor and its Ground is connected to negative terminal of
Battery through Transistor 2N2222

 Log in or register to post comments


Submitted by Dhruv Mehta on Sat, 06/04/2016 - 17:12
Permalink
friend this connection is for
friend this connection is for servo ,motor u need to connect fan and wen u connect fan it is
nessery to give ground to the ground in auredino if u do dis ur project wil run sucessfully and it
will work properly

 Log in or register to post comments

Submitted by zoya sharma on Wed, 03/21/2018 - 20:11


In reply to friend this connection is for by Dhruv Mehta
Permalink
can you please send me full
can you please send me full code of this project

 Log in or register to post comments

Submitted by Sachin on Sun, 06/12/2016 - 03:57


Permalink
Please explain the resistor parts
Please can you explain the resistor parts? To where the two resistors are exactly connecting to?
It's not very clear for me and I need to do this as my project so please help?

 Log in or register to post comments

Submitted by Abhishek on Sat, 07/09/2016 - 16:30


In reply to Please explain the resistor parts by Sachin
Permalink
Please check the connections
Please check the connections in Circuit Diagram.

 Log in or register to post comments

Submitted by Mohammad Shoaib on Mon, 07/18/2016 - 17:22


Permalink
Code
I have same problem that is:
_12:6: error: 'dht' does not name a type
_12.ino: In function 'void loop()':
_12:39: error: 'DHT' was not declared in this scope
please help me as i am beginner about arduino.
I need final working code.Please please help me.
[]
 Log in or register to post comments

Submitted by Maddy on Sat, 08/20/2016 - 15:39


In reply to Code by Mohammad Shoaib
Permalink
Install the DHT library
Install the DHT library properly, go through the above comments to install DHT library properly.

 Log in or register to post comments

Submitted by tejas on Thu, 03/23/2017 - 22:09


In reply to Install the DHT library by Maddy
Permalink
Pls give the link to install
Pls give the link to install dht library

 Log in or register to post comments

Submitted by Jay on Tue, 08/02/2016 - 04:15


Permalink
Instead of using a battery,
Instead of using a battery, can I use a 12V power adapter and have the ground from the fan into
ground on my board, and the 12v power running through the 2n2222 transistor and the power
from fan into the other end of the 2n2222 transistor?

 Log in or register to post comments

Submitted by Maddy on Sat, 08/20/2016 - 15:41


In reply to Instead of using a battery, by Jay
Permalink
You need to check the
You need to check the datasheet of all the components for their power and current rating before
using 12v Adapter, it may burn some components.

 Log in or register to post comments

Submitted by Charlie on Thu, 08/25/2016 - 14:39


Permalink
Are there any alternative for
Are there any alternative for 9v Battery ? i find it quite pricey haha
Thanks . Will AA batteries do ?

 Log in or register to post comments


Submitted by Abhishek on Tue, 09/20/2016 - 19:43
In reply to Are there any alternative for by Charlie
Permalink
Although the 9v batteries are
Although the 9v batteries are very cheap, but you can use 4 or 6 AA batteries for simple DC fan.

 Log in or register to post comments

Submitted by samuel on Thu, 09/01/2016 - 20:53


Permalink
will the be a difference if I
will the be a difference if I use lm35 as my sensor instead of DHT11 ......I use the exact circuit l

 Log in or register to post comments

Submitted by deadpool on Mon, 10/03/2016 - 16:07


Permalink
Sir , I'm having a problem I
Sir , I'm having a problem I tried to compile the code but there was an error "LiquidCrystal" does
not name a type I hope you could help me here thank you

 Log in or register to post comments

Submitted by Maddy on Fri, 10/07/2016 - 22:38


In reply to Sir , I'm having a problem I by deadpool
Permalink
You may have forgotten to
You may have forgotten to include the LiquidCrystal.h library, please check and always use
latest version of Arduino IDE.

 Log in or register to post comments

Submitted by Rajesh on Sun, 10/09/2016 - 23:06


Permalink
I got an error stating - " no
I got an error stating - " no matching function for call to 'DHT::DHT()' "
Please help me out.

 Log in or register to post comments

Submitted by Prasanna on Mon, 10/24/2016 - 16:00


Permalink
I did all my connections
I did all my connections correct but not printing and not able to control
 Log in or register to post comments

Submitted by Salman on Sat, 10/29/2016 - 07:30


Permalink
Instead of DHT11. Is it
Instead of DHT11. Is it possible to use DHT22. I have read in many articles, DHT22 have more
accuracy. So I guess DHT22 will be more useful. If it is possible to use, will be there any change
in coding and other electronic components used in the circuit ??

 Log in or register to post comments

Submitted by Abhishek on Thu, 12/01/2016 - 20:16


In reply to Instead of DHT11. Is it by Salman
Permalink
Yes you can use DHT22 with
Yes you can use DHT22 with this circuit. It is recommended to check its datasheet for its pins
and power requirement.

 Log in or register to post comments

Submitted by Quinno on Wed, 11/09/2016 - 17:27


Permalink
DC FAN
Can I know what is the voltage of the DC fan used in this project?

 Log in or register to post comments

Submitted by Shubhang kedia on Thu, 11/17/2016 - 22:48


Permalink
fan speed not controlling
i did all the things same as said but my fan moves at constant speed.....it doesn't even switches
off when temperature falls below the limit and its speed doesn't increases when temperature
increases...
PLEASE HELP..

 Log in or register to post comments

Submitted by mumin on Mon, 11/28/2016 - 04:13


Permalink
Please someone send me your
Please someone send me your runnable code?
thanks

 Log in or register to post comments


Submitted by redstone on Wed, 03/08/2017 - 02:01
In reply to Nice work, exactly what I was by Alain
Permalink
I have facing an error to
I have facing an error to dht11 DHT11; I get an error no matching function for call to
'DHT11::DHT11()'

 Log in or register to post comments

Submitted by PM on Sun, 03/26/2017 - 23:15


In reply to Nice work, exactly what I was by Alain
Permalink
Most Helpful Comment Here!!
Thanks a lot!
It's only after I read your comment I was able to get my fan to stop spinning at a constant speed
for all temp.
Great project,very useful.
So yeah, if your error is that fan is spinning at constant speed connect negative of fan to collector
of 2222 ,negative of 9V to emitter and a wire from emitter to GND line of arduino.

 Log in or register to post comments

Submitted by Bill Frick on Wed, 12/27/2017 - 23:00


In reply to Nice work, exactly what I was by Alain
Permalink
DHT libraries
New to this environment and struggling with finding the right combination of library and code
statements.  The constant appears to be  'dht' does not name a type.  The library you refer to does
not appear in the library manager - updated, renamed or absorbed into a larger one ?  
I was hoping this 'Temperature controlled Fan' would be working on my Solar furnace by now
but this code problem has held me up 2 long and frustrating days.....
Any more specific direction on this library/code would be appreciated.

 Log in or register to post comments

Submitted by sai vasavi on Mon, 02/06/2017 - 16:01


Permalink
We are doing this project,
We are doing this project,.while running this code we are getting an error like (fatal error:dht.h:
No such file or directory.
Compilation terminated

 Log in or register to post comments


Submitted by avvilla on Sat, 03/04/2017 - 15:36
Permalink
automatic fan speed
there is no interfacing to the fan/motor .. pls help me guys..

 Log in or register to post comments

Submitted by Shankar on Thu, 03/09/2017 - 18:03


Permalink
Sensor
Why should we use DHT 11 or DHT 22 or LM 35 or any what is the reason behind that and you
use the dht11 is there any consumption or anything else.....

 Log in or register to post comments

Submitted by samrudhi patil on Mon, 03/20/2017 - 10:55


Permalink
please help me in code i got
please help me in code i got error in dht library .so please send the entire correct code as early as
possible.

 Log in or register to post comments

Submitted by Kuldeep Detroja on Sun, 03/26/2017 - 11:32


Permalink
simulation
In proteus it shows these errors: 1.cannot find model file 'DHTXX.MDF'
2.Missing interface model 'DHTXXITF' IN U1 #P
3. PIN 'DATA' is not modelled
4. PIN 'VDD' is not modelled
5. PIN 'GND' is not modelled
Please please help me to solve all these errors and run simulation of this project.

 Log in or register to post comments

Submitted by simran on Fri, 03/31/2017 - 19:36


Permalink
It's working! But I don't
It's working! But I don't understand meaning of those byte degree values in the code. Plz explain
me==>
byte degree[8] =
{
0b00011,
0b00011,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};

 Log in or register to post comments

Submitted by Adithya on Sun, 04/02/2017 - 15:13


Permalink
Compilation error with dht header
As Sai vasavi mentioned above, even I'm getting the same error:dht.h: No such file or directory.
Compilation terminated. Please send the exact link of the library and executable code asap as it is
to be submitted tomorrow.

 Log in or register to post comments

Submitted by Adithya on Sun, 04/02/2017 - 19:06


Permalink
:D phew!! Kudos... it worked
:D phew!! Kudos... it worked finally. No changes required in the code. Purely depends on
installing dht library.
Thanks guys.

 Log in or register to post comments

Submitted by Uzair on Wed, 05/03/2017 - 01:19


In reply to :D phew!! Kudos... it worked by Adithya
Permalink
Where did you get that
Where did you get that library? Please tell me how you installed that library? This is for my
project. Thanks for your help :)

 Log in or register to post comments

Submitted by Sya on Sun, 09/10/2017 - 16:11


Permalink
what is the voltage of the DC
what is the voltage of the DC fan used in this project? If the voltage of fan is 5 v , and used
battery 9v, so we must use voltage regulator or not?

 Log in or register to post comments


Submitted by Sya on Mon, 09/11/2017 - 17:41
Permalink
Can i know how volt of dc fan
Can i know how volt of dc fan, 12v or 5v.

 Log in or register to post comments

Submitted by ima on Thu, 09/28/2017 - 15:19


Permalink
hi. please help me. what does
hi. please help me. what does byte degree coding means? i dont get it

 Log in or register to post comments

Submitted by Debasish Kalita on Sun, 10/08/2017 - 16:20


Permalink
i dont know the meaning of the error ;please help me
Arduino: 1.8.1 (Windows 8.1), Board: "Arduino/Genuino Uno"
C:\Users\Debasish Kalita\Documents\Arduino\random\random.ino:1:50: fatal error: dht.h: No
such file or directory
#include<dht.h> // Including library for dht
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

 Log in or register to post comments

Submitted by Aswinth Raj on Mon, 10/09/2017 - 15:04


In reply to i dont know the meaning of the error ;please help me by Debasish Kalita
Permalink
Download and add dht.g
Download and add dht.g library from Github to ArduinoIDE 

 Log in or register to post comments

Submitted by Antu on Wed, 10/25/2017 - 22:34


Permalink
if i am using DHT22 sensor
if i am using DHT22 sensor instead of DHT11 then what will be the change in the code....please
solve my problem
 Log in or register to post comments

Submitted by Anonymous on Sat, 03/10/2018 - 21:16


Permalink
Arduino
Can I use arduino nano instead of uno?
and Can I use a thermistor instead of dht11?

 Log in or register to post comments

Submitted by Anonymous on Sat, 03/10/2018 - 21:26


Permalink
what is the volatge of the dc
what is the volatge of the dc fan used? 5v or 9v?

 Log in or register to post comments

Submitted by akira on Sun, 03/11/2018 - 10:54


Permalink
Please how to fix this error
Please how to fix this error
#include <Adafruit_Sensor.h>
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno

 Log in or register to post comments

Submitted by Danyaal Tayyabkhan on Tue, 03/13/2018 - 06:18


Permalink
error
i get this error:
Arduino: 1.8.5 (Mac OS X), Board: "Arduino/Genuino Uno"
In file included from /Users/DanyaalT/Documents/Arduino/libraries/DHT-sensor-library-
master/DHT_U.cpp:22:0:
/Users/DanyaalT/Documents/Arduino/libraries/DHT-sensor-library-master/DHT_U.h:25:29:
fatal error: Adafruit_Sensor.h: No such file or directory
#include <Adafruit_Sensor.h>
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
what can i do

 Log in or register to post comments

Submitted by AISHA on Tue, 03/13/2018 - 13:06


In reply to error by Danyaal Tayyabkhan
Permalink
You did not add the adafruit
You did not add the adafruit_sensor library  to your Arduino IDE correctly.. Try adding it again
follow the tutorial to know how it is done 

 Log in or register to post comments

Submitted by mahirtoky on Sat, 03/17/2018 - 12:56


Permalink
display doesn't show any
display doesn't show any value rather contains only box.please need urgent suggestion.Is the
motor is 9v dc

 Log in or register to post comments

Submitted by Aswinth Raj on Tue, 04/10/2018 - 07:23


In reply to The diagram shown is wrong. by Ishtiaque
Permalink
Thank a ton Ishtiaque
Thank a ton Ishtiaque
It should be useful for people here

 Log in or register to post comments

Submitted by syahmi on Tue, 02/12/2019 - 22:27


In reply to The diagram shown is wrong. by Ishtiaque
Permalink
Other pins?
how about the other pins on lcd?

 Log in or register to post comments

Submitted by Clyde on Tue, 04/10/2018 - 19:33


Permalink
The fan keeps rotating at a
The fan keeps rotating at a constant speed, done all the things mentioned above pls help

 Log in or register to post comments

Submitted by Utkarsh on Tue, 04/02/2019 - 19:38


In reply to The fan keeps rotating at a by Clyde
Permalink
About Code
Hii @Clyde ,, your query is excatly correct, fan keeps rotaing at constant speed. It means Battery
supply is directly given to fan.
Means there is no use of code for changing fan speed.
please help us

 Log in or register to post comments

Submitted by Aswinth Raj on Fri, 04/05/2019 - 14:57


In reply to About Code by Utkarsh
Permalink
No it does not mean battery
No it does not mean battery is connected directly fan. As you can see there is a switching
transistor in-between the fan and battery. If your fan does not reduce speed it means the
transistor is not switching.
Try turning off the fan completly to check if the transistor is working

 Log in or register to post comments

Submitted by Mohammad Adil on Thu, 04/12/2018 - 23:58


Permalink
Please reply, Code run but proteus shows 'can't find DHTXX. MDF
Please anyone reply
I have added dht file in library of arduino and also for proteus, so finally code successfully run in
arduino compiler but proteus shows following two error
* cannot find model file 'DHTXX. MDF
* Simulation failed due to net list linker error

 Log in or register to post comments

Submitted by aniqee on Wed, 04/18/2018 - 19:50


Permalink
i followed the program...but
i followed the program...but why the temperature is not accurate?
48 degree celcius in my room....

 Log in or register to post comments


Submitted by Darshan on Sat, 04/28/2018 - 12:57
Permalink
Code error
Even though i have installed the DHT library files,there are lots of error while compiling the
program please do correct the program and upload it .

 Log in or register to post comments

Submitted by KARIM on Tue, 05/15/2018 - 23:05


Permalink
can you please send me full
can you please send me full code of this project

 Log in or register to post comments

Submitted by Aswinth Raj on Wed, 05/16/2018 - 18:38


In reply to can you please send me full by KARIM
Permalink
The full code of this
The full code of this projects is already given in this page at the bottom of the explanation 

 Log in or register to post comments

Submitted by Lachie on Tue, 08/21/2018 - 08:01


Permalink
Arduino: 1.8.5 (Windows Store
Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"
dht11 DHT11;
^
In function 'void loop()':
sketch_aug17b:34: error: request for member 'read' in '11', which is of non-class type 'int'
DHT11.read(DHT11pin);
^
sketch_aug17b:34: error: 'DHT11pin' was not declared in this scope
DHT11.read(DHT11pin);
^
sketch_aug17b:35: error: request for member 'temperature' in '11', which is of non-class type 'int'
int temp=DHT11.temperature;
^
'dht11' does not name a type
Any suggestions for a solution?

 Log in or register to post comments

Submitted by Angikar on Thu, 09/06/2018 - 21:30


Permalink
lcd
code is executing properly but the lcd does not show any data. Have tried with multiple lcds but
shows the same thing....please help!!

 Log in or register to post comments

Submitted by tolga on Mon, 09/17/2018 - 15:36


Permalink
Multiple motors
Dear Saddam, thanks for the great share. It is working perfect. Just wanted to know how many
identical items can I connect to this PWM ? Or how can I run multiple PWM circuits for multiple
fans ? Thanks 

 Log in or register to post comments

Submitted by Jayant on Tue, 09/18/2018 - 18:56


In reply to Multiple motors by tolga
Permalink
It depends on how long you
It depends on how long you are running the wires and how much current is being drawn. If you
powering multiple devices an Op-Amp buffer circuit is recommended 

 Log in or register to post comments

Submitted by tolga on Thu, 10/31/2019 - 12:06


In reply to It depends on how long you by Jayant
Permalink
3 fans
I want to control the speed of 3 fans (Not seperately, they will all run same speed regarding the
enviroment temperature) They are all 12v 0,30A. Can I connect all 3 to the same PWM circuit ?
In other words how many amperes can I run through the circuit ? Thanks

 Log in or register to post comments

Submitted by Tim Verkerk on Tue, 11/27/2018 - 09:33


Permalink
After messing around with
After messing around with issues as descibed in the comments I got it working with these
libraries and code below. Hope this helps.
Libraries:
DHT_sensor_library 1.3.0
Adafruit_Unified_Sensor 1.0.2
Code:
//**TEMPERATURE CONTROLLED FAN**
//Authored by Saddam of Circuit Digest 03/08/18
//Modified to work with later DHT libraries by Tim Verkerk 27/11/18
#include<DHT.h>      // Including library for DHT
#include<DHT_U.h>
#include<LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
#define DHTPIN 12 
#define DHTTYPE DHT11
DHT dht(DHTPIN,DHTTYPE);
#define pwm 9
byte degree[8] = 
       {
                0b00011,
                0b00011,
                0b00000,
                0b00000,
                0b00000,
                0b00000,
                0b00000,
                0b00000
              };
void setup()
{
 lcd.begin(16, 2);
 lcd.createChar(1, degree);
 lcd.clear();
 lcd.print("   FAN SPEED  ");
 lcd.setCursor(0,1);
 lcd.print("  CONTROLLER ");
 delay(2000);
 analogWrite(pwm, 255);
 lcd.clear();
 lcd.print("STARTING ");
 delay(2000);
}
void loop()
{
  int temp= dht.readTemperature();
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.print(temp);   // Printing temperature on LCD
  lcd.write(1);
  lcd.print("C");
  lcd.setCursor(0,1);
  if(temp <26 )
    { 
      analogWrite(9,0);
      lcd.print("Fan OFF            ");
      delay(100);
  }
    
    else if(temp==26)
  {
      analogWrite(pwm, 51);
      lcd.print("Fan Speed: 20%   ");
      delay(100);
  }
    
     else if(temp==27)
  {
      analogWrite(pwm, 102);
      lcd.print("Fan Speed: 40%   ");
      delay(100);
  }
    
     else if(temp==28)
  {
      analogWrite(pwm, 153);
      lcd.print("Fan Speed: 60%   ");
      delay(100);
  }
    
    else if(temp==29)
  {
      analogWrite(pwm, 204);
      lcd.print("Fan Speed: 80%    ");
      delay(100);
  }
     else if(temp>29)
  {
      analogWrite(pwm, 255);
      lcd.print("Fan Speed: 100%   ");
      delay(100);
    } 
  delay(3000);
}
 

 Log in or register to post comments

Submitted by Hiro_Hamada on Thu, 12/06/2018 - 15:57


In reply to After messing around with by Tim Verkerk
Permalink
nice job
nice job

 Log in or register to post comments

Submitted by Jericho Yang on Mon, 11/18/2019 - 08:36


In reply to After messing around with by Tim Verkerk
Permalink
DC Fan
Hello, may I ask how much voltage does your DC Fan use. Is it 12 volts?

 Log in or register to post comments

Submitted by Prasanth on Tue, 04/02/2019 - 08:19


Permalink
Some errors are there in code
Could you please fix the code which is in the given above. They are so many errors like dht is
not a data type and '.' is not taken before

 Log in or register to post comments

You might also like