FreqCountESP
A frequency counter library for esp32
Table of Contents
About
A frequency counter library for esp32. It counts the numbers of pulses on a specified pin during a fixed time frame using native interrupts and timers. It only supports one instance per sketch for now.
Installation
To use this library you have to import it into Arduino IDE as follows:
- Download or clone this repository as a zip file.
- Go to “Sketch” > “Include Library” > “Add .ZIP library…” and select the zip file to import it.
Usage
Include the library in the sketch
#include "FreqCountESP.h"
Initialize the instance
Set which pin to use and the length of the time frame in milliseconds.
void setup()
{
int inputPin = 14;
int timerMs = 1000;
FreqCountESP.begin(inputPin, timerMs);
}
Read the frequency
Wait for a new value to become available and read it by calling the read()
method.
void loop()
{
if (FreqCountESP.available())
{
uint32_t frequency = FreqCountESP.read();
// Do something with the frequency...
}
}
Credits
-
Big thanks to @dpwe for his contributions https://github.com/kapraran/FreqCountESP/pull/5
- FreqCount library for Arduino & Teensy boards
- Frequency Icon
License
Copyright (c) 2020 Nikos Kapraras