I put it into Arduino IDE but once I verify it, it just has error after error after error.
I would appreciate it if somebody could have a look at it at tell me the problems. It should read the temperature and humidity and write it onto html.
Thanks in advance!
/*
Web Server Thermometer
A simple web server that shows the value of a DHT11
using an Arduino Wiznet Ethernet shield.
Circuit:
* DHT11 attached to pin 2
* Ethernet shield attached to pins 10, 11, 12, 13
Web server code:
created 18 Dec 2009
by David A. Mellis
modified 4 Sep 2010
by Tom Igoe
DHT code written by ladyada
Public Domain
Combining the two by thoughtfix
July, 2011
*/
#include <SPI.h>
#include <Ethernet.h>
#include "DHT.h"
#define DHTTYPE DHT11 // DHT 11
#define DHTPIN 2 // DHT pin
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x4B, 0x21 };
byte ip[] = { 192,168,1, 223 };
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
Server server(80);
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
dht.begin();
}
void loop()
{
// listen for incoming clients
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = t*1.8+32;
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
// output the value of each analog input pin
client.print("TemperatureC: ");
client.println(t);
client.println("
");
client.print("TemperatureF: ");
client.println(f);
client.println("
");
client.print("Humidity: ");
client.print(h);
client.println("
");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
}
}
This is what comes up in the black area at the bottom.
I've put it in as code, for easier reading.
adamdht11.cpp:27:17: error: DHT.h: No such file or directory
adamdht11:39: error: no matching function for call to 'Server::Server(int)'
As of Arduino 1.0, the Server class in the Ethernet library has been renamed to EthernetServer.
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Server.h:4: note: candidates are: Server::Server()
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Server.h:4: note: Server::Server(const Server&)
adamdht11:39: error: cannot declare variable 'server' to be of abstract type 'Server'
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Server.h:4: note: because the following virtual functions are pure within 'Server':
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: note: virtual size_t Print::write(uint8_t)
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Server.h:6: note: virtual void Server::begin()
adamdht11:40: error: 'DHT' does not name a type
adamdht11.cpp: In function 'void setup()':
adamdht11:48: error: 'dht' was not declared in this scope
adamdht11.cpp: In function 'void loop()':
adamdht11:55: error: 'dht' was not declared in this scope
adamdht11:58: error: 'class Server' has no member named 'available'
adamdht11:58: error: cannot declare variable 'client' to be of abstract type 'Client'
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:7: note: because the following virtual functions are pure within 'Client':
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:12: note: virtual size_t Client::write(uint8_t)
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:13: note: virtual size_t Client::write(const uint8_t*, size_t)
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:14: note: virtual int Client::available()
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:15: note: virtual int Client::read()
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:17: note: virtual int Client::peek()
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:18: note: virtual void Client::flush()
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:10: note: virtual int Client::connect(IPAddress, uint16_t)
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:11: note: virtual int Client::connect(const char*, uint16_t)
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:16: note: virtual int Client::read(uint8_t*, size_t)
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:19: note: virtual void Client::stop()
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:20: note: virtual uint8_t Client::connected()
C:\Users\gbadwri\Desktop\arduino-1.0.1\hardware\arduino\cores\arduino/Client.h:21: note: virtual Client::operator bool()
Hey - I am the original author of that code (well - the one who wrote that page anyway) and would be glad to help once the library is in place. I didn't port it to the latest IDE. Did you get the library done?