Freq Measure with ESP 32 / 8266

I have been using the FreqMeasure ( FreqMeasure Library, for Measuring Frequencies in the 0.1 to 1000 Hz range, or RPM Tachometer Applications) with a Nano module to find the flow rate using a flowmeter. All good. ( Frequency max limit is 150 Hz )

Now there is a requirement to post this Flow data to Thingspeak cloud and hence and ESP32 is entering the scene. For now I am linking the ESP and Nanao via a Serial link and pushing the flow data to it.

Instead will be nice if I can directly measure the frequency on the ESP itself. Searched for some typical codes but most are in the Espressif native code and not on the Arduino . Any library for this exists to use with ESP ?

Thanks

Please, post your NANO's sketch.

This code works fine for the requirement .

/*
 * 25 July 2023 
 * 
 *CPU : ESP32 Dev Module 
 *Code for reading two parameters of a Case Drain line and posting to 
 *the Cloud. 
 *The first parameter is a pulse train from flowmeter. This has a 
 *conversion factor of 11 . Thus Lpm = Freq / 11. 
 *Next is temperature with a LM35 sensor. 
 *
 *30 July 2023 
 *Checked the pulse reading and conversion ...OK. 
 *TODO - Temperature reading and WiFi link up coding. 
 */
  
int pulseCnt;
float lpm ; 

void ICACHE_RAM_ATTR sens() {
  pulseCnt++;
}

//%%%%%%%%%%%%%%%%%%%%%%%%%

void setup() {
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(4), sens, RISING);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%

void loop() {
  noInterrupts();
 
  Serial.print(float(pulseCnt) / 11 );
  Serial.println(" Lpm");  
  pulseCnt=0;
  
  interrupts(); 
  delay(1000);           //For a human to read ...
}

//%%%%%%%%%%%%%%%%%%%%%%%%%

Please use the link in my first post to learn about the full details of the FreqMeasure code. Thats where i got it from

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.