Hey guys,
I have an arduino uno and an ethernetshield. I am running a little Webserver that gives me the value of an analog sensor. So far so good, once I include SD.h the html sent to the client is corrupt and the output in the browser is not as expected.
Attached are 2 screenshots. One showing how I expect it to look like and the other shows how it looks like once I include SD.h
the code looks as follows:
THANKS A LOT IN ADVANCE
#include <SPI.h>
#include <Ethernet.h>
//#include <SD.h>byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,178,179);const int chipSelect = 4;
int outputPin = 6;
EthernetServer server(80);void setup() {
Serial.begin(57600);
pinMode(10, OUTPUT);
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
pinMode(outputPin, OUTPUT);}
void loop() {
int sensorValue = analogRead(A0);
float humidityPerCent = 100-(sensorValue /10.23);EthernetClient client = server.available();
if (client) {
Serial.println("new client");
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
if (c == '\n' && currentLineIsBlank) {
client.println( "");
client.println( "");
client.println( "");
client.println( "The Garduino");
client.println( "");
client.println( "body, input, select, textarea");
client.println( "{color: #888;font: 16pt "Source Sans Pro", sans-serif; width: 75%; margin:0 auto;}");
client.println( ".gradient { height: 50px; margin: 0 0 50px 0;");
//*** THE GRADIENTS SHOULD BE DEPENDING ON THE BOUNDARY VALUES***
client.println( "background: -webkit-linear-gradient(left, #69482D 10%, #1B701B 45%, #1B701B 55%, #1E315E 90%);"); /* For Safari 5.1 to 6.0 /
client.println( "background: -o-linear-gradient(right, #69482D 10%, #1B701B 45%, #1B701B 55%, #1E315E 90%);"); / For Opera 11.1 to 12.0 /
client.println( "background: -moz-linear-gradient(right, #69482D 10%, #1B701B 45%, #1B701B 55%, #1E315E 90%);"); / For Firefox 3.6 to 15 /
client.println( "background: linear-gradient(to right, #69482D 10%,#1B701B 45%, #1B701B 55%, #1E315E 90%);}"); / Standard syntax (must be last) /
client.println( ".box{float: left !important; height: 50px;}");
//** THE BOXES WIDTHS SHOULD BE DEPENDING ON THE BOUNDARY VALUES***
client.println( ".box.dry{width: 40%;}");
client.println( ".box.good{width: 20%; border-left:2px solid #888; border-right:2px solid #888;}");
client.println( ".box.humid{width: 37%}");
client.println( ".level{text-align: right; height: 50px; border-right: 2.5px solid #444;}");
client.println( ".level.bad{border-right:2.5px solid #c33;}");
client.println( "");
client.println( "");
client.println( "");
client.println( "The Garduino measures the humidity
");
of the ficus benjaminus
//*** LOOP ALL POTENTIAL SENSORS ***
client.println( "top soil sensor");
client.println( "<div class ="gradient">");
client.println( "<div class="box dry"> <div class="box good"> <div class="box humid"> ");
client.print( "<div class="level bad" style="width:");
client.print( humidityPerCent);
client.print( "%;">");
client.print( humidityPerCent);
client.print( "%");
client.println( "");
//*** END LOOP ***
client.println( "");
client.println("");
break;
}
if (c == '\n') {
currentLineIsBlank = true;
}
else if (c != '\r') {
currentLineIsBlank = false;
}
}
}
delay(1);
client.stop();
Serial.println("client disconnected");
}
}