### Panel Meter Clock (yet another one)

Moderator: Mmiscool

### Panel Meter Clock (yet another one)#53944

By russm
#53944 Have wanted to make one of these for a while so I finally got it started. Code is really easy in ESP8266Basic!

Here is a picture of two panel meters for hours and minutes. When I get another panel meter I'll add seconds, it is pretty cool to see them tick by.

The panel meters are 1mA max. I found some 3.2K ohm resistors which are just slightly higher than needed. I will add a trim pot for each to adjust. Also, fighting some breadboard resistance that changes with wire movement.

I used a program to generate the simple panel meters. You can adjust the size for your particular panel meter. http://www.tonnesoftware.com/meterbasicdownload2.html Took a few prints to get it right. The meters come apart pretty easily. I'll redo them with better paper eventually, this was good enough for now.

The basic code is pretty simple. I have a few things to add as noted in the header. Running on V3.0 Alpha 42
Code: Select all`'******************************************************'* Analog Panel Meter Clock                           *'*   by Russ McIntire, 8/27/16                        *'*   D0 = Hours                                       *'*   D1 = Minutes                                     *'*   D2 = Seconds                                     *'*                                                    *'* To do: HTML setup screen to select DST, TZ, SSID   *'*        Daily NTP timesetup call                    *'******************************************************timesetup(-4,1)  'Need to figure out what is wrong with DSTdelay 5000udpbegin 5001hour = 0min = 0sec = 0M = " "udptimer = 0hourpwm = 0minpwm = 0secpwm = 0timer 1000, [updatetime]waitend[updatetime]'Get time values from NTP server hour = val(time("hour")) min = val(time("min")) sec = val(time("sec"))'For UDP message show AM/PM if hour > 12 then  hour = hour - 12  M = "PM" else  if hour = 0 then   hour = 12  endif  M = "AM" endif'Panel PWM calculationhourpwm = 93.1 * (hour - 1)  'divide 1024/11minpwm = 17.36 * min         'divide 1024/59secpwm = 17.36 * sec         'divide 1024/59'Panel outputio(pwo,d0,hourpwm)io(pwo,d1,minpwm)io(pwo,d2,secpwm)'Send UDP broadcast message out for current time udptimer = udptimer + 1 if udptimer > 30 then  ct = str(hour)&":"&time("min:sec")&" "&M  udpwrite "192.168.10.255", 5001, ct   udptimer = 0 endifwait`

It will eventually go into a wood cabinet and be constructed on a little perf board or perhaps I'll make a PCB. Hoping I can get DST working right someday. Can't seem to get it to actually do anything, had to make a work around for the aquarium timer.
Last edited by russm on Sat Aug 27, 2016 11:12 pm, edited 1 time in total.

### Re: Panel Meter Clock (yet another one)#53945

By russm
#53945 Just did an OTA update to V3.0 A43. Hilarious to watch the panel meters dance as the upgrade occurs.

### Re: Panel Meter Clock (yet another one)#53951

By russm
#53951 Added a couple features:
1) Determines udp broadcast address from current address (assumes class c)
2) Added once/day (2:00 AM) update for NTP

Code: Select all`'******************************************************'* Analog Panel Meter Clock                           *'*   by Russ McIntire, 8/27/16                        *'*   D0 = Hours                                       *'*   D1 = Minutes                                     *'*   D2 = Seconds                                     *'*                                                    *'* To do: HTML setup screen to select DST, TZ, SSID   *'******************************************************timesetup(-4,1)  'Need to figure out what is wrong with DSTdelay 5000udpbegin 5001i = 0x = 0x1 = 0broadcastaddr = " "hour = 0min = 0sec = 0M = " "udptimer = 0hourpwm = 0minpwm = 0secpwm = 0'Determine broadcast addressipaddr = ip()for i = 1 to 3 x = instr(ipaddr,".",x1+1) x1 = xnextbroadcastaddr = left(ipaddr,x)&"255"timer 1000, [updatetime]waitend[updatetime]'Get time values from NTP server hour = val(time("hour")) min = val(time("min")) sec = val(time("sec"))'Set 12 hour time and determine AM/PM if hour > 12 then  hour = hour - 12  M = "PM" else  if hour = 0 then   hour = 12  endif  M = "AM" endif'Panel PWM calculationhourpwm = 93.1 * (hour - 1)  'divide 1024/11minpwm = 17.36 * min         'divide 1024/59secpwm = 17.36 * sec         'divide 1024/59'Panel outputio(pwo,d0,hourpwm)io(pwo,d1,minpwm)io(pwo,d2,secpwm)'Daily NTP refreshif ((hour=2) and (min=0) and (sec>0) and (sec<5) and (M="AM")) then timesetup(-4,1)  'Need to figure out what is wrong with DST delay 5000endif'Send UDP broadcast message out for current time every 30 seconds udptimer = udptimer + 1 if udptimer > 30 then  ct = str(hour)&":"&time("min:sec")&" "&M  udpwrite broadcastaddr, 5001, ct   udptimer = 0 endifwait`

### Re: Panel Meter Clock (yet another one)#53963

By forlotto
#53963 an excellent use of your time! :P
First time I seen the analog meter type clock personally I've seen some pretty interesting clocks but guess I missed these or forgot about them.

I like your code example as well it gives people a grasp on how to handle time in a fairly easy manner.

think the following should work for you

timesetup():
Will set up the time time zone and daylight savings attribute.
timesetup({number or var for time zone},{number or var for dst})

So for instance:

timesetup(6,1)
delay 5000
get time value

6 would be central and 1 I believe is DST enable 0 is DST disabled.

You need a delay after time setup for time adjustment 5 seconds is likely overkill but play with it and see where the magic number is .

I am not sure if you have to do it after each request for hour minute I don't think you'll be doing seconds in this case just not likely imho unless you have some snazzy way of doing it in code well technically you could do so you could actually with a for x loop then increase the number of minutes you could actually be your own timer with a for x loop but you would likely lose seconds and have to resync every so often but it would be possible to do if I am thinking correctly with the right code.

Anyways good stuff thank you for sharing this one with us lots of useful info.