Hi, I'm trying to get my pi to read pulses to a GPIO pin. This is in preparation for reading from a hall effect flow sensor in my water line. Right now I'm just trying to get software + hardware reading pulses. I have a signal generator set to output square waves. The thing is no matter what my output frequency (generally I'm attempting 5-20hz) I get strange readings (example output below). I also tried just connecting a wire from ground or from 3.3v to the pin (and various assortments of pull down/pull up settings in my code) and I get odd output from that also. If I just touch the wires together, I might get a count of 120 pulses in a second, for example. Adding the debounce code (glitchFilter) did not help. Any ideas what might be happening?
Here is my code
And the output while the signal generator is connected. I can adjust the output frequency and the counts don't really change. But if I disconnect the signal generator, then my counts go to zero. I have an oscilloscope connected in the circuit too, and everything looks good there.
Here is my code
And the output while the signal generator is connected. I can adjust the output frequency and the counts don't really change. But if I disconnect the signal generator, then my counts go to zero. I have an oscilloscope connected in the circuit too, and everything looks good there.
Javascript:
const Gpio = require('pigpio').Gpio;
var counter = 0
//const led = new Gpio(17, {mode: Gpio.OUTPUT});
const button = new Gpio(6, {
mode: Gpio.INPUT,
pullUpDown: Gpio.PUD_UP,
edge: Gpio.RISING_EDGE
});
// debounce - shouldn't be necessary? It didn't help
//button.glitchFilter(10000);
button.on('interrupt', (level) => {
//led.digitalWrite(level);
counter++
});
setInterval(function() {
//read the count of pulses
console.log(counter);
counter = 0
}, 1000);
Example output when the signal generator is connected:
356
440
366
459
401
387
365
396
414
399
376
411
365
391
400
458
422
456
416
441
431
426
369
397
423
424
416
411
407
400
388
393
438
418
454
371
425
383