Hi,
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() {
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);
}
The raw data that the sensor provides looks like this (I believe the value is millivolts OUT from the sensor):
Nano:
OUT 299
OUT 294
OUT 297
OUT 297
etc.
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
etc.
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!
-David