EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Humidity Display on LCD

Humidity Display on LCD

|

Microcontroller › 8051 › Humidity Display on LCD

  • This topic has 7 replies, 2 voices, and was last updated 12 years, 6 months ago by proteek basu.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • April 19, 2013 at 4:35 pm #2277
    proteek basu
    Participant

    I have compiled the code for humidity display posted in engineers garage site using KEIL 4, I got zero errors and zero warnings, but when I run the controller I get garbage characters on the LCD first line the second line displats two single digit numbers with some gap in between, has anybody done this project? please help.

     

    Proteek

    April 20, 2013 at 4:51 pm #9546
    AJISH ALFRED
    Participant

    Hi Proteek,

    Please share the location from where you’ve find the code.

    April 23, 2013 at 5:23 pm #9548
    proteek basu
    Participant

    The code has been taken from Engineers Garage only under 8051 projects titled:

     

    How to interface Humidity Sensor with 8051 Microcontroller (AT89C51)

     

    // Program to Interface Humidity sensor with 8051 Microcontroller

    #include<reg51.h>
    sfr lcd_data_pin=0x80;//p0 port
    sbit rs=P3^0;
    sbit rw=P3^1;
    sbit en=P3^2;
    sbit wr= P3^3;
    sbit rd= P3^4;
    sbit intr= P3^5;
    sfr input_port=0x90; //p1 port
    unsigned int number=0;
    unsigned char humidity,lcd,key=0;
     
    void delay(unsigned char count)
    {
    unsigned char i;
    unsigned int j;
    for(i=0;i<count;i++)
    for(j=0;j<1275;j++);
    }
     
    void lcd_command(unsigned char comm)
    {
    lcd_data_pin=comm;
    en=1;
    rs=0;
    rw=0;
    delay(1);
    en=0;
    }
     
    void lcd_data(unsigned char disp)
    {
    lcd_data_pin=disp;
    en=1;
    rs=1;
    rw=0;
    delay(1);
    en=0;
    }
     
    lcd_dataa(unsigned char *disp)
    {
    unsigned char x;
    for(x=0;disp[x]!=0;x++)
    {
    lcd_data(disp[x]); 
    }
    }
     
    void lcd_ini()
    {
    lcd_command(0x38);  // for using 8-bit 2 row LCD 
    delay(50);
    lcd_command(0x0F);        // for display on cursor blinking
    delay(50);
    lcd_command(0x0C);
    delay(50);
    lcd_command(0x80);
    delay(50);
    }
     
    void lcd_display(unsigned int val)
    {  
    unsigned char flg=0;
    lcd_command(0xC7);
    if(val==0)
    lcd_data(‘0’);
    while(val>0)
    {  
    lcd=val%10;
    val=val/10;
    lcd_command(0xC7-flg);
    lcd_data(lcd+’0′);
    flg++;  
    }
      
    }
     
    void display()
    {
    key++;
    number=number+input_port;
    if(key==11)
    {
    number=number/key;
    number=number*10;
    number=number/25;
    humidity=number-3;
    lcd_display(humidity);
    key=0;
    number=0;
    }
    }
     
    void adc()
    {
    rd=1;
    wr=0;
    delay(2);
    wr=1;
    while(intr==1);
    rd=0;
    display();
    delay(2);
    intr=1;
    }
     
    void main()
    {
    lcd_ini();
    lcd_dataa(“%Rel.Humidity:”);
    while(1)
    {
    adc();
    }
    }
    April 29, 2013 at 1:37 pm #9595
    proteek basu
    Participant

    The characters displayed on the LCD are as follows:

     

    $Pd1,Hthdht*8                               -1st line

            4   3                                       – 2nd line

    May 12, 2013 at 4:56 pm #9720
    proteek basu
    Participant

    I have checked the code using Proteus 8 simulator the display goes blank with the backlight only comming on

    May 12, 2013 at 7:39 pm #9728
    AJISH ALFRED
    Participant

    Hi Proteek,

    Have you made exactly the same circuit as you find along with the code? The LCD should be connected in 8 bit mode. Please check your connections, especially the data lines.

    May 14, 2013 at 6:14 pm #9751
    proteek basu
    Participant

    Alfred Sir,

     

    I have wired up the whole thing as per the circuit and rechecked everything several times, in fact there is a minor mistake in the circuit pin 34 is printed for a second time instead of 35 of the microcontroller, still then I am getting the same error.

    May 14, 2013 at 6:18 pm #9752
    proteek basu
    Participant

    Alfred Sir,

     

    I have rechecked everything several times and things are just according to the circuit, LCD is in 8 bit mode only, still I am getting errors.

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Help please! BLDC driver circuit using the IR2136s and the STP80NF06 MOSFETS November 8, 2025
  • need two ICs November 8, 2025
  • MLT-8530 Buzzer on ESP32: Why Is the Sound Output Lower Than Expected? November 8, 2025
  • Scope Clock CRT Z-Axis - Grid bias positive? November 8, 2025
  • Measuring controller current output with a meter November 8, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise