Arduino Frequency Measurement Help

Hey y'all, I have been trying to mess with this code for a while now. What I am trying to do is measure hertz from a 5v square wave source. The source for this is the tachometer signal on my car. I have stepped it down from 12v to 5v using a 2N4401 NPN transistor. Everything online is telling me this code should accurately measure hertz, but what I am getting on my serial monitor is way off. At around 1000 rpm, I am getting between 34 and 36 hertz which the rpm would actually be between 2000-2200 at that frequency.

#include <FreqMeasure.h>

void setup() {
  Serial.begin(57600);
  FreqMeasure.begin();
}

double sum=0;
int count=0;

void loop() {
  if (FreqMeasure.available()) {
    // average several reading together
    sum = sum + FreqMeasure.read();
    count = count + 1;
    if (count > 30) {
      float frequency = FreqMeasure.countToFrequency(sum / count);
      Serial.println(frequency);
      sum = 0;
      count = 0;
    }
  }
}

Any help with figuring what's up with this code would be greatly appreciated! Thanks in advance!

I feel like an idiot now lol. I stopped thinking for a second I guess.. My car is a Miata and it has a wasted spark system where the ignition fires every time the cylinder is at TDC. I'm going to try this. Hope it works out!

 float frequency = FreqMeasure.countToFrequency((sum / count) / 2);

edit
Or I could just try this and get RPM instead of hz... lol I'm fixing my own problems in some sleep-deprived state..

 float frequency = FreqMeasure.countToFrequency((sum / count) * 20);

It sounds to me like you get two pulses per rotation, thus doubling the frequency measured.

By the way, how do you go from 12V to 5V using a transistor? It'd be MUCH safer to use an optocoupler, and isolate your Arduino from the car's electrics.

There is probably a nice clean rpm signal available from the ECU , either directly or from the OBD2 port