#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90,0xA2,0xDA,0x00,0xCF,0x4D }; //physical mac address
byte ip[] = { 192,168,1,149 }; // ip in lan
byte gateway[] = { 192,168,1,1 }; // the IP of the router or acsesspoint
byte subnet[] = { 255,255,255,0 }; //subnet mask (i dont think this is neccesary
EthernetServer server(1400); // server port (change this if you are having a local webserver else than the arduino)
String readString = String(30); // string for fetching data from address
long pulsewidth1;
float wspeed1;
// Analog Pin 8
double Thermistera(int RawADC) {
double Tempa;
Tempa = log(((10240000/RawADC) - 9400));
Tempa = 1 / (0.001129148 + (0.000234125 * Tempa) + (0.0000000876741 * Tempa * Tempa * Tempa));
Tempa = Tempa - 273.15; // Convert Kelvin to Celcius
Tempa = Tempa * 1.8;
Tempa = Tempa + 32;
return Tempa;}
void setup()
{
Serial.begin(9600); //enable serial datada print
Ethernet.begin(mac, ip, gateway, subnet); //start Ethernet
pinMode(15,INPUT);
}
void loop(){
EthernetClient client = server.available(); // Create a client connection
if (client)
{
while (client.connected())
{
if (client.available())
{
char c = client.read();
if (readString.length() < 100)
{
readString +=c;
}
if (c == '\n')
{
if (readString.indexOf("?") <0)
{
//do nothing
}
else
{
// removed Servo Control Strings From Here
}
//Anemometer code
pulsewidth1=pulseIn(15, LOW); //Anemometer 1
wspeed1=1000000.0/pulsewidth1*2.5;
Serial.println(pulsewidth1);
//Html Starts Here
client.println("HTTP/1.1 200 OK"); //output HTML data starting with standart header
client.println("Content-Type: text/html");
client.println();
//client.println("<META HTTP-EQUIV="Refresh" CONTENT="15">");
client.print (""); //set background to white
client.println("Home Monitoring System");
client.println("
");
client.println("Release Date 08/2012 - Latest Update 011/2013");//send first heading
client.println("
");
client.println("");
client.println("
");
client.println("System Location:Gardiner, Maine ");
client.println("
");
client.println("");
client.println("
");
client.println("Analog Sensors");
client.println("
");
client.println("");
client.println("
");
//screen input for pin8
client.println("Unknown Location: Temp ");
client.print(int(Thermistera(analogRead(8))));
client.print("F");
client.println("
");
//screen input for pin15
client.println("");
client.println("
");
client.println("Current Wind Speed: MPH ");
client.print(wspeed1);
client.println("
");
client.println("");
client.println("
");
client.println("");
client.println("");
client.println("");
readString=""; //clearing string for next read
//delay(1);
client.stop(); //stopping client
}
}
}
}
}
for Schematic: I have pin 15 connecting to + anemometer with a 10k resistor going to 3.3volts and the negative of the annemometer is going to ground on my arduino