Post about your Basic project here

Moderator: Mmiscool

User avatar
By russm
#54102 New meters came today, should look great, slightly larger. Will have 3 for final design. Made the seconds label for this one:

Image

After getting the race car ready, I'll be making a nice wood cabinet for my new clock this weekend. Can't wait to place it front and center in the living room, I'm sure my wife will love it almost as much as the race car. :)
User avatar
By forlotto
#54143 wow gotta see that sucker in action looks pretty nifty but the end result I am curious on kinda retro looking not quite steam punk but electronic punk :P
User avatar
By russm
#54145 I finally put the nodemcu on a protoboard and soldered everything up with trim pots. What a huge difference in accuracy. Extremely simple PCB layout, protoboard took about 15 minutes to make.

Here are some pictures:
Image

Image

Image

Updated code with bug fixes:
Code: Select all'*******************************************************
'* Analog Panel Meter Clock                            *
'*   by Russ McIntire, 8/31/16                         *
'*   D0 = Hours                                        *
'*   D1 = Minutes                                      *
'*   D2 = Seconds                                      *
'*   D4 = varies intensity to show clock running       *
'*                                                     *
'* Shows hours/minutes/seconds on 3 panel displays     *
'* Allows Timezone and DST settings from webpage       *
'* Requires Internet connection for NTP time retrieval *
'* Sends UDP broadcast of current time via UDP         *
'* Can update UDP Port in settings, default is 5001    *
'*******************************************************
memclear

'Get DST and Timezone info from memory
DST = read.val(DaylightSavings)
timezone = read.val(TZ)
udpportval = read.val(UdpPort)

if DST = 1 then
 tz = timezone + 1
else
 tz = timezone
endif

if udpportval = 0 then udpportval = 5001
udpbegin udpportval

timesetup(tz,DST)
delay 5000

hour = 0
min = 0
sec = 0
M = " "
udptimer = 0
hourpwm = 0
minpwm = 0
secpwm = 0
updated = 0
updatetimer = 0
cts = time("hour:min:sec")
uvsr = "Running..."

'Determine broadcast address
let localIP = ip()
pos = instrrev(localIP,".")
netIP = left(localIP,pos)
nodeIP = mid(localIP,pos+1)
let broadcastaddr = netIP & "255"

'GUI setup
cls
wprint |<HTML>|
wprint |<HEAD>|
'wprint |<meta http-equiv='refresh'content='5;URL=/input?'>|
wprint |<h2>Analog Clock Setup Info</h2>|
wprint |</HEAD>|
'wprint |<body bgcolor="grey">|
wprint "<br>"

wprint "The time is currently: "
wprint htmlvar(cts)  ' time("hour:min:sec")
wprint "<br>"

wprint "Timezone: "
textbox timezone
wprint "<br>"
wprint "DST:         "
textbox DST
wprint "<br>"
button "Time Info Update", [timezone_update]
wprint "<br> <br>"
wprint "UDP Port:  "
textbox udpportval
wprint "<br>"
button "UDPPort Update", [udpport_update]
wprint "<br> <br>"

wprint htmlvar(uvsr)

timer 1000, [updatetime]
wait
end

[updatetime]
'Get time values from NTP server
 hour = val(time("hour"))
 min = val(time("min"))
 sec = val(time("sec"))

'For calibration (max meter swing)
'hour = 11
'min = 30
'sec = 59

 cts = time("hour:min:sec")

'Set 12 hour time and determine AM/PM
 if hour >= 12 then
  hour = hour - 12
  M = "PM"
 else
  M = "AM"
 endif

'Panel PWM calculation
'hourpwm = 85.33 * (hour)                 'divide 1024/12
hourpwm = (85.33 * hour) + (1.446 * min)   'divide 1024/12 add proportion of minutes (1.445/min)
minpwm = 17.36 * min                      'divide 1024/59
'minpwm = (17.36 * min) + (.289 * sec)     '- don't recommend - divide 1024/59 add proportion of seconds (.289/sec)
secpwm = 17.36 * sec                      'divide 1024/59

'Panel output
io(pwo,d0,hourpwm)
io(pwo,d1,minpwm)
io(pwo,d2,secpwm)

'Daily NTP refresh at 2:00 AM
if ((hour=2) and (min=0) and (sec>0) and (sec<5) and (M="AM")) then
 timesetup(tz,DST)  'Need to figure out what is wrong with DST
 delay 5000
endif

gosub [udptimer]
wait

[timezone_update]
'Persist timezone information and UDPPort
write(DaylightSavings,str(DST))
write(TZ,str(timezone))

if DST = 1 then
 tz = timezone + 1
else
 tz = timezone
endif

timesetup(tz,DST)
delay 5000

'serialprintln "Timezone Updated"
'serialprintln "The Updated time is: "
'serialprintln time("hour:min")

cts = time("hour:min:sec")
uvsr = "<mark> Updated... </mark>"
updated = 1
returngui
wait

[udpport_update]
write(UdpPort,str(udpportval))
udpbegin udpportval
cts = time("hour:min:sec")
uvsr = "<mark> Updated... </mark>"
updated = 1
returngui
wait

[udptimer]
'Send UDP broadcast message out for current time every 30 seconds
 udptimer = udptimer + 1
 io(pwo,d4,1024-udptimer*273)     'vary d4 intensity to show clock operating, can comment out if desired
 if udptimer > 30 then
  if (M = "PM" and hour = 0) then hour = 12
  ct = str(hour)&":"&time("min:sec")&" "&M
  udpwrite broadcastaddr, 5001, ct
  udptimer = 0
 endif

'Check to see if Timezone or DST was updated
 if updated = 1 then
  updatetimer = updatetimer + 1
    if updatetimer > 6 then
        uvsr = "Running..."
        updated = 0
        updatetimer = 0
        returngui
    endif
 endif     
return





This weekend I'll be making an enclosure. It shall be displayed prominently in our living room, at least until my wife decides it needs to move...

Time for another beer, this one celebratory for first phase complete, with a video to prove it:
User avatar
By russm
#54207 May need to make a 4 meter version that has:
Hour and Minute
Temp and Humidity

I'll miss seconds but that combo is probably worthwhile. Could even have an LED that indicates whether the temp/humidity is indoor or outdoor as it reads over wifi from a remote sensor. Perhaps another two meters to show wind speed and direction (manometer and a weather vane).

OK, need to make the wood case for my current contraption first. :)