seeking a rule daytime light curve on aquarium

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
noxin
New user
Posts: 2
Joined: 28 Dec 2023, 12:44

seeking a rule daytime light curve on aquarium

#1 Post by noxin » 20 Feb 2024, 11:09

dear forum,

I use an ESP32 together with an IRF520 module to control the LED strip above my aquarium and i was able to figure out how this works with a rule.
Now I would like to slowly increase the brightness in the morning and slowly reduce it in the evening like sunrise and sunset.
I'm not looking for a complicated light curve, a linear curve is sufficient.
Despite researching in the local forum, I didn't find anything suitable rule, which may also be due to the language barrier.
I would be grateful for a good tip.
( i had to use the g**g**-translator for this post)

regards
noxin

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

Re: seeking a rule daytime light curve on aquarium

#2 Post by TD-er » 20 Feb 2024, 11:33

Have you looked at the sysvars page? (tools->System Variables button)

On there you can see %sunset% and %sunrise%, but also variants like %sunset-1h% and %sunrise+10m%
N.B. for correct sunset/sunrise times, it is important you have your DST & timezone and your GPS position set on the Tools->Advanced page. (and NTP checkbox checked of course)

Let's assume you need to start your "fade on" at %sunrise-15m% and want to fade on for 30 minutes.

Code: Select all

on Clock#Time=All,%sunrise-15m% do
  // ...
  // See: https://espeasy.readthedocs.io/en/latest/Rules/Rules.html#system-events
endon
I guess one step up per minute is good enough, so you can use the looptimer for a fixed amount of calls like this:

Code: Select all

on Clock#Time=All,%sunrise-15m% do
  looptimerset,1,60,30 // Set timer #1 with 60 sec interval for 30 loops
endon
See: https://espeasy.readthedocs.io/en/lates ... oop-timers

Then you need to handle this timer:

Code: Select all

On Rules#Timer=1 do
  //  The 2nd eventvalue (%eventvalue2%) is the count of the current loop.
  // Compute the dim value based on the current loop count
  // Max dim value = 1023, 30 steps, so each step is 34.
  // See: https://espeasy.readthedocs.io/en/latest/Plugin/P000.html#internal-gpio
  let,1,%eventvalue2%*34
  pwm,2,[int#1] // Set GPIO pin 2 to the computed PWM value
endon
Edit:
When using an translator to read this, please do not translate the example rules I gave you as it may also translate rules commands which cannot be processed by ESPEasy.

noxin
New user
Posts: 2
Joined: 28 Dec 2023, 12:44

Re: seeking a rule daytime light curve on aquarium

#3 Post by noxin » 20 Feb 2024, 12:29

hello TDer,

this answer was writen very fast, many thanks for it !
I have set a NTP-service, i will now set dist, timezone and gps-pos.
i will now have to create the correct rule-set, but im confident to get it !

regards
noxin

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests