Go Down

Topic: someone has experience with wind sensors? (Read 3450 times) previous topic - next topic

bitacovir

Hi. I am trying to work with a sensor from moderndevice http://moderndevice.com/product/wind-sensor-rev-p/ using a arduino mega 2560 but I can not make it provide data. Does someone have experience with this kind of sensors?

I do not know what I am doing wrong. Here I put some pictures of the circuit that I set up for this sensor and the sketch provided by the builder.






Code: [Select]

/* A demo sketch for the Modern Device Rev P Wind Sensor
* Requires a Wind Sensor Rev P from Modern Device
* http://moderndevice.com/product/wind-sensor-rev-p/

* The Rev P requires at least at least an 8 volt supply. The easiest way to power it 
* if you are using an Arduino is to use a 9 volt or higher supply on the external power jack
* and power the sensor from Vin.

* Hardware hookup 
* Sensor     Arduino Pin
* Ground     Ground
* +10-12V      Vin
* Out          A0
* TMP          A2
*
* Paul Badger 2014
* code in the public domain
*/

const int OutPin  = A1;   // wind sensor analog pin  hooked up to Wind P sensor "OUT" pin
const int TempPin = A2;   // temp sesnsor analog pin hooked up to Wind P sensor "TMP" pin


void setup() {
    Serial.begin(9600);
}

void loop() {

    // read wind
    int windADunits = analogRead(OutPin);
 //Serial.print("RW ");   // print raw A/D for debug
    // Serial.print(windADunits);
    // Serial.print("\t");
    
    
    // wind formula derived from a wind tunnel data, annemometer and some fancy Excel regressions
    // this scalin doesn't have any temperature correction in it yet
    float windMPH =  pow((((float)windADunits - 264.0) / 85.6814), 3.36814);
    Serial.print(windMPH);
    Serial.print(" MPH\t");   

 


    // temp routine and print raw and temp C
    int tempRawAD = analogRead(TempPin); 
    // Serial.print("RT ");    // print raw A/D for debug
    // Serial.print(tempRawAD);
    // Serial.print("\t");
    
    // convert to volts then use formula from datatsheet
    // Vout = ( TempC * .0195 ) + .400
    // tempC = (Vout - V0c) / TC   see the MCP9701 datasheet for V0c and TC
    
    float tempC = ((((float)tempRawAD * 5.0) / 1024.0) - 0.400) / .0195;
    Serial.print(tempC);
    Serial.println(" C");
    delay(750);
}





Grumpy_Mike

#1
Apr 10, 2015, 08:03 am Last Edit: Apr 10, 2015, 08:03 am by Grumpy_Mike
Nan stands for not a number and is something produced by the floating point routines. It is the result of asking the computer to do something silly like divide by zero.

What happens when you do not comment out the debug messages and just look at the raw numbers?

Just copy and paste the consol output, no need to post a picture.

bitacovir

Thanks for you response.

This is the output that I get with the debug is not comment out:

RW 18   nan MPH   RT 0   -20.51 C
RW 5   nan MPH   RT 15   -16.76 C
RW 0   nan MPH   RT 0   -20.51 C
RW 3   nan MPH   RT 0   -20.51 C
RW 13   nan MPH   RT 19   -15.76 C
RW 18   nan MPH   RT 20   -15.50 C
RW 56   nan MPH   RT 56   -6.49 C
RW 10   nan MPH   RT 15   -16.76 C
RW 10   nan MPH   RT 13   -17.26 C
RW 0   nan MPH   RT 0   -20.51 C
RW 0   nan MPH   RT 0   -20.51 C
RW 0   nan MPH   RT 0   -20.51 C
RW 23   nan MPH   RT 21   -15.25 C
RW 5   nan MPH   RT 15   -16.76 C
RW 0   nan MPH   RT 0   -20.51 C
RW 50   nan MPH   RT 51   -7.74 C
RW 7   nan MPH   RT 10   -18.01 C
RW 42   nan MPH   RT 43   -9.75 C
RW 0   nan MPH   RT 0   -20.51 C
RW 47   nan MPH   RT 46   -8.99 C
RW 13   nan MPH   RT 18   -16.01 C
RW 39   nan MPH   RT 38   -11.00 C
RW 19   nan MPH   RT 22   -15.00 C
RW 0   nan MPH   RT 0   -20.51 C
RW 0   nan MPH   RT 0   -20.51 C
RW 27   nan MPH   RT 24   -14.50 C
RW 57   nan MPH   RT 56   -6.49 C
RW 0   nan MPH   RT 0   -20.51 C
RW 23   nan MPH   RT 36   -11.50 C
RW 0   nan MPH   RT 8   -18.51 C
RW 22   nan MPH   RT 34   -12.00 C
RW 0   nan MPH   RT 0   -20.51 C
RW 38   nan MPH   RT 38   -11.00 C
RW 21   nan MPH   RT 25   -14.25 C
RW 26   nan MPH   RT 24   -14.50 C
RW 35   nan MPH   RT 39   -10.75 C
RW 9   nan MPH   RT 12   -17.51 C
RW 39   nan MPH   RT 41   -10.25 C
RW 7   nan MPH   RT 12   -17.51 C
RW 32   nan MPH   RT 32   -12.50 C
RW 24   nan MPH   RT 28   -13.50 C
RW 18   nan MPH   RT 18   -16.01 C
RW 35   nan MPH   RT 38   -11.00 C
RW 11   nan MPH   RT 13   -17.26 C
RW 40   nan MPH   RT 41   -10.25 C
RW 15   nan MPH   RT 19   -15.76 C
RW 29   nan MPH   RT 27   -13.75 C

This is the sketch edited:

Code: [Select]
/* A demo sketch for the Modern Device Rev P Wind Sensor
* Requires a Wind Sensor Rev P from Modern Device
* http://moderndevice.com/product/wind-sensor-rev-p/
*
* The Rev P requires at least at least an 8 volt supply. The easiest way to power it
* if you are using an Arduino is to use a 9 volt or higher supply on the external power jack
* and power the sensor from Vin.
*
* Hardware hookup
* Sensor     Arduino Pin
* Ground     Ground
* +10-12V      Vin
* Out          A0
* TMP          A2
*
* Paul Badger 2014
* code in the public domain
*/

const int OutPin  = A0;   // wind sensor analog pin  hooked up to Wind P sensor "OUT" pin
const int TempPin = A2;   // temp sesnsor analog pin hooked up to Wind P sensor "TMP" pin


void setup() {
    Serial.begin(9600);
}

void loop() {

    // read wind
    int windADunits = analogRead(OutPin);
    Serial.print("RW ");   // print raw A/D for debug
    Serial.print(windADunits);
    Serial.print("\t");
   
   
    // wind formula derived from a wind tunnel data, annemometer and some fancy Excel regressions
    // this scalin doesn't have any temperature correction in it yet
    float windMPH =  pow((((float)windADunits - 264.0) / 85.6814), 3.36814);
    Serial.print(windMPH);
    Serial.print(" MPH\t");   

 


    // temp routine and print raw and temp C
    int tempRawAD = analogRead(TempPin); 
    Serial.print("RT ");    // print raw A/D for debug
    Serial.print(tempRawAD);
    Serial.print("\t");
   
    // convert to volts then use formula from datatsheet
    // Vout = ( TempC * .0195 ) + .400
    // tempC = (Vout - V0c) / TC   see the MCP9701 datasheet for V0c and TC
   
    float tempC = ((((float)tempRawAD * 5.0) / 1024.0) - 0.400) / .0195;
    Serial.print(tempC);
    Serial.println(" C");
    delay(750);
}

Grumpy_Mike

It looks like the analogue inputs are floating. Normally this means a ground is not connected. I notice that your physical layout diagram does not match your actual circuit layout. Have you got the grounds connected?

AJITnayak

Code: [Select]

const int OutPin  = A0;   // wind sensor analog pin  hooked up to Wind P sensor "OUT" pin
const int TempPin = A2;   // temp sesnsor analog pin hooked up to Wind P sensor "TMP" pin


void setup() {
  Serial.begin(9600);
}

void loop() {

  // read wind
  int windADunits = analogRead(OutPin);
  float windMPH =  pow((((float)windADunits - 264.0) / 85.6814), 3.36814);
  Serial.print(windMPH);
  Serial.print(" MPH\t");

  int tempRawAD = analogRead(TempPin);

  float tempC = ((((float)tempRawAD * 5.0) / 1024.0) - 0.400) / .0195;
  Serial.print(tempC);
  Serial.println(" C");
  delay(750);
}


here is your code. How you test it. Intially hold your wind sensor. using multimeter take analog output reading ; calculate the windout as per formula given.

how you compare it if you have any wind logger you compare result
AMPS

bitacovir

It looks like the analogue inputs are floating. Normally this means a ground is not connected. I notice that your physical layout diagram does not match your actual circuit layout. Have you got the grounds connected?
Hi. Finally I could make work the sensor. And you probably are right with the observation of the ground. The diagram shows how I set up the circuit, at first. I did not connect the power from the arduino. The power and ground were provided for an independent adapter (12v) that was connected directly to the breadboard ( friend suggested me to do in this way to avoid burn other sensors connected to the arduino that work with 5v). The adapter is not in the photos because is under the desk. But apparently there is something wrong how the ground is connected.
I changed the adapter plugging it to the arduino's jack and the ground / power in the breadboard is supplied by the arduino (vin / GND) (This way is the suggested in the instructions for the sketch). So now it works perfectly. I will check the circuit to know why that configuration does not work.
Thanks. Your help oriented me.

bitacovir

Quote
here is your code. How you test it. Intially hold your wind sensor. using multimeter take analog output reading ; calculate the windout as per formula given.

how you compare it if you have any wind logger you compare result
Hi. I did not write the code and I do not know how it works. I just using the sketch provided by the sensor factory.

AJITnayak

oK good. If you don't wanna know sensor works. How you understand problem in future. SOmehow carry on with coding by supplier
AMPS

Grumpy_Mike

oK good. If you don't wanna know sensor works. How you understand problem in future. SOmehow carry on with coding by supplier
And you can help someone understand this?

Go Up