Re: Speed sensor error condition on startup
Posted:
Wed Jan 13, 2021 4:22 pm
by walders
Thanks, I'm using nodeMCU v3 LoLin device.
Strange behaviour, I've tried all other gpio without any success in picking up sensor event! The code at least runs at startup on the other input digital pins. Just the sensor events are not picked up at all?
Re: Speed sensor error condition on startup
Posted:
Thu Jan 14, 2021 3:49 am
by QuickFix
Try this instead:
- Put the sensor to GPIO13 (= D7 on the NodeMCU)
- Replace the setup() code with this:
Code: Select allvoid setup()
{
Serial.begin(19200);
pinMode(13, INPUT); // probe output on pin 13
attachInterrupt(digitalPinToInterrupt(13), isr, RISING);
numPulses = 0; // prime the system to start a new reading
}
(BTW: Shouldn't you have set the pinMode to INPUT instead of OUTPUT?)
Re: Speed sensor error condition on startup
Posted:
Thu Jan 14, 2021 7:17 am
by walders
Thanks @QuickFix, brill, this works
Yes, you're right, should have use input. Also should of have checked the gpio pin reference which can be found here:
https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/Thanks also for "attachInterrupt(digitalPinToInterrupt(13)" didn't know about that
cheers