Hi All,
Need a little help, I have an error in my sketch that for some reason I'm unable to work it out, can some one help please?
This is the line in question
client.println(" <a> href="steve.tester.com">Steve.Tester.com</a>");
this is the error
Harrisons_Hilltop_View_Battery_Monitor.cpp: In function 'void listenForClients()':
Harrisons_Hilltop_View_Battery_Monitor:97: error: expected `)' before 'steve'
& this is my sketch
/* Read from two voltage sensors
* Reads the voltage sensors to calculate a battery voltages
*/
int bat1MonPin = A1; // input pin for battery one voltage sensor
int bat2MonPin = A2; // input pin for battery two voltage sensor
int val = 0; // variable for the A/D value
int val2 = 0; // variable for the A/D value
float pin1Voltage = 0; // variable to hold the calculated voltage of voltage sensor one
float pin2Voltage = 0; // variable to hold the calculated voltage of voltage sensor two
float battery1Voltage = 0;
float battery2Voltage = 0;
float ratio1 = 5.075; // Change this to match the MEASURED ration of the circuit of voltage sensor one
float ratio2 = 5.030; // Change this to match the MEASURED ration of the circuit of voltage sensor two
#include <Ethernet.h>
#include <SPI.h>
// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
// assign an IP address for the controller:
byte ip[] = {
192, 168, 1, 177 };
byte gateway[] = {
192, 168, 1, 123 };
byte subnet[] = {
255, 255, 255, 0 };
// 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 SPI library:
SPI.begin();
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
//Serial.begin(9600); // open the serial port at 9600 baud
}
void loop() {
// listen for incoming Ethernet connections:
listenForClients();
val = analogRead(bat1MonPin); // read the voltage on voltage sensor one
val2 = analogRead(bat2MonPin); // read the voltage on voltage sensor two
pin1Voltage = val * 0.00488; // Calculate the voltage on the A/D pin
pin2Voltage = val2 * 0.00488; // A reading of 1 for the A/D = 0.0048mV
// if we multiply the A/D reading by 0.00488 then
// we get the voltage on the pin.
battery1Voltage = pin1Voltage * ratio1; // Use the ratio calculated for the voltage divider one
battery2Voltage = pin2Voltage * ratio2; // Use the ratio calculated for the voltage divider two
// to calculate the battery voltage
//Serial.print("VDC Sensor One: "); // Print to the serial port
//Serial.println(battery1Voltage);
//Serial.print("VDC Sensor Two: "); // Print to the serial port
//Serial.println(battery2Voltage);
delay(2000); // Slow it down
}
void listenForClients() { // listen for incoming clients
EthernetClient client = server.available();
if (client) {
//Serial.println("Got a client");
boolean currentLineIsBlank = true; // an http request ends with a blank line
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();
client.println("
");
client.println(" <h1>CoW SkyExtender @ Harrisons Hilltop View</h1> ");
client.println("
");
client.println(" <h3>Solar Battery Monitor</h3> ");
client.println("
");
client.println(" <h3>Contact: Able Microwave Solutions</h3> ");
client.println(" <h3> 03 9722-2233</h3> ");
client.println("
");
client.println("
");
client.println(" <h3>Designed, Built & Installed</h3> ");
client.println(" <h4>by Steve Tester</h4> ");
client.println(" <a> href="steve.tester.com">Steve.Tester.com</a>");
client.println("
");
client.println("
");
// print the current readings, in HTML format:
client.print(" <h2> Battery One : </h2>");
client.println (battery1Voltage);
client.print("VDC");
client.println("
");
client.println("
");
client.print("Battery Two : ");
client.println (battery2Voltage);
client.print("VDC");
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();
}
}