Anemometer Keeps Registering inf on output

#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

I will admit that I am no expert on the Arduino code but it looks as you are setting up pin 15 as a digital out by setting it low. A low pin would come up as infinite. I cant honestly suggest how to change it, I can copy and paste code and modify slightly to suit my needs. That being said I have always seen "pulsewidth1=pulseIn**(15, LOW)**; //Anemometer 1" as setting the pin for an output value. It almost appears that you are resetting the pin to low each time the loop runs. How about setting the pin to (15, DIGITAL); I think I have seen that command somewhere.

Hope this helps.

Dom

Hi, can you please help us all and put your code in code brackets, to see how to use this forum check the post at the top of the forum list.
I assume it is a weather monitor that uses ethernet connectivity.
Have you tried just a sketch with the anemometer and serial monitor debug to see if the input is working, without any other hardware and software running.

Hoping to help you. Tom....... :slight_smile:

Looking into this a little more and finding w reference that might help you.

 int ledPin = 13; // LED connected to digital pin 13
int inPin = 7;   // pushbutton connected to digital pin 7
int val = 0;     // variable to store the read value

void setup()
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin 13 as output
  pinMode(inPin, INPUT);      // sets the digital pin 7 as input
}

void loop()
{
  val = digitalRead(inPin);   // read the input pin
  digitalWrite(ledPin, val);    // sets the LED to the button's value
}

This will setup the arduino to output to a led but you should be able to modify it to suit your needs. The important part here is the setup for a digital read.

Dom