Wind speed sensor formular

Hello, I got this sensor from adafruit https://www.adafruit.com/products/1733 and I need some help with a formular for calculating the wind speed.

0.4V is 0 m/s wind
2.0V is 32.4m/s wind speed

I think it should be simple enough, I just ran into some stress issues which have messed my concentration up. :frowning:

rule of three?!

32.4 * (output - 0.4) / 1.6

Hmm, something like this then?

`hardware.pin1.configure(ANALOG_IN);
function airSpeed()
{
local firstreading = hardware.pin1.read();
local reading = 0;
for(local i=0; i<10; i++)
{
reading += hardware.pin1.read();
}

reading /= 10.0;

local output = 3.3/65535;
output *= reading;

server.log((32.4 * (output - 0.4) / 1.6) + " m/s");

imp.wakeup(5, airSpeed);
}
airSpeed();`

Hmm no, this can’t be right… I can get negative readings out of it.

Tried printing the raw output value? It’s possible it’s not quite 0.4v (eg if it was 0.38v you’d get a negative number).

You should probably also use hardware.voltage() instead of the hard-coded 3.3:

local output = hardware.voltage() / 65535;

After switching to hardware.voltage I haven’t gotten a negative reading.

I also tried to put tape on the sensor so it stopped rotating, then read the value, and it was around 8100 (a bit unstable to this seems to be around the lowest reading). And it is like 0.407873655299v, so pretty close to the 0.4v it says.