ADC, Generic HTTP Update by changing over / under values

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
adlerauge1980
Normal user
Posts: 13
Joined: 22 Sep 2019, 16:15

ADC, Generic HTTP Update by changing over / under values

#1 Post by adlerauge1980 » 24 Apr 2022, 15:54

Hi Forum Peoples
I have a question about ADC (Analog input) at my ESP8266
I get values in the range 0 to 400
However, these often change by +/- 5. That gives a lot of data traffic.
However, I only need a notification to my Generic HTTP Controller, when it goes below or above 100.
example: over 100 send a 1 or true and when goes under 100 send a 0 or false


Is for vehicle detection with a Metal Sensor (Garage it's bussy or not)
less than 100 = car is outside
greater than 100 = car is inside
(this value is variable due to the size of the car)

Is there a way to do this? possibly with a rule?

Thanks for your helps!

User avatar
Ath
Normal user
Posts: 3488
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ADC, Generic HTTP Update by changing over / under values

#2 Post by Ath » 24 Apr 2022, 16:28

In that case you should disable the Controller in the Device configuration, and add a Rule with something like this:

Code: Select all

on ADC#Analog do
  if %eventvalue1% > 100
    sendtohttp,<ip>,<port>,<url,status=1>
  else
    sendtohttp,<ip>,<port>,<url,status=0>
  endif
endon
/Ton (PayPal.me)

adlerauge1980
Normal user
Posts: 13
Joined: 22 Sep 2019, 16:15

Re: ADC, Generic HTTP Update by changing over / under values

#3 Post by adlerauge1980 » 24 Apr 2022, 18:49

Hallo Ath

Thanks for your helps.
The Rule works, but, the problem its, when the Value change from 130 to 131 (example) than send esp this again.

I only need a message when the threshold is below or above 100. (Whit your example spam me the ESP my remote station full) :lol:

can i intercept this somehow?

User avatar
Ath
Normal user
Posts: 3488
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ADC, Generic HTTP Update by changing over / under values

#4 Post by Ath » 24 Apr 2022, 19:12

Please show your current rule, so I can adjust the code for you.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3488
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ADC, Generic HTTP Update by changing over / under values

#5 Post by Ath » 24 Apr 2022, 19:36

I've re-used my earlier code to come up with a possible solution.

Code: Select all

on ADC#Analog do
  if %eventvalue1% > 100
    if %v1% = 0
      sendtohttp,<ip>,<port>,<url,status=1>
      let,1,1
    endif
    let,2,0
  else
    if %v2% = 0
      sendtohttp,<ip>,<port>,<url,status=0>
      let,2,1
    endif
    let,1,0
  endif
endon
NB: Untested!
/Ton (PayPal.me)

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

Re: ADC, Generic HTTP Update by changing over / under values

#6 Post by TD-er » 24 Apr 2022, 20:48

Also please add a small capacitor close to the ESP over the A0 pin and the GND.
For example 100 nF is generally a good value to start with to filter out some noise.
But for slow changing voltages, you may want to combine a low capacitance value and a higher one.
e.g. 100 nF + 10 uF (note the polarity of the larger one!)

Enabling oversampling in the ADC is also a good idea to get a more stable reading.

adlerauge1980
Normal user
Posts: 13
Joined: 22 Sep 2019, 16:15

Re: ADC, Generic HTTP Update by changing over / under values

#7 Post by adlerauge1980 » 04 May 2022, 18:14

Ath wrote: 24 Apr 2022, 19:36 I've re-used my earlier code to come up with a possible solution.

Code: Select all

on ADC#Analog do
  if %eventvalue1% > 100
    if %v1% = 0
      sendtohttp,<ip>,<port>,<url,status=1>
      let,1,1
    endif
    let,2,0
  else
    if %v2% = 0
      sendtohttp,<ip>,<port>,<url,status=0>
      let,2,1
    endif
    let,1,0
  endif
endon
NB: Untested!
Hello Ath, thanks for this querry, after my first tests, work this fine! thank you verry much!

adlerauge1980
Normal user
Posts: 13
Joined: 22 Sep 2019, 16:15

Re: ADC, Generic HTTP Update by changing over / under values

#8 Post by adlerauge1980 » 04 May 2022, 18:16

TD-er wrote: 24 Apr 2022, 20:48 Also please add a small capacitor close to the ESP over the A0 pin and the GND.
For example 100 nF is generally a good value to start with to filter out some noise.
But for slow changing voltages, you may want to combine a low capacitance value and a higher one.
e.g. 100 nF + 10 uF (note the polarity of the larger one!)

Enabling oversampling in the ADC is also a good idea to get a more stable reading.
Hallo TD-er

and you also a big thanks for this info. i must this make in a slow time window

Thank you!

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests