I've connected PC fan tacho to IO pin 2 (with pullup from 3.3v) and wanted to count pulses. Here the code:
wifi.setmode(wifi.NULLMODE, false);
gpio.mode(2, gpio.INT);
tacho_2 = 0
gpio.trig(2, "down", function()
tacho_2 = tacho_2 + 1
end)
function start()
print("tacho ".. tacho_2 .. "\n");
tacho_2 = 0
end
tmr.create():alarm(1000, tmr.ALARM_AUTO, start)
But the interrupt is triggered too many times... There are about 38 pulses per second, but the interrupt seems to be triggered about 100 times per second.
And yes, I know the tacho pules are no revolutions.
Any suggestions?