Timer with astronomical sunset & sunrise time from geo

It will be nice to have a timer widget where user can select a city or geo-coordinates and timer will be engaged in a time of sunset, sunrise or both

All the tools for this use-case are provided.

You have the Timer Widget, Time Input Widget, Webhook Widget.

Up to you now to make them work together via code. Good luck!

I made something similar. The code is bit big, but if you are interested I can post it. As @Jamin says, I used the time input, cal a http api and parse the times. Since sunrise-sunset.org (or something) also provides different methods of calculating like astronomical and nautical you can set it up with a menu widget to choose different settings.

1 Like

Yes, it seems that all what is needed exists

It will be nice to have a code. Before I switched to Blynk service I have used MQTT client on Arduino Ethernet board and my own MQTT broker on a Raspberry Pi. The Raspberry calculated time of house wall lights ON/OFF by using astronomical library and the internet time

I’ve put the Code on GitHub https://github.com/WhizzCat/sunriselight_0.3_anon

I use the PlatformIO IDE to develop stuff, so the directory structure might be a bit weird, but all the code is in the src/ directory. Any questions, please let me know :slight_smile:

1 Like

Thanks!

@Lichtsignaal where are you picking up the sunrise / sunset dates from for the rollover of each day?

Edit: found it.

Its a big piece and not always in logical order :smiley:

1 Like

@Lichtsignaal with an ESP and the json parser it takes us on average 6.2s to get the data whereas Webhook averages just 1.5s. Obviously this is because a powerful server is doing the work rather than a $5 ESP.

I notice you disconnect and reconnect from Blynk during the WiFi Client call whereas we don’t bother. How long does it take for your data gathering?

@Dmitriy I think Webhook adds great functionality and flexibility to Blynk and it would be a shame to lose it in the “App builder”. It’s quite possible to code without the Webhook but it adds extra effort for Blynkers and goes against the Blynk ethos.

1 Like

Tbh, I don’t really timed it, but webhook could be faster. I just plug my lamp in and it starts up. Syncing with time and the api usually gets done in under a second. I’ve built in an indicator which displays red lights while it starts up and it just flashes up under a second.

What is your hardware setup to achieve the API call via WiFi Client in less than 1s?
Are you sure the 1s is not a sync process i.e. the MCU made the API call earlier in the day and simply plugging in a lamp takes the sunrise data from the MCU rather than the API?