Automatic scheduler. ESP-01 with 4 Time Input Widgets

Where are sunrise et sunset in psoro’s code ? I don’t see that
I use openweathermap’s API to get them.

its not in psoros code, i wanted to know where i can include your code snippets, i dont use openweathermap’ API

how do i get about that?

You have to suscribe to, it’s free
once you get json string, you have to use my code.

this is the string you get with API

{"coord":{"lon":5.01,"lat":44.84},"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"base":"stations","main":{"temp":19.99,"feels_like":13.56,"temp_min":18.89,"temp_max":21,"pressure":1029,"humidity":43},"visibility":10000,"wind":{"speed":8.2,"deg":350},"clouds":{"all":34},"dt":1590341663,"sys":{"type":1,"id":6505,"country":"FR","sunrise":1590292743,"sunset":1590347696}

as you can see, sunrise is 1590292743, unix time

If you don’t want to use openweathermap ,
you can follow this code from @Lichtsignaal

No need to subscribe, just enter lng. and lat.

Wouldn’t it be simpler to use the Sunrise/Sunset option in the Time Input widget?


but I never use this option, and I don’t know how to get sunset and sunrise from this widget :thinking:

Hi Pete, thats was my initial idea, when i run psoros code, i cannot include sunset/sunrise as input, how do i use this in psoros code?

thanks Blynk_Coeur- you thought me something new :slight_smile:

1 Like

You don’t need to extract sunset and sunrise time from the widget ?
I never see a function, there is not t.getSunrise in blynk


1 Like

Yes Pete,
I know this library, but you can’t get sunset and sunrise time from this, maybe I’m wrong.

yeah me too

Apologies, I was getting confused (it doesn’t take much :crazy_face:).
I’ve used the time input widget to give the option to choose Sunset and Sunrise as the start/stop times for some lights, but I’d forgotten that the widget just sends “ss” and “ss” so when I see these I use the SunCalc module in Node-Red translate this to a time for my latitude and longitude and then use those times.
That is all buried deep in a custom function that I’d long forgotten about :slightly_smiling_face:


1 Like

it’s so bad, we can’t get the info from this widget.

I think the sunrise-sunset also gives different styles of time, mind you. There are nautical, astronomical and several other types of sunset. I’m not sure what the default return is, but it should be all in the JSON you get back.

Way back when I wrote that piece of code I made my own JSON interpreter but I suggest you use something prebuilt. There are several very good and free JSON interpreters for Arduino on GitHub. Cheers!

1 Like

Sound like an ambient light sensor would be the easiest :wink:

1 Like

Well, to measure is to know, as we say in The Netherlands, so you are obviously right, however, I’ve noticed it’s very difficult to obtain a reasonable measurement. I used to measure with 3 LDR’s which all pointed in different directions of the room and averaged all those values out. Also I fiddled with the timing taken with measurements, e.g. if the lights were turned on I increased the LDR timer to measure every ten minutes instead of every 30s because that would mean light going off and on all the time.

Anyway, it’s good to experiment with both options, lots of fun and insights to gain!

1 Like

I found this sketch very useful. With the changes I needed it works great.
One question: do you think it is possible to add a second timer (or even more)?
For example when alldays is running one timer in the morning and one timer in the evening (without having to create a second alldays).