Does enabling the pulse counter turn on the GPIO pull-up?
Posted: Sun Jul 08, 2018 11:18 am
Hi all,
I'm developing an IoT application that responds to pulses coming in from an external sensor. I've had it working fine with the sensor wired directly to a GPIO pin with an interrupt handler configured but I thought that I would try moving to the pulse counter instead. My application needs to count pulses over a period of one or two minutes, then report the result up to a central server - the pulse counter seems to be the perfect solution.
When I modified the code and fired it up, nothing happened - no pulses detected at all. After spending a good couple of hours reading my code and the Espressif hardware documentation, I decided to check the hardware - I hooked an oscilloscope up to the GPIO input pin and discovered that it was being held high all the time. I disconnected the sensor, hooked it up to the scope and it was working fine - plenty of pulses coming in and showing on the scope screen. I left the hardware the same and reverted to my old code and it worked fine - the GPIO pin was no longer held high and the code saw the pulses.
I then tried an old sensor that I had been using earlier successfully. Even with the pulse counter enabled, this worked! I think that the difference is that the old sensor is very basic technology and can source or sink a significant current. The new sensor is ultra low power and when the pulse counter in the ESP32 is enabled, it seems that the GPIO pin is getting some pull-up turned on which is too strong for the new sensor.
Does this make any sense? I've looked through the documentation for the pulse counter and can see no mention of pull-up. My code explicitly turns off both the pull-up and pull-down on the input pin and it works fine provided I don't enable the pulse counter but as soon as I add the line of code to turn on the counter, the input pin flips up to 3v and stays there!
I'm developing an IoT application that responds to pulses coming in from an external sensor. I've had it working fine with the sensor wired directly to a GPIO pin with an interrupt handler configured but I thought that I would try moving to the pulse counter instead. My application needs to count pulses over a period of one or two minutes, then report the result up to a central server - the pulse counter seems to be the perfect solution.
When I modified the code and fired it up, nothing happened - no pulses detected at all. After spending a good couple of hours reading my code and the Espressif hardware documentation, I decided to check the hardware - I hooked an oscilloscope up to the GPIO input pin and discovered that it was being held high all the time. I disconnected the sensor, hooked it up to the scope and it was working fine - plenty of pulses coming in and showing on the scope screen. I left the hardware the same and reverted to my old code and it worked fine - the GPIO pin was no longer held high and the code saw the pulses.
I then tried an old sensor that I had been using earlier successfully. Even with the pulse counter enabled, this worked! I think that the difference is that the old sensor is very basic technology and can source or sink a significant current. The new sensor is ultra low power and when the pulse counter in the ESP32 is enabled, it seems that the GPIO pin is getting some pull-up turned on which is too strong for the new sensor.
Does this make any sense? I've looked through the documentation for the pulse counter and can see no mention of pull-up. My code explicitly turns off both the pull-up and pull-down on the input pin and it works fine provided I don't enable the pulse counter but as soon as I add the line of code to turn on the counter, the input pin flips up to 3v and stays there!