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 ?
/*
* 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 ...
}
//%%%%%%%%%%%%%%%%%%%%%%%%%