Arduino Temp/Humidity with LCD and Web Interface

Picture of Arduino Temp/Humidity with LCD and Web Interface
I recently helped a client move their office which included setting up a new computer room.
I wanted them to be able to check the temperature and humidity of the room both by checking an LCD display in the room and also via a web page. I put together an Arduino with a DHT11 sensor, 16x2 LCD display and ENC28J60 Ethernet module. I did the project in stages first getting the DHT11 portion working using the DHT11 library and examples from Adafruit, then adding an LCD display and finally adding Ethernet using the EtherCard library and modifying their example code . This makes troubleshooting a lot easier and I could build/learn the code as I went along. I have taken code from the various examples provided with the necessary libraries.

This instructable will go through the steps to prototype this.

Note: the DHT11 sensor isn't very accurate - about plus and minus 2 degrees Celsius and 5% accuracy for humidity. I'll probably be changing to a DHT22 which is plus and minus .5 degrees Celsius and between 2% and 5% for humidity. The good news is it's an easy change in the code.
Remove these adsRemove these ads by Signing Up

Step 1:

Picture of
What you will need:

  • An Arduino
  • DHT11 or DHT22 sensor from Adafruit or various ebay vendors
  • 10K resistor for the DHT11 pullup
  • 16x2 LCD display HD44780
  • 10k trimpot for LCD contrast
  • 100 Ohm resistor for the LCD backlight
  • ENC26J60 Ethernet module or shield
  • Prototype shield if you use a regular Arduino and ENC28J60 Ethernet shield
  • hookup wire, breadboard etc for prototyping

Step 2: Wiring up the DHT11

The DHT11 and DHT12 have 4 pins. Looking at it with the side with square cutouts in it the pins are from left to right:
  • +5v
  • Signal
  • not used
  • GND
It also requires a 10k pullup resistor between +5V and Signal
For this project the Signal lead goes to Digital Pin 2 on the Arduino

The images show the DHT11 soldered into a prototype shield with the signal lead going to the Arduino digital Pin2

lineuve2 months ago

Congratulations for our work.

ankitshyani4 months ago

I think I am coming to conclusion. Do you think its because I am using Arduino Ethernet shield Wiznet 811MJ module and it doesn't work . will it make any difference if I don't use "


because rbb server example complies and upload onto Wiznet 811 MJ. but when I try to use Web server example from Arduino Example it works fine?

Please Help

Thank you

Would you be able to make changes to the Final_sketch.ino as I m using Wiznet 811MJ module but not


SteveRoy (author)  ankitshyani4 months ago

Have a look at this project - Note it's not my project, but should help you with the sketch you need. It uses the WizNet module rather than the ENC28J60 I used in my Instructable

ankitshyani4 months ago

I am using exact same library as its provided over this Page. I have managed upload the Final sketch onto Uno connected to ethernet Sheild interface with LCD . it displays Temperature and humidity correctly onto LCD . But when I try to type in web the IP address which I am using onto network google chrome comes out with this error "

Oops! Google Chrome could not connect to

Try reloading: 129.­12.­50.­145"

Is it any possible reason its not working . is it because I am using arduino Ethernet sheild!

SteveRoy (author)  ankitshyani4 months ago

Did you test the Ethernet Shield as per Step 8?

SteveRoy (author)  ankitshyani4 months ago

Are the PC and Arduino on the same subnet? i.e. what is the IP address of your PC?

ColCar6 months ago

Hello Everyone !

I am also new to all of this and its been a lot to absorb, this instructable was very helpful and I wouldn't make any progress without this kind of information and I Thank You for posting it.. I followed the steps and got everything working until the Ethernet part. Im using the Arduino Ethernet shield and I am not sure what part of the webserver example sketch to cut and paste into the FinalSketch provided here.. All help would be extremely appreciated.

ColCar ColCar6 months ago

Also is it possible to go from Celsius to Fahrenheit ?

SteveRoy (author)  ColCar6 months ago

To convert from C to F the equation is:

C x 9/5 +32 = F

or C x 1.8 +32 = F

so after the line:

int t = dht.readTemperature();

you could try something like..

t = (t * 9)/5 +32;


t = (t * 1.8) + 32;

you may need to change:

int t = dht.readTemperature(); to

float t = dht.readTemperature();

so it can read and display the temp in decimal places.


nguyenlocan7 months ago

Hi, every body!

I'm a new beginner.

Can you show me how to declaire byte ethernet?

I don't know that. Thanks you!

dsutherland7 months ago
Hi,thanks for this well explained instructible.
I want to add another DHT11 and have most of the code sorted but I keep getting errors when compiling,I think the problem lies here where the extra DHT's temp and humidity must be displayed on web interface...
"Dave's Temperature & Humidity Server"
"Welcome To Dave's Online Temperature & Humidity Monitor"
"Office Sensor 1"
"Temp: $D  Degrees Celsius
Humidity: $D %"),
t, h);
// "Office Sensor 2"
// "Temp: $D  Degrees Celsius
Humidity: $D %"),
// t1, h1);
The commented out lines are the problem,please advise how to sort this,my html coding skills are zero :(
SteveRoy (author)  dsutherland7 months ago
try remove the ; after the t, h)
i.e. after the first sensor and leave it after the t1, h1)

Let me know if that works.
Hi,thanks for reply are now getting the following error when compiling - error: expected `;' before string constant with the centre h1 office sensor2 h1 line highlighted. Any further ideas welcome.
PS: Can upload sketch to a dropbox if easier for you.
SteveRoy (author)  dsutherland7 months ago
You need to do something like this:
Put the 4 $D first and then the t, h, t1, h1 on the last line

// Here we build a web page and pass the t and h values into it
static word homePage() {

bfill = ether.tcpOffset();
"HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\n"
"Pragma: no-cache\r\n"
"Temp server"

Temp1: $D C
Humidity1: $D %
Temp2: $D C
Humidity2: $D %

t, h, t1, h1);
return bfill.position();
SteveRoy (author)  SteveRoy7 months ago
OK it took my code literally... :)

Do a temp1: $D and follow with humidity1: $D then temp2: $D etc
last like becomes
t, h, t1, h1);

hope that makes sense

Thanks for your help.after getting the syntax right it is compiling :)
abdulrahman28 months ago
good idea
thank you