Digital humidity sensor with LCD display using PIC microcontroller
Digital humidity sensor with LCD display is used to measure the relative percentage of water vapors in air. HS1101 capacitive humidity sensor is interfaced with PIC16F877A microcontroller to measure humidity and LCD is used to display percentage humidity in the air. For humans, there is a certain limit for water vapors presence in the air. Above that limit relative humidity may cause problems to human health.
Applications of digital humidity sensors
Humidity sensors have much application in industry and domestic areas. Humidity means the presence of water vapors in air. Percentage of water vapors in the air should be within safety limit. Otherwise, It has harmful physical and chemical effects on human beings and also in industrial products. Humidity sensors have major applications in agriculture, chemical, oil, gas, and medical industry. For example in agriculture industry humidity sensor is used to measure moisture in fields. There are also many other application of humidity sensor. You can search for them on Google.
digital Humidity sensor selection
When you search on Google, you will come across many humidity sensors. All these humidity sensors have their advantage and disadvantage. But I used capacitive HS1101 humidity sensor in this project. What is meant by capacitive humidity sensor? All capacitive sensors give output in capacitive form. They change their capacitance with respect to change in sensing parameter like in HS1101 sensor sensing parameter is the number of water vapors in air. The reason why I used this humidity sensor? Because
- It can be used for highly sensitive applications.
- less cost
- easy to interface with a microcontroller with small extra circuitry
- No calibration is required
- It can be easily used for home appliances and industrial control system.
How to use HS1101 digital humidity sensor
HS1101 is a capacitive humidity sensor, so it can be used with a 555 timer circuit to generate a square wave of different frequency. I assume you know about the 555 timer IC and its use.
As shown in the above figure, a variable capacitor is used in place of humidity sensor for simulation purpose. Because the HS1101 simulation model is not available in Proteus. Above circuit is used as a signal conditioning circuit to convert one form of a parameter to its other proportional parameter so that it can be easily interfaced with any digital system or microcontroller. It is not possible for any microcontroller to read the change in capacitance directly. That’s why the above circuit is used to convert changing capacitance of HS1101 into square wave whose frequency changed according to change in capacitance.
I have already posted a tutorial on how to measure square wave using PIC 16F877A microcontroller. I recommend you to go through the article before going further in this project.
Now you know we can easily measure square wave frequency with the microcontroller. But now the question is how we will convert frequency back into relative humidity? There is a proper relationship between humidity and frequency. Go through data sheet of HS1101 humidity sensor to know more about HS1101 sensor.
components list for digital humidity sensor
Category,Reference,Value,Order Code Resistors,"R1",1732k, Resistors,"R2",549k, Resistors,"R3",1k, Resistors,"R4",49.9k, Resistors,"R44",10k, Integrated Circuits,"U1",NE555, Integrated Circuits,"U2",PIC16F877A, Miscellaneous,"LCD1",LM016L, Miscellaneous,"SENSOR",humidity sensor HS1101, crystal 20mhz
Circuit diagram of a digital humidity sensor
Complete circuit diagram of Digital humidity sensor with LCD display:
Simulation results using pulse generator in proteus:
As shown in above diagram humidity is shown in percentage. 27% humidity mean air contains 27% water vapors. so you can take control actions according to your requirement. By little bit modification in this project you can also control anything according to change in relative humidity. let me know what is your requirement I will be happy to provide you solution.
Video lecture digital humidity meter
Code of digital humidity sensor measurement using pic
Code is written in mikro c for pic:
//***************microcontrollerslabhub@gmail.com*********** // LCD module connections sbit LCD_D7 at RB2_bit; sbit LCD_D6 at RB3_bit; sbit LCD_D5 at RB4_bit; sbit LCD_D4 at RB5_bit; sbit LCD_EN at RB6_bit; sbit LCD_RS at RB7_bit; sbit LCD_D7_Direction at TRISB2_bit; sbit LCD_D6_Direction at TRISB3_bit; sbit LCD_D5_Direction at TRISB4_bit; sbit LCD_D4_Direction at TRISB5_bit; sbit LCD_EN_Direction at TRISB6_bit; sbit LCD_RS_Direction at TRISB7_bit; // End LCD module connections //******************************frequency meter variables******* int value,freq,humidity; char humid[7]; //************************************************************** void data_converstion(void) { IntToStr(humidity, humid); } void display1(void) { lcd_out(1,1,"Humidity = "); lcd_out(1,13, Ltrim(humid)); Lcd_Chr_Cp('%'); Lcd_Chr_Cp(' '); } void interrupt(void) // high portD { if(T1CON.TMR1ON==0) { T1CON.TMR1ON=1; // turn on the timer1 INTCON.INTF = 0; // clear the interrupt flag } else if(T1CON.TMR1ON==1) { T1CON.TMR1ON=0; // turn off the timer1 value=(TMR1H<<8)|(TMR1L); INTCON.INTE = 0; //Enable RB0/INT external Interrupt freq=(5018035/value); humidity = 565 - freq/13; // freq = freq /13.18; //freq = 100 - freq; TMR1H=0; TMR1L=0; INTCON.INTE = 1; //Enable RB0/INT external Interrupt INTCON.INTF = 0; // clear the interrupt flag //freq=0; } } void main() { long count; count=0; TMR1H=0; TMR1L=0; // intialization of timer one prescalar and internal clock INTCON.GIE = 1; //Enable Global Interrupt INTCON.INTE = 1; //Enable RB0/INT external Interrupt OPTION_REG.INTEDG = 0; //Interrupt on rising edge ADC_Init(); Lcd_Init(); // Initialize LCD freq=0; Lcd_Cmd(_LCD_CLEAR); // Clear display lcd_cmd(_LCD_CURSOR_OFF); lcd_out(1,4,"GREEN HOUSE"); lcd_out(2,6,"SYSTEM"); delay_ms(1000); Lcd_Cmd(_LCD_CLEAR); // Clear display while(1) { data_converstion(); display1(); } }
If you have any problem after reading this article, comment on this post with your problem and if you need complete circuit diagram, simulation and hex file of this project, comment on this post with your email address.
If you feel this article helps you in getting some knowledge kindly don’t forget to share it with your friends on social media.
enjoy coding 🙂
i want to know how u calculate the percentage from the frequency
thanx
I have used the formula which is given in HS1101 humidity sensor data sheet. Formula is used to convert humidity % into frequency and vice versa
Hi!
Bilal I need your help can you help me to make codes for count down timer, temperature and humidity in one micro-controller I tried to do that but there is interference one not working when all reads at the same time please you can email me the hex file for that.
Thanks and kind regards
Ally
you can email me the hex file for that
hey can u give me the full schematic and source code for this project?
Hi!
I downloaded the code from Bilal Project for humidity sensor but is not working is not giving me 27%
Please can any one give me the formula for calculating frequency in this circuit.
and Bilal can you tell me how you get 27%?
Thanks
Ally
Hi Reeza!
Sorry I generate codes from different projects and I build it in one micro controller so please if you know to separate codes help me.
I need to make Incubator to control temperature,humidity and turning of the eggs automatic so if you any one can help me here the codes I will be thankfully to him.
Regards
Ally
Assalamoalikum
brother what is the capacitence of hs1101 sensor at 0% humidity and at 100% humidity??
and what is the maximum frequency generated by 555 at 100% humidity??
Dear Mr. Bilal
I would like to have the code (hex file) for humidity controller and temperature controller.
Thanks.
Raj
hi
please tell me the program used for coding
tnx
and give me the hex ofprogram
very very tnx for solving my problem
hi
if any one have the hex of program please send to my mail
ali_game_2010@yahoo.com
tnx all
Hello there Bilal. Can you email me complete circuit diagram, simulation and hex file of this project? please let me know that you email-ed me. Please. this is my email ikhlasnash@gmail.com
hi can i use Lm331 for convert frequency to volt in this project
Can you write equation for humidity and frequency because idont understand these please
hi
if any one have the hex of program please send to my mail
akifdenizoglu@gmail.com
i need complete code
Please be so kind and email me
the whole project and code
I have proteus and i would like to try it
Thank you
hi Bilal. im working on something like this, where i need to get the frequency from the timer. can you email the whole project because i would like to try this out. thanks brother
krazy2107@gmail.com
hi code and circuit diagram is already available in post
i need complete code of humidity use key pad control only four key start,use,enter,program .help me
Please email me the whole project and code
Thank you
Please email me the whole project and code
Thank you
georgejobin51@gmail.com
i need hex.file for humidity sensor
Can you please send me the hex file of this program
thanks!
I am going to make water generator from air machine so i need humidity value in air . http://www.instructables.com/id/The-Arduino-Weather-Station-Thermostat/ you can see this link. i think this project value is very high cost, but i need same like as above with cheapest cost can your provide good project with program
garasan88@gmail.com
you can purchase it from our shop
Do we need to ground the D0 to D3 pins in the LCD module?if we won’t do that will it work?
No need
I tried this out.But it is not displaying anything.Is display connections are correct?
yes it is correct. Connect D+ with 5 volt and D- with ground
what do you mean by D+ and D-?
It’s not in the diagram.
Hello there Bilal. Can you email me complete circuit diagram, simulation and hex file of this project? please let me know that you emailed me. Please. this is my email rapunzelfairy8@gmail.com
Hi Bilal Malik, i need the source code for ‘automatic irrigation system’ with it circuit diagram
code of automatic irrigation system project is not for free
hello, i need a hex file of this project can u pleasemail me…. vishakhakale2@gmail.com is my email id…thank you
hi , I think it is not working on reality.
Can you translate it to C language im using mplab
pls can u give us the source program of this and also the hex file generated
I can’t run code because i have some errors , Can you check your code?
I can’t run the code it says Not enough RAM for call stack __Lib_MathDouble.c
Hello! Mr. Bilal
I need to make an Incubator to control temperature,humidity and turning of the eggs automatically using PIC16F877A.I tiered to write the correct code and also i used the code you attached, but it does not work .so if you are pleasured to help me; please email me complete code specially for humidity. another thing in which Port can i connect the out put of the timer?
hello.. i am making the same incubator as you but i dont know where to start it.. can you help me with the components???
hello Mishigu…. i am making the same incubator as you.. can you help me with the components required?
Dear BILAL,
Well done for another beautiful article. Indeed I have benefited a lot from your articles. I am still learning the ropes in this field.
I have a question. I do not know how you came about the constant 5018035 in this formula:
Freq=5018035/value.
Could you please shed more light on this aspect of your code?
Thanks.
Yusuf
Hi Bilal,
I want to know how you get this value in the program?
“Freq=5018035/value”
Waiting for an reply from you.
Thank you.
hi bilal , i want to make television circuit, but first i need to study in detail each part ; so can you help me or can you give suggestion please. I will have thesis report in this year on master level . my email is: kuk12980@gmail .com
I want the flow chart and the block diagram of this sensor
Please send me the program used for coding
and give me the hex file
i have a code for power measurment using pic16f887 mikroc,,
but there on lcd showning values are in ,as= 220.34578 v..
i want to measure vaalue as =220v
Sir, I need a complete circuit diagram, code and hex file, please.
hello, i need a hex file of this project can u pleas email me…. sanaullahmuhammad62@gmail.com is my email id…thank you
kindly send me the full file
hi
please tell me the program used for coding
Connect the Humidity sensor to any anolog pin of PIC microcontroller , if the Humidity sensor reaches a voltage level
>=2.5V , Shift 8 LED right to left connectrd to PORTB.
I am not getting any error in Proteus, but there’s nothing displayed on the LCD Screen 😥 can you help me?
Thank you Bilal, I want the complete simulation with the hex file if you don’t mind😊
this is my email: omeralkaley3322@gmail.com