Hi. I am new with arduino and I do not know how to programing, yet. I am trying to run a platform of 4 wind sensors in parallel, using an Arduino mega 2560
Each sensor provides two analog signal Out= wind speed and TMP=temperature. So, I have connected the sensors to six pins in the analog in of the arduino board:
Sensor 1 OUT=A0 TMP=A1
Sensor 2 =OUT=A2 TMP=A3
Sensor 3 =OUT=A4 TMP=A5
Sensor 4 =OUT=A6 TMP=A7
Now, I took the sketch provided by the sensors factory and (with help) I adapted the code to try to work with the four sensors, but the output in the serial monitor only show two columns of numbers. Can someone check this edited code?
This is the original code:
/* 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);
}
And this is the code edited for four sensors:
/* 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[4] = {A0, A2, A4, A6}; // wind sensor analog pin hooked up to Wind P sensor "OUT" pin
const int TempPin[4] = {A1, A3, A5, A7}; // temp sesnsor analog pin hooked up to Wind P sensor "TMP" pin
void setup() {
Serial.begin(9600);
}
void loop() {
// 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
// Leo comenzando en A0 hasta A3 y los presento
for (int i=0; i<4; i++){
int windADunits = analogRead(OutPin[i]);
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[i]);
// 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);
}