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.

Step 1:

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
<p>very good example.<br>Works nice !</p>
<p>I tried it without lcd and different code it is still not working with that different code </p>
<p>Do you get it working up to Step 3? Wiring up the sensor and reading the temp on the Arduino serial port?</p>
<p>when I have add the display my sensor stop collecting reading plz help buddy </p>
<p>Beautiful project.</p><p>But how can I see data from outside Internet network?</p><p>I refer as well to access from outside?</p><p>For example from another network</p><p>The network goes eg</p>
<p>Setup port forwarding from your router.</p>
<p>Hello friend.</p><p>Thank you for your promptness of responding just as I have no problem with rooteru but the declaration port in the program.</p><p>I tried this formula but does not work :( &quot;server = EthernetServer EthernetServer (8081),&quot; Where in rooter port 8081 is open and ready to receive data from outside but unfortunately progranul not support this formula.</p><p>If you can help me with that formula and example would be of great help to me.</p><p>Multumesv again prompt response given to you</p>
<p>I need your arduino code which you already write on arduino ide?</p><p>Because I have to send to the measure value of soil moisture to android phone with ethernet module (enc28j60) by arduino ide?<br></p>
<p>All the code I used is in the instructable.</p><p>Use a &quot;soil moisture sensor&quot; and prototype the same way I did in this Instructable:</p><p>1. get the arduino and soil moisture sensor talking to each other</p><p>2. get a bluetooth module and the arduino talking to each other</p><p>3. get the bluetooth/arduino talking to the phone.</p><p>4. combine it all</p>
<p>Does the ENC26J80 come with a unique MAC address or does it take the value in your sketch code? Have you ever create any code to get remote NTP time using the ENC26J80 card?</p>
<p>Got things to work using the Final_Sketch and removing the &quot;static&quot; from word homePage(). Could you be more specific on external web access? Specifically, what port number do I set in my router as being forwarded? Is there a specific port found in the code for the ENC28J80?</p>
<p>It will be somewhat different depending on the router - however the default port is 80,</p><p>so in my Linksys running dd-wrt I goto:</p><p>NAT/QoS then port forwarding. Then Add, give it a name, port 80, put the IP address you assigned to the Arduino, enable it and save.</p><p>It will be similar on most home type routers</p>
<p>Thanks for the information. The port forwarding works great.</p><p>One other question, I have modified the sketch using a DS1307RTC. For the web page display code, how can I get it to show the leading zero for the hour, minute, seconds when they are single digits?</p>
<p>I saw my answer in the code below after sending the question. Thanks,</p>
<p>I saw my answer in the code below after sending the question. Thanks,</p>
<p>I am trying to create this project and I have downloaded the the EtherCard checkout program listed above on this page. When I compile this program, I get the errors:</p><p>C:\Arduino\EtherCard\Ethernet_Test\Ethernet_Test.ino: In function 'word homePage()':</p><p>Ethernet_Test:19: error: 'word homePage()' was declared 'extern' and later 'static' [-fpermissive]</p><p> static word homePage() {</p><p> ^</p><p>Ethernet_Test:14: error: previous declaration of 'word homePage()' [-fpermissive]</p><p> if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)</p><p> ^</p><p>exit status 1</p><p>Can anyone tell me what is wrong and how to correct this problem?</p><p>'word homePage()' was declared 'extern' and later 'static' [-fpermissive]</p>
<p>can you copy and paste your sketch here?</p>
<p>#include &lt;EtherCard.h&gt;</p><p>// ethernet interface mac address, must be unique on the LAN</p><p>static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };</p><p>static byte myip[] = { 192,168,1,203 };</p><p>byte Ethernet::buffer[500];</p><p>BufferFiller bfill;</p><p>void setup () {</p><p> if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)</p><p> Serial.println( &quot;Failed to access Ethernet controller&quot;);</p><p> ether.staticSetup(myip);</p><p>}</p><p>static word homePage() {</p><p> long t = millis() / 1000;</p><p> word h = t / 3600;</p><p> byte m = (t / 60) % 60;</p><p> byte s = t % 60;</p><p> bfill = ether.tcpOffset();</p><p> bfill.emit_p(PSTR(</p><p> &quot;HTTP/1.0 200 OK\r\n&quot;</p><p> &quot;Content-Type: text/html\r\n&quot;</p><p> &quot;Pragma: no-cache\r\n&quot;</p><p> &quot;\r\n&quot;</p><p> &quot;&lt;meta http-equiv='refresh' content='1'/&gt;&quot;</p><p> &quot;&lt;title&gt;RBBB server&lt;/title&gt;&quot; </p><p> &quot;&lt;h1&gt;$D$D:$D$D:$D$D&lt;/h1&gt;&quot;),</p><p> h/10, h%10, m/10, m%10, s/10, s%10);</p><p> return bfill.position();</p><p>}</p><p>void loop () {</p><p> word len = ether.packetReceive();</p><p> word pos = ether.packetLoop(len);</p><p> if (pos) // check if valid tcp data is received</p><p> ether.httpServerReply(homePage()); // send web page data</p><p>}</p>
<p>I have some problems with the highlight of the display, but i directly linked it to ground and +5 and evrything work nice.</p>
<p>Thanks a lot!</p>
I am using same library and connection here temp. and humidity is displaying on LCD and the connection of Ethernet module is showing on LCD but temp and humidity not showing on web page and the Ethernet test is also not working Is there any change in setting of IP in computer
<p>Are you using a enc28j60 or a W5100 (WizNet) ethernet adapter?</p><p>If your network isn't on a 192.168.1.x subnet made sure to change the IP address in the sketch to match your subnet and make sure it's a free IP address</p>
<p>Have the ethernet drivers for the wiznet w5100 or the enc28j60 been pulled into the main arduino core yet? I couldn't find it in the github repo but perhaps I'm not looking in the right place. (Kinda confusing with hardware 'sam' vs 'avr')</p><p>For example, is there hardware that works out of the (ide) box for this:</p><p><a href="http://playground.arduino.cc/Code/WebServer" rel="nofollow">http://playground.arduino.cc/Code/WebServer</a></p>
<p>The W5100 is in the Arduino core and is the:</p><p>#include &lt;Ethernet.h&gt;</p><p>The ENC28J60 needs the library added to your library folder<br></p>
<p>How do we change the temperature to read Fahrenheit instead of Celcius? </p>
<p>To convert from C to F the equation is:</p><p>C x 9/5 +32 = F</p><p>or C x 1.8 +32 = F</p><p>so after the line:</p><p>int t = dht.readTemperature();</p><p>you could try something like..</p><p>t = (t * 9)/5 +32;</p><p>or</p><p>t = (t * 1.8) + 32;</p><p>you may need to change:</p><p>int t = dht.readTemperature(); to</p><p>float t = dht.readTemperature();</p><p>so it can read and display the temp in decimal places.</p>
<p>This is the only tutorial I have found to be compatible with my setup. Now if I can only change the code to display the temperature on the web page in Fahrenheit as well. That's what I'm working on now. Thanks SteveRoy.</p>
<p>Hi, further down in an earlier comment is a note on converting the temperature reading to Fahrenheit. To display both you could create another variable for Fahrenheit, convert C to F and add the extra info in the homePage part of the sketch.</p>
<p>This saved me so much time! I was working on the individual parts, but having a hard time putting it all together, until I came across this! Thank you so much! The next step is to upload the data to thingspeak!</p>
<p>Why send your data to Thingspeak? </p>
<p>Nice, I must try uploading to thingspeak too!</p>
<p>[want to ask]</p><p>hi i from Indonesia, i still success until step 6 :)<br>buat i have problem with the ethernet shiled, i use ethernet shield from DFRobot </p><p><a href="http://www.dfrobot.com/index.php?route=product/product&product_id=455" rel="nofollow">http://www.dfrobot.com/index.php?route=product/pro...</a> </p><p>the library is different with the ENC28J60, anyone can help me?</p>
<p>Have a look at this project - it's not mine, but similar and uses a W5100 chip</p><p>https://arduino-info.wikispaces.com/ethernet-temp-humidity</p>
<p>Thank &quot; instructables.com &quot;</p><p>until Step 6 :) amazing *_&amp;<br> i dont try step 7</p>
<p>How hard would it be to modify the code to upload the data to thingspeak or a similar service?</p>
<p>Foe me? hard. For a programmer, probably fairly easy. </p><p>Start here:</p><p>http://community.thingspeak.com/tutorials/arduino/using-an-arduino-ethernet-shield-to-update-a-thingspeak-channel/</p>
hi.... I connected the enc28j60 module to arduino and to pc ethernet card directly using a patch cable. but, the indicator lights on the module or ethernet cable are not glowing. although the red light on module is working . can you help me out???
<p>You may need a cross over cable if you go directly from a PC to the enc module</p>
<p>sorry to much asking, what if using lcd shield like in this site: <a href="http://www.famosastudio.com/lcd-shield" rel="nofollow"> http://www.famosastudio.com/lcd-shield</a></p><p>did it will make more simple?.. and how the wiring, its completly different cuz its shield. and yours was just lcd and trimpot. </p>
<p>No, not with my sample code - It uses digital pin 10 which is used by the Ethernet module in my example. You would have to change the code and pins that the Ethernet uses. What's wrong with the way I have it in my build? If it's too many wires to solder then get an LCD with the i2c &quot;backpack&quot; and change the code.</p>
<p>thanks man, yeah you right, too many wire to be soldered. thats why i ask. ok. </p>
<p>aye bro. what if we don't using the trimpot, did need a change on the wiring diagram or not?</p>
<p>no, you could use a resistor for the contrast or use pwm off an Arduino port, but you will need something for the contrast. More recently I have been using i2c/SPI &quot;backpacks&quot; for LCD displays - easier in some ways as they only need 4 wires to connect to the Arduino, come with back-light via an on-jumper and have the contrast trimpot built-in. The down side being there are multiple library's for them and finding the right one can be a chore. They tend to use analog ports off the Arduino as well, so it frees up digital ports for other things.</p>
<p>thank you. its better and easier to changing the contrast with trimpot rather using another way that you've explain. </p>
<p>Thanks for this great instructables, it took me some time but worth it. I will want to add a barometric sensor in the future.</p>
<p>Hi rbayonet, good to hear you got it working. If you add a barometric sensor let us know the steps - maybe do an instructable on it.</p>
<p>Dear Instructables!! Excellent!!!. I made it!!! The steps are very explicit. I'll try to put together all in board Pro Mini. Consumption will support the usb port? external power supply?. Thank you very much. Sebasti&aacute;n.</p>

About This Instructable




More by SteveRoy:Building a Prusa i3 3D Printer - revisited Building a  Prusa i3 3D Printer Add your own trails to OpenStreetMaps 
Add instructable to: