I am doing a basic experimentation on showing status / controlling over web.
My setup es an Arduino UNO, enc28j60 network module, dht11 temperature sensor.
Heres my code:
#include "dht11.h"
// A simple web server that turn an LED on or off"
#include "etherShield.h"
#include "ETHER_28J60.h"
dht11 DHT11;
#define DHT11PIN 2
int outputPin = 3;
static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24}; // this just needs to be unique for your network,
static uint8_t ip[4] = {192, 168, 1, 15}; // IP address for the webserver
static uint16_t port = 80; // Use port 80 - the standard for HTTP
ETHER_28J60 e;
void setup()
{
e.setup(mac, ip, port);
pinMode(outputPin, OUTPUT);
DHT11.read(DHT11PIN);
Serial.begin(115200);
}
void loop()
{
char* params;
if (params = e.serviceRequest())
{
e.print("<h1><a href='/?led=off'>Anti Flood System Web Remote</a></h1>");
e.print("<h2>Manual Pump Override</h2>");
if (strcmp(params, "?led=on") == 0)
{
digitalWrite(outputPin, HIGH);
e.print("<a href='?led=off'><button style='border: 1px solid #ff0000; border-left: 10px solid #ff0000' type='button'>PUMP IS ON</button></a>");
}
else if (strcmp(params, "?led=off") == 0)
{
digitalWrite(outputPin, LOW);
e.print("<a href='?led=on'><button style='border: 1px solid #000; border-left: 10px solid #000' type='button'>PUMP IS OFF</button></a>");
}
e.print("<h2>Temperature Status</h2>");
e.print("Temperature C: ");
e.print(DHT11.temperature);
Serial.println(DHT11.temperature);
e.respond();
}
}
I got to control a relay over web, but I want to show DHT 11 temperature, I could, but it stays static... It doest refresh (even if I refresh the web page) and via serial I saw that the temperature is moving.
Pretty basic so maybe you've already tried this, but have you tried in another browser and see if the value is different? Perhaps your browser is caching the page. If so adding some headers with Pragma: no-cache might fix it. Something like this might work:
Print out the URL of the incoming HTTP request. It's almost universal in my experience for browsers to request a favicon for each new site and the requests you're seeing at the Arduino may actually be the result of the browser trying again and again to retrieve a valid favicon - meanwhile continuing to show the very first copy of the page itself, which has been cached at the browser. There are various ways for the web server to inform the browser that the page should not be cached, and also ways for the browser to generate a unique URL each time the page reloads which will defeat caches even if the server has not disabled them.
clubbby:
Pretty basic so maybe you've already tried this, but have you tried in another browser and see if the value is different? Perhaps your browser is caching the page. If so adding some headers with Pragma: no-cache might fix it. Something like this might work:
PeterH:
Print out the URL of the incoming HTTP request. It's almost universal in my experience for browsers to request a favicon for each new site and the requests you're seeing at the Arduino may actually be the result of the browser trying again and again to retrieve a valid favicon - meanwhile continuing to show the very first copy of the page itself, which has been cached at the browser. There are various ways for the web server to inform the browser that the page should not be cached, and also ways for the browser to generate a unique URL each time the page reloads which will defeat caches even if the server has not disabled them.
I think you might be right, now it only displays the first part on the web page, just unitl de