Hello,
I have a problem since 2months...
I search how i can show values of my sensors on a dynamic webpage and i don't have find the solution.
Can you help me please? It's a project for my school.
I have Arduino ethernet shield for the webserver,sensor DHT22 for temperature and humidity (http://www.gotronic.fr/art-capteur-d-humidite-et-de-t-grove-sen51035p-18964.htm) , other sensor for temperature is (http://www.gotronic.fr/art-capteur-de-temperature-grove-sen23292p-18965.htm) and a simple display LCD 2x16.
The only who i arrived is to modify the exemple in the library and i have add my website but i don't arrived to send the values on my website i don't think how can i and i don't have find exemples who built on the web.
Sorry for my bad english i'm french :S
Thank you for yours response
my code
/*
http://www.bajdi.com
Web Server showing the values from a DHT22 sensor
*/
#include <SPI.h>
#include <Ethernet.h>
#include <dht.h>
#define DHTTYPE DHT22// Sensor type
#define DHT22_PIN 4// Data pin of DHT22 sensor
// 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, 0x0F, 0x21, 0xE8 };
byte ip[] = { 172,16,7, 100 };
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
void setup(){
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
}
void loop()
{
// listen for incoming clients
EthernetClient 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.print("<h1>Arduino powered webserver</h1>");
client.println("
");
client.print("Serving temperature and humidity values from a DHT22 sensor");
client.println("
");
client.print("Temperature (oC): ");
client.println("
");
client.print("Humidity (%): ");
client.println("
");
client.print("Bonjour");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<HEAD> <META charset=""UTF-8""></HEAD>");
client.print("<body style=background-color:#B0C4DE>");
client.println("<font color='red'><P style=""font-family:Courier New""><h1 ALIGN=CENTER>La Mini Serre</font></h1></P>");
client.println("<table CELLPADDING=2 CELLSPACING=1 BGCOLOR='#3CB371'><tr><td>");
client.println("");
client.println("<style>");
client.println("body { width:900px; margin:auto; }.nav {list-style: none none;margin: 0;padding: 0;line-height: 1;}.nav a {display: block;padding:.5em;color: blue;background: #B0C4DE;text-decoration: none;}.nav a:focus,.nav a:hover {color: black;background: #3CB371;text-decoration: underline;}.nav-item {float: left; position: relative; }.sub-nav {position: absolute; white-space: nowrap; left: 0; top: 2em; white-space: nowrap; background: #B0C4DE; margin-top: -2px; }.sub-nav-item a {position: absolute;left: -10000px;top: auto;width: 1px;height: 1px;overflow: hidden;float: left; }.sub-nav-item a:focus,.nav-item a:focus +.sub-nav a,.nav-item:hover .sub-nav-item a {position: static;left: auto;width: auto;height: auto;overflow: visible;}@media screen and (max-width: 480px) {.nav-item {float: none; }.sub-nav {position: static; white-space: normal }.sub-nav-item a {display: block; width: auto; height: auto; position: static; padding-left: 1em; overflow: visible; float: none;}}");
client.println("table{Background-Color: #3CB371;border-collapse: collapse; }th, td{border: 2px solid black;}.cantine{font-size: 23px}.cantine{font-weight: bold;}.jours{font-size: 23px}.jours{font-style: italic;}body {Background-Color: #B0C4DE;}");
client.println("</style>");
client.println("");
client.println("<center>");
client.println("<thead><tr><th></th><th class=jours> Température </th><th class=jours>Humidité </th></tr></thead>");
client.println("<tbody><tr><td class=cantine>A l'intérieur</td>");
client.println("<td width=300 height=200>");
client.println("Température intérieur
");
client.println("</td>");
client.println("<td width=300 height=200> Humidité intérieur
</td></tr>");
client.println("<tr><td class=cantine> A l'extérieur </td><td width=300 height=200>Température extérieur
</td>");
client.println("<td width=300 height=200>Non disponible
</td><body text=#000000></tr>");
client.println("</tbody>");
client.println("</table>");
client.println("</center>");
client.println("</BODY>");
client.println("</html>");
client.println("<meta http-equiv=\"refresh\" content=\"30\">");
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();
}
}
Bye