Need a delay before read analog value in mega 20200608

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
FreakErn
New user
Posts: 2
Joined: 30 Jun 2020, 13:22

Need a delay before read analog value in mega 20200608

#1 Post by FreakErn » 02 Jul 2020, 20:18

Hey Folks,

i flashed the mega 4MB version 20200608 onto my ESP-07S. He acts as a Light sensor, connected to a 3.7v battery, a solar panel and a photoresistor (connected through a voltage-Divider to the analog pin).

The ESP8266 has a deep sleep time of 300 seconds and he works almost perfect. The only problem i have is that the first reading after boot is a way to low value.

Normal measurements are 10 as minimum value in pure dayligt and in the middle of the night the readings are about 205 or even higher.

Is there a way to wait a second before read after boot?

second question: Where is the "Message Delay" from the Advanced page?

Thanks in advance

/Edit
Sorry, i just configured the device (Analog input) and the Controller (UDP Generic to send it to my Loxone automation) and set the deep-Sleep awake time.

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

Re: Need a delay before read analog value in mega 20200608

#2 Post by TD-er » 02 Jul 2020, 21:17

You can trigger a read from the rules by "running" the task for the analog input.
See Taskrun
So if you call a read at some timer event in the rules, you can take it whenever you like.

Please take into account the WiFi activity will affect the ADC reading. (and vice verse)
This also means there are no readings taken while still in the WiFi connect phase.
I suggest to wait for the wifi#connected event in the rules to trigger the ADC reading and send that value.
If it is hard to filter out the first sample, you can store the read value in a dummy task and then call a taskrun on the dummy task, or format your own publish command in the rules.

Also the ADC value is quite a bit more stable when you use the oversampling feature, although I am not entirely sure it is the best to use the samples collected during WiFi connection phase.

I removed the "message delay" feature as it is now replaced by the "minimal send interval" setting in each controller setting.
Also the old "message delay" feature was actually quite a bad design as it was a blocking wait stalling everything on the node.
This could lead to all kinds of issues.

chlorinelangley
New user
Posts: 1
Joined: 19 Aug 2020, 05:56

Re: Need a delay before read analog value in mega 20200608

#3 Post by chlorinelangley » 19 Aug 2020, 06:13

Totally agree :D

Sang15512
New user
Posts: 1
Joined: 24 Aug 2020, 14:37

Re: Need a delay before read analog value in mega 20200608

#4 Post by Sang15512 » 24 Aug 2020, 14:39


Post Reply

Who is online

Users browsing this forum: Google [Bot] and 83 guests