I have a bunch of Uno's with ethernet cards collecting data. The data is sent to a PC running a Python program that commits the data to an Sqlite3 database.
This works very well for me but there are a few glitches that I am working out.
For the arduino program I started with the WebServer example https://www.arduino.cc/en/Tutorial/WebServer and modified it to send back my data.
I removed the client.print's and added my data, before:
if (client.available()) {
char c = client.read();
Serial.write(c);
// 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("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("
");
}
client.println("</html>");
break;
}
After:
if (client.available()) {
char c = client.read();
Serial.write(c);
// 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) {
client.println("my data in string form");
client.println("</html>");
break;
}
My question is, is the "standard http response header" that I removed something that should have left in?
If so what is the minimum header required?
Thanks.