Different Analog Results Using ESP8266 vs Nano for Wind Sensor


I am trying to integrate a Modern Device Wind Sensor (Rev P) for a project. I've utilized the Modern Devices test sketch using a Nano and am able to do analogReads() and get expected results. Here is the sketch they provide:

* 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() {

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(" 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.println(" C");

The raw data that the sensor provides looks like this (I believe the value is millivolts OUT from the sensor):

OUT 299
OUT 294
OUT 297
OUT 297

BUT, when I substitute a NodeMCU ESP8266 12E board (which only has one analog input @ A0) and upload the sketch, the sensor (or MCU) provides different results:

NodeMCU ESP8266:
OUT 416
OUT 488
OUT 423
OUT 438

In other words, the same setup on different boards is providing different results by some offset voltage it appears. Input voltages to the boards and the sensor are identical.

Could it be that an ESP8266 board processes a bit differently on the analog input? Any insight would be greatly appreciated!


the input range of the Nano analog inputs is 0 to 5 V. it returns 1023 for 5 V.
For esp8266 A0 it is 0 to 1 V. NodeMcu board has a voltage divider on A0 of the esp-12 which changes the input range to 0 to 3.3 V. It returns 1023 for 3.3 V.

1 Like

From http://moderndevice.com/product/wind-sensor-rev-p/

The temp sensor analog output is also scaled to 3.3 volts. The voltage (wind) output of the sensor has also been scaled to a maximum 3.3V output with high precision (.1% resistors). This is to accommodate the increasing use of 3.3 volt boards, and microcontrollers. It will work great with any Arduino or clone, right out of the box, except for the fact that you need to provide at least 9-12 volts from an external power source, with 12 volts being ideal.

So maybe, the readings from the NodeMCU ESP8266 are the correct ones ...
Could be verified by printing the temperature.

1 Like

both are correct:
290 * (5 / 1024) = 1.41V
440 * (3.3 / 1024) = 1.41V

1 Like

Yes brilliant, this is the answer. The analog values are scaled differently per the board spec, I should have realized that.

Really appreciate the detailed response. Thank you!

You are right, but using a 5 Volts reference voltage with a maximum of 3.3 Volts on the analog pin is not the best idea.

PS I am refering to the sketch they provide.