Code won't upload when Vin plugged in

Hi,

I am using a Modern Device Rev P Wind Sensor with my Arduino Mega. The Wind Sensor needs 9V input so I have my arduino plugged into a 9V supply and then the Wind Sensor attached to the Vin and GND. When the sensor is plugged in the arduino stops working and when I unplug it it runs again. Anyone know why this is happening? Is there an issue with my soldering and connections?

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");

        // 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

    
    // 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");

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

    delay(750);
}

Elizabethleriche:
The Wind Sensor needs 9V input so I have my arduino plugged into a 9V supply and then the Wind Sensor attached to the Vin and GND. When the sensor is plugged in the arduino stops working and when I unplug it it runs again.

The subject of this thread specifically mentions problems are with uploading code. What is it, really?

Anyone know why this is happening? Is there an issue with my soldering and connections?

// wind sensor analog pin hooked up to Wind P sensor "OUT" pin
// temp sesnsor analog pin hooked up to Wind P sensor "TMP" pin

What kind of voltages does your sensor put out? You sure it's less than 5V? Anything over 5.5V and you may fry your port.

How much current does it use? This may be another problem. If it draws too much, no current left for the Arduino.

Finally I'm not too sure about the wisdom of using the Vin pin as power source - are you sure there's a direct electrical connection to the barrel jack?

Elizabethleriche:

Theres a diode between barrel jack and Vin so the Vin voltage is 0.65V LOWER then the barrel jack. How much current can your 9V supply put out?

The 9V supply has a current of 650mA.

Also to answer the previous question when I read the output voltages of the Wind Sensor they average around 1-2V.

Looking at the schematic, I think you need minimum 10.5V, 12 would be better, you're only getting 8.4V from Vin.

Useful link.
Description says "minimum 8V", but then they list 10-12V in the specs. That's an odd contradiction.

There's indeed a 9V regulator on board (and a 3.3V one), that usually means >10V supply needed to give it enough to regulate down (I didn't look up the spec sheet of that one) to 9V. Supplying 8V as suggested in the description doesn't sound like a good idea, even at 8.4V the board itself would have only about 7V left to operate. Without digging up spec sheets (the OpAmp type isn't even given in the schematic) impossible to say whether that's enough.

Anyway, that's focusing on the sensor, while it seems that one actually works (but the voltage dividers may be off due to too low supply voltage) and OPs problem seems to be in the Arduino part, but without clarification by OP we still don't really know what's going on.

This is a heater-based flow sensor, it needs lots of power, a small 9V battery can do only pathetic amounts
of power and is being effectively shorted-out by the heater element in the sensor.

Small 9V batteries struggle above 50mA. You need something much more powerful (and probably which
much more capacity to have a reasonable discharge time)