@peekay123 Well, I’m a little embarrassed to say, because I really have no idea what I’m doing. I tried adding the “if” statement below, but that doesn’t verify, so I must have formatted something wrong.
unsigned long t;
static unsigned int pc;
t = (millis() - oldTime);
if(t >= 1000) // Only process counters once per second
//Read water sensor pulse count and process
if (WaterPulseCount != 0) // Do nothing if water is not flowing!
detachInterrupt (WATER_SENSOR_PIN); // Disable water flow interrupt to read value
//Calculate litres and adjust for 1 sec offset, if any
liters = (WaterPulseCount / pulsesPerLiter) * (t / 1000);
oldTime = millis(); // Reset base delay time
pc = WaterPulseCount;
WaterPulseCount = 0; // Reset the water pulse counter
attachInterrupt(WATER_SENSOR_PIN, WaterPulseCounter, FALLING);
sprintf(liters_S, "%4.3f", liters);
if(liters_S > .04)
I’ve also tried adding the Particle.publish line below, just to see what would happen. It compiled, but I didn’t see anything in the cloud. Again, I’m pretty much clueless, sorry.
Particle.variable("litersS", liters_S, STRING);
// Set Digital pin WATER_SENSOR_PINT to INPUT mode and set
// interrupt vector (water flow sensor) for FALLING edge interrupt
attachInterrupt(WATER_SENSOR_PIN, WaterPulseCounter, FALLING) ;
oldTime = millis();