Any advice on how to solve or sidestep this startup issue greatly appreciated, thank you.
Sensor connected to D3, Like the one here
Code:
void ICACHE_RAM_ATTR isr()
{
unsigned long now = micros();
float pulselength;
pulseNow = now;
int averagepulse;
int totalsample = 0;
if ((pulseNow - pulseThen) > resolution)
{
Serial.print("numPulses ");
Serial.print(numPulses+1);
Serial.print(" ");
pulselength = (float)(pulseNow - pulseThen) /1000000;
Serial.print(pulselength);
Serial.print("\n");
if( count < sample )
{
keeppulse[count] = pulselength;
count++;
}
else
{
count = 0;
Serial.print("Average in a sample of ");
Serial.print(sample+1);
Serial.print(" is ");
for( int x=0; (x<sample); x++ ) {
totalsample += (int)keeppulse[x];
}
averagepulse = totalsample/sample;
Serial.print(averagepulse);
Serial.print("\n\n");
}
pulseThen = pulseNow;
++numPulses;
}
}
void setup()
{
Serial.begin(19200);
pinMode(3, OUTPUT); //probe output on pin 3
attachInterrupt(0, isr, RISING);
numPulses = 0; // prime the system to start a new reading
}