Just clarifying it a little bit about what @fr8tra1n said about the 12V:
The OP said he was using a 10KΩ resistor from the 12V to the fan tachometer pin. This pin is also connected to the ESP8266, which he assumed, correctly, won’t survive to be exposed to 12V very long.
Quick clarification: the tachometer is not “sending pulses”. The line is always UP (12V), and the tachometer connects it to ground (GND) 2 times per revolution. Yeah, it’s “sending pulses” in the sense that the line is always at 12V (pulled up by the pull-up 10KΩ resistor) and those “pulses” are 0V (GND).
The tachometer may not work correctly with a lower voltage, let’s say, 3.3V, because, as the OP said before, the RPM readings were not accurate.
I’ve seen people trying to use a voltage divider (other 2 resistors) to bring the 12V line down to 3.3V, a voltage that the ESP8266 can stand, before reaching the ESP8266 pin. I didn’t test it yet but, in principle, it should work. These voltage dividers can be configured in many ways and there are many calculators on the web that you can use for helping with that. For example:
Voltage Divider Conversion Calculator | DigiKey
You can use, let’s say, a 27KΩ resistor for R1 and a 10KΩ resistor for R2, bringing the 12V input to 3.2V.
The formula is simple:
Vin / (R1 + R2) * R2
or, in our case, 12V / (27KΩ + 10KΩ) * 10KΩ
which gives us 3.24V
Notice that Ohm’s Law (I = V / R
) units are still obeyed in this formula. So, when we divide V / (R1 + R2)
, we have the current (I
). But then we multiply it by R2
, and I * R = V
, so having our result in volts (V
) is correct.