ESP8266 Frequency Measurement?

Is there a library available to do frequency measurement with the 8266? I need this for a tachometer function on 4- and 6-cylinder engines. Unless I'm missing something, it appears the only way to do this is with pin interrupts, as there are apparently no unused timers in the 8266, and what timers there are, are not capable of being gated by input pins.

Why couldn't you count low-to-high (or high-to-low) transitions, in some period of time, vs. millis() ?

As an FYI and not as any help. The ESP32 has a PCNT module that is a self contained unit, does not require cpu time to count pulses, that might interest you. If you want you can read about the PCNT at Pulse Counter - ESP32 - — ESP-IDF Programming Guide latest documentation.

You can try to use these examples and see see any of them is OK for you

For ESP8266

  1. ISR_RPM_Measure
  2. RPM_Measure
  3. ISR_RPM_Measure
  4. RPM_Measure

For ESP32

  1. ISR_RPM_Measure
  2. RPM_Measure
  3. ISR_RPM_Measure
  4. RPM_Measure

runaway_pancake:
Why couldn't you count low-to-high (or high-to-low) transitions, in some period of time, vs. millis() ?

Because the response would be too slow for a tachometer in a car. I need to get a minimum of 10 measurements per second, with, ideally, a few % accuracy. That can't be achieved with that method.

Idahowalker:
As an FYI and not as any help. The ESP32 has a PCNT module that is a self contained unit, does not require cpu time to count pulses, that might interest you. If you want you can read about the PCNT at Pulse Counter - ESP32 - — ESP-IDF Programming Guide latest documentation.

Yeah, it's a lot easier on ESP32, but for this project, I'm committed to NODEMCU.

khoih-prog:
You can try to use these examples and see see any of them is OK for you

For ESP8266

  1. ISR_RPM_Measure
  2. RPM_Measure
  3. ISR_RPM_Measure
  4. RPM_Measure

Thanks. I suspect something similar to the ISR_RPM_Measure examples is the best I can do. No idea if it will be good enough, until I try it. It will depend on average interrupt latency.

A car engine is, in MCU terms, quite slow. 10,000 RPM is about 167 Hz.
However, the esp8266 is quite good at blocking other activities while services its WLAN functions so some smoothing/interpolation may be good to avoid disturbing visual effects.

A car engine is, in MCU terms, quite slow. 10,000 RPM is about 167 Hz.

It really is quite slow, but normally an RPM meter measures the times the coil goes low, which is twice that for a 4 cylinder car and 3 times that for a 6 cylinder car (going from the point of view of a 4-stroke engine) You could of course just measure the inductance of a single sparkplug lead as a tuning Stroboscope does, in that case it would even be half that.