Inconsistent results from a hall effect sensor on different breadboards

So I've been having this frustrating problem with a flow rate sensor. It works based on a pinwheel + hall effect sensor best I can tell.

You connect Vcc on the sensor to +5V, GND to GND, and yellow (data) to an input pin on the arduino (pin 4). When connecting this on a solderless breadboard it works fine.

And when I say doesn't work, the arduino doesn't detect any pulses from pin 4 so the getFreq function outputs 0.

When I try this on a perfboard I soldered some stuff to, it only works if I have a pull up resistor between the data pin on the sensor and +5V. The largest resistance I could find that would work reliably was 220 Ohm.

I tried setting pin 4 to HIGH to (I believe) enable the internal pull up resistor. This printed some erratic frequency values only when restarting the code and the pinwheel in the flow meter was actually moving. It would print 2 or 3 lines of numbers and then go back to 0s. This happens irregularly when using pull up resistors greater than 220 Ohm on the perfboard.

This is some code I used to test the sensor.

int flowMeterPin = 4;

void setup() {
  Serial.begin(9600);
  pinMode(flowMeterPin,INPUT);
  digitalWrite(flowMeterPin,HIGH);
}

unsigned int getFreq(int pin) {
  unsigned long pWidth = pulseIn(pin,LOW);
  float f = 1/(float(pWidth)*1e-6);
  return f;
}

void loop() {
  delay(500);
  Serial.println(getFreq(flowMeterPin));
}

There are no short circuits on the perfboard. There is some other stuff connected to the same 5V and GND rail, but there is no reason they should effect the flow sensor that I could tell.

Any theories as to what could be going on?

The HE sensor probably has an open collector output and has to have a pullup to +V, usually 1 to 5K, the output pulls LOW when triggered, can you post a link or part nr?
NOTE: The internal pullups (about 30k) may be too weak, try an external 4.7k

edgemoron:
The HE sensor probably has an open collector output and has to have a pullup to +V, usually 1 to 5K, the output pulls LOW when triggered, can you post a link or part nr?
NOTE: The internal pullups (about 30k) may be too weak, try an external 4.7k

I wrote in the OP that I've already tried external pullups. A 4.7k is too high and doesn't work reliably on the solder board. The highest resistance I tried that works reliably is a 220 Ohm.
And of course that doesn't explain how it's possible that it works with no pull up resistor when isolated on the solderless board but acts so wonky on the solder board.

It's a YF-S401 flow sensor.

You need to explain more about this perfboard - what's on it? Is the soldering good? How about a
decent photo?

MarkT:
You need to explain more about this perfboard - what's on it? Is the soldering good? How about a
decent photo?

Annotated.
The columns are connected vertically except the power/ground rails which are connected horizontally.
Everything in the upper left should be irrelevant. The red wires going off to the upper left are to toggle switches for fans and a pump.

A: From 5V and GND on arduino
B: 3 horizontal pins on column 12,13,14 are to the HE sensor. Right Vcc, Center GND, Left data.
C: 220 Ohm resistor soldered in.
D: GND and Vcc for an LCD
E: GND, and Vcc for a 1-wire bus. The resistor in middle is a 4.7k pull up resistor for the 1-wire data line
There are connectors for 2 1-wire sensors. The single female post above is for the data line to the arduino.
F: The data line from the HE sensor to the arduino (pin 4).
G: Vin to arduino. It is powered from the barrel jack at lower right (12VDC).

The HE sensor behaves strangely as described in the OP when it's the only thing connected to the board apart from the jumpers at A and F. The barrel jack is unused then, the board is being powered by the arduino 5V which is plugged into my laptop.

I had some issues with short circuits and I think it was from flux/metal chip residue that was left on the board. I cleaned it up and that was solved.
I tested quite thoroughly with a DMM, everything seems to be connected the way it should be.