Switch Counter

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Xumpy
New user
Posts: 3
Joined: 20 Mar 2018, 07:46

Switch Counter

#1 Post by Xumpy » 20 Mar 2018, 07:56

Hey All,

First of all let me congratulate you guys on building the nicest coolest framework I've ever seen for the esp8266.
Now I have a little problem. Currently I'm trying to read my watermeter with a TCRT5000 connected to my esp8266.
My water meter is a Elster with a little mirror that rotates every 0.001m3. The mirror takes half of the circle.

The problem I have is that with that mirror my TCRT5000 can have 2 states. Or D0 is on or D0 is off (reflecting at the mirror or not reflecting at the mirror).
What I want to read is when that state switches. So when the mirror comes at the led or when it leaves the led.

The pulse counter is not for me in this scenario cause it keeps counting as long as the state of the TCRT5000 is on (pointed at the mirror).
So what I need is some kind of switch counter. Is that possible?

I could build it myself in arduino but I would really like to use this framework cause it has more possibilities that my arduino skills :p

Thanks,

Br,

Nico

Xumpy
New user
Posts: 3
Joined: 20 Mar 2018, 07:46

Re: Switch Counter

#2 Post by Xumpy » 20 Mar 2018, 14:28

Alright to answer my own question. The problem is that somehow the TCRT5000 is triggering the CHANGE interrupt.
I think this might be triggered by some noise.

Is there a solution for that? For now I've just connected D0 of the TCRT5000 to GPIO14 of the esp8266.
I could copy the plugin and build myself a new one where I just check every 1 second what the value of the pin is and if it changes I can add the necessary values.

However I don't really like that solution. Aren't there any better solutions?

Thanks,

Br

Nico

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

Re: Switch Counter

#3 Post by TD-er » 20 Mar 2018, 19:36

Noise like that is often an electronics issue.
So please show some drawing indicating how the input is connected and what kind of signal is to be expected.
The extra electronics needed can range from nothing (internal pull-up resistor activated in ESPeasy) to some kind of low-pass filter (rsistor + capacitor) or some inverter chip to brush up the signal.

Xumpy
New user
Posts: 3
Joined: 20 Mar 2018, 07:46

Re: Switch Counter

#4 Post by Xumpy » 21 Mar 2018, 07:54

Hey, thanks for the reply,

I connected D0 of the TCRT5000 directly with GPIO14. I was also thinking about using a capacitor as a low-pass filter.
But I would prefer to keep the electronics as simple as possible.

I will investigate in the possibilities. Maybe hook up a scope to it so I could see the noise. Will take some time to investigate but I will post my results.

edit:
Apparently the Internal pullup is already activated in the code:
pinMode(Settings.TaskDevicePin1[event->TaskIndex], INPUT_PULLUP);

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 14 guests