reed switch count pulses - pulldown or pullup

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Ralle
New user
Posts: 3
Joined: 28 Jun 2021, 18:01

reed switch count pulses - pulldown or pullup

#1 Post by Ralle » 28 Jun 2021, 19:49

Hello all,
I want to count the switching pulses from a simple reed switch (from a rain gauge counter).
For this I have chosen the function "Generic - Pulse counter". Unfortunately no pulse of the switch is recognized. Alternatively I have also tried "Switch input", without success.
The pulldown resistor has 68 kΩ
What am I doing wrong?
2021-06-24_18-50.png
2021-06-24_18-50.png (92.81 KiB) Viewed 5784 times

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: reed switch count pulses - pulldown or pullup

#2 Post by ThomasB » 28 Jun 2021, 20:06

With your "active high" switch wiring you must ensure that the GPIO's internal pullup is NOT enabled. So check your device settings. Also, the 68K pulldown might need to be reduced (try 10K).

I normally use Active Low methods. That is to say, switch is connected to ground and provides a logic low when activated. And when wiring is short I use the internal pullup (with Inversed logic enabled too). But if wiring is more that a few inches long I add an external pullup resistor (2.2K to 10K ohms).

- Thomas

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: reed switch count pulses - pulldown or pullup

#3 Post by TD-er » 28 Jun 2021, 20:13

Also you're using GPIO-5. That pin is by default assigned to I2C, so make sure the I2C settings are changed if you want to use those pins. (Hardware tab)

Ralle
New user
Posts: 3
Joined: 28 Jun 2021, 18:01

Re: reed switch count pulses - pulldown or pullup

#4 Post by Ralle » 28 Jun 2021, 21:01

Thank you for your support,
@ TD-er
i think it is not GPIO 5 but GPIO 14 = D5, or did i get it wrong? That would explain everything.
@ThomasB
i will change it to Active Low with 10 kΩ tomorrow and test it.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: reed switch count pulses - pulldown or pullup

#5 Post by TD-er » 28 Jun 2021, 21:32

Ah yes, I always get confused by those ridiculous "D" markings once introduced by the NodeMCU boards.

Ralle
New user
Posts: 3
Joined: 28 Jun 2021, 18:01

Re: reed switch count pulses - pulldown or pullup

#6 Post by Ralle » 30 Jun 2021, 20:07

I don't understand it.....
1. GPIO is always HIGH, no matter what I set under Hardware/ GPIO = (Output Low, Output High or...).
ok then it is so but,
2. if I set up a device "Generic - Pulse counter" I expect that with every change of GPIO 14 from High to Low the pulses are counted. But unfortunately nothing happens.
For testing I have set up a device "Switch input - Switch" but also here the status is always 0
But under Tools / Log I see that GPIO changes from High to Low.

To exclude all sources of error
I set GPIO 14 (D5) directly to GND for this test. The internal PullUp is on.

2021-06-30_20-04.png
2021-06-30_20-04.png (7.98 KiB) Viewed 5717 times
2021-06-30_19-40.png
2021-06-30_19-40.png (44.79 KiB) Viewed 5717 times
Screenshot_2021-06-30 thermo.png
Screenshot_2021-06-30 thermo.png (101.39 KiB) Viewed 5717 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: reed switch count pulses - pulldown or pullup

#7 Post by TD-er » 30 Jun 2021, 23:30

GPIO-0 is pulled high with a pull-up resistor of roughly 10k.
This is to make sure the ESP will boot into the mode for running the program. Pulling down during boot => flash mode.
So this alone makes it a bad idea to add something to this pin which may be "low" during boot.
The same for GPIO-2.
GPIO-15 must be pulled down during boot.

The internal pull-up resistor of the ESP itself is roughly 80k, so very weak.

The values on the devices tab are only updated every N seconds, depending on the lowest "interval" of the enabled tasks.
On top of that, this update did not include the values from the pulse counter, which is a bug I fixed quite recently.
In this build ( https://td-er.nl/ESPEasy/ ) it should be fixed, but still the update frequency depends on the lowest "interval" value.
For this I usually add a "Sysinfo" task set to 1 sec.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: reed switch count pulses - pulldown or pullup

#8 Post by ThomasB » 01 Jul 2021, 02:30

GPIO is always HIGH, no matter what I set under Hardware/ GPIO = (Output Low, Output High or...).
It's not fully clear what you are doing, but I think your testing method needs some attention. Firstly, do not configure the Hardware/ GPIO value when using the Switch input - Switch device. There's no need for this because the plugin's settings are used. So Set Hardware/ GPIO = Default.

To reliable test the switch's input state you should add a mechanical switch to the GPIO input. Also, change the Switch input - Switch device's GPIO-14 "Switch Button Type" to "Normal Switch." Configure debounce time to something around 100mS. Now test the switch while observing the serial log. The GPIO=14 State should now reflect the logic state of the GPIO-14 switch input.

BTW, long wire leads to the switch will require an external pullup resistor (2.2K to 10K ohms). But sometimes it may be necessary to add it on short leads too.

- Thomas

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests