Top
Best
New

Posted by tokyobreakfast 6 hours ago

Converting a $3.88 analog clock from Walmart into a ESP8266-based Wi-Fi clock(github.com)
341 points | 114 comments
teraflop 5 hours ago|
Cool project!

The most interesting part, IMO, is the "SRAM with EEPROM backup" chip. It allows you to persistently save the clock hands' positions every time they're moved, without burning through the limited write endurance of a plain old EEPROM. And it costs less than $1 in single quantities. That's a useful product to know about.

ssl-3 4 hours ago||
That's really neat. TIL.

So the way this works seems to be this: It's an SRAM and an EEPROM in one little package along with a controller that talks with each, with a little capacitor (this clock uses 4.7uf) placed nearby.

The SRAM part does all of the normal SRAM stuff: It doesn't wear out from reading/writing, and as long as it has power it retains the data it holds.

The EEPROM does all the normal EEPROM stuff: It stores data forever (on the timescale of an individual human, anyway), but has somewhat-limited write cycles.

The controller: When it detects a low voltage, it goes "oh shit!" and immediately dumps the contents of the SRAM into EEPROM. This saves on EEPROM write cycles: If there are no power events, the EEPROM is never written at all.

Meanwhile, the capacitor: It provides the power for the chip to perform this EEPROM write when an "oh shit!" event occurs.

When power comes back, the EEPROM's data is copied back to SRAM.

---

Downsides? This 47L04 only holds 4 kilobits. Upsides? For hobbyist projects and limited production runs, spending $1 to solve a problem is ~nothing. :)

bonsai_spool 2 hours ago||
What's the purpose of using an LLM to write a comment here?
ssl-3 2 hours ago|||
"Hey, someone on the Internet used decent diction! Obviously, this means I must accuse them of being a bot!"

(Hey Dang. Can we get a ban button? There's a few people here that are impossible to conduct rational discourse with. My sanity would improve if they were simply gone from my view.)

bonsai_spool 1 hour ago|||
You've edited the response since you posted it. I think there's a difference between diction and the standard output of ChatGPT et al.
ssl-3 1 hour ago||
I'd like to say that I'm sorry that you feel that way, but frankly: My ability to feel anything empathetic about you dwindles by the moment.

Please stop fucking with people in this way. It's callous, unnecessary, and antithetical to the greater good. We don't come here to get accused of things.

(edit: Today, I learned about the existence of a chip that does a clever thing. That made me curious: After all, I've been passively wondering for -decades- about how electronic things remember their previous state without power, and without hammering an EEPROM.

I could have learned more about this at any time over the years, but I just never bothered with doing so.

And today, it was right in front of my face -- with a part number! That gave me a very easy place to start, so I started.

I read up on it a bit using the datasheet and a whitepaper. I learned some about how it does that clever thing, and I wrote a few sentences about this new-to-me stuff in a way that I felt would be approachable and appreciated by this particular audience.

That's what we're here for -- to be curious, to share ideas, and to learn stuff from others. Not for fucking with people.)

ninalanyon 2 hours ago|||
You could create a browser user script to do it locally.
ssl-3 1 hour ago||
That's not a terrible idea.

An extra UI element or two should be enough. Maybe with sticky options for collapse-by-default or hide-by-default at the top of each HN comment section.

And the list of usernames can be stored and edited in the purveyor's HN bio (in plain text, like a monster), so that it works automatically across devices.

Dachande663 2 hours ago|||
Upvoted because this stinks to high hell of an LLM response. Half the GPs comments seem to be in a similar vein. It’s such a shame but you can’t fight the trolls so don’t take it to heart.
sowbug 5 hours ago|||
I'm not sure if this is the same technology, but regardless it's also cool: https://www.adafruit.com/product/1897
mftrhu 4 hours ago||
Not quite - the chip the article refers to is the 47L04 [0], which is "just" NVSRAM built out of a RAM + EEPROM. I do agree on FeRAM being cool, though - I have a few I2C chips en route, and I can't wait to get my hands on them.

[0] https://www.microchip.com/en-us/product/47L04

summa_tech 2 hours ago|||
You could also consider MRAM. Which is available in larger sizes - up to 4 Mbit on SPI bus in the MR20H40, and 128 Mbit in EM128LXQ (but it gets unreasonably expensive when this big).

https://www.everspin.com/family/mr20h40?npath=259

qwertox 3 hours ago|||
Thanks to both of you for bringing FRAM onto my radar!
monocasa 2 hours ago||
I do like the frams too for similar use cases.

Particularly I like that I can get those large enough to stick a ring buffer from debug out on them as well and get crash logs from embedded systems despite the debug uart not being tethered to a dev machine.

riskable 5 hours ago||
I want to see someone convert one of those cheap projection clocks like this: https://www.homedepot.com/p/La-Crosse-Technology-5-in-Color-...

The red projection is just the right brightness (at night) but it sucks that it's not wifi-enabled so you can't just get it to NTP sync (or hook up a GPS receiver). The projector part of the clock is a separate device that's attached to it via a ribbon cable. I would reverse engineer it myself but I haven't got the time.

Ideally, I'd want a matrix of LEDs projected on to the ceiling so I could get more info than just the time. Such clocks exist but they're super duper expensive! Example: https://buyfrixos.com/

stavros 5 hours ago||
If you're looking for something low brightness, I made one: https://www.stavros.io/posts/i-made-another-little-bedside-c...
ElevenLathe 5 hours ago|||
The one you linked claims to have "Atomic Time" which usually means syncing by radio from WWV/WWVB. I have several cheap wallclocks like this (though none with a projector) and they are always accurate with no noticeable drift AFAICT. Have you tried that particular one and found its accuracy wanting? I think, in principle at least, there should be less jitter in this method than using NTP over a computer network.
Animats 57 minutes ago|||
Right. WWVB clocks running off the 60KHz pretty much solve the clock problem in the US. All my clocks at home are basic LaCrosse analog clocks. They have the internal sensors needed to tell when each hand is straight up, so they can set themselves without user input. On power up, they step until the hands are straight up, then sync when they get an update. You have to set the time zone with a switch when installing. Only the four US time zones are available. Battery life is 1-2 years, which is pretty good for a device with a radio.

There are UK and Japan clocks that work similarly, but use national time sources. There are G-Shock watches which synchronize from multiple sources. While running on solar power. Those keep accurate time with no maintenance. That's an impressive achievement.

js2 39 minutes ago||
> WWVB clocks running off the 60KHz pretty much solve the clock problem in the US.

YMMV depending upon location. I've never gotten a WWVB clock to work in North Carolina. If you're lucky, the signal works on the east coast at night in an outdoor location:

https://tf.nist.gov/tf-cgi/wwvbmonitor_e.cgi

I've never been lucky indoors and never had a WWVB clock synchronize successfully overnight.

They also don't transition DST automatically, so you're pulling them off the wall twice a year unless you're in one of the rare US locations that don't adhere to the DST silliness.

zymhan 2 minutes ago||
I'm fairly certain the radio time signal has a mechanism to convey daylight savings, I've had alarm clocks that managed DST without any input.

> The DST status bits indicate United States daylight saving time rules.

https://en.wikipedia.org/wiki/WWVB

cptskippy 2 hours ago|||
With a resolution of one second, I think most people would be hard pressed to distinguish between NTP and WWV/WWVB time keeping devices.
lostlogin 5 hours ago|||
Undermining the spirit of HN: By the time you’ve spent a few hours hacking away and bought any parts, that price is probably not too bad.
stavros 5 hours ago||
That's assuming you don't like hacking and would pay to not have to do it, which is generally not the case around here.
lostlogin 5 hours ago||
I’m think you can go further than that.

Days spent modifying cheap electronics is absolutely encouraged.

hackingonempty 4 hours ago|||
Buy the premade thing and hack something new.
seg_lol 4 hours ago|||
Cheap electronics are just the feed stock, the basis function for your new creation. Why start with raw matter when you can get fully formed matter for less.
btheconqueror 2 hours ago|||
Some clocks also update over radio. Oregon Scientific used to make the best bedside atomic clock ever. Super simple, with the projector, was an atomic clock that updated automatically via radio and had a pleasant, crescendo alarm that would start off nice and get more aggressive. They don't make it anymore :/
mmsimanga 5 hours ago|||
+1 I have a couple of digital.clocks from Temu. They look nice but cannot keep the correct time. They slowly edge ahead and in a month they are about a minute ahead. It is annoying having to correct the clock and would be great if they time from WiFi connected source.
alnwlsn 4 hours ago||
Depending on how dark your room is you might get by with an ordinary but bright LCD screen and a camera lens. There's a pretty common 240x240px, 1-inch square TFT display on amazon or other usual places you might start with.
tanvach 30 minutes ago||
Related - we have an atomic Seiko wall clock expecting to have the time automatically adjusted by the WWVB LF atomic clock broadcast. Turns out, the signal is very weak where we now live. Manually setting the time on these atomic clocks is a HUGE pain (beware!).

Turns out it's possible to emulate the atomic clock signal quite easily with a Raspberry Pi, or in my case I put together Arduino code that can emulate atomic clock broadcasts from around the world using an ESP32 module using NTP servers: https://github.com/tanvach/clocksync

The history of these atomic clock broadcast signals and their differences in different countries is quite fascinating.

sowbug 5 hours ago||
If you like this but don't want to get your hands as dirty, have a look at the Crazy Clock: https://www.tindie.com/products/nsayer/crazy-clock/

I got one for my daughter. The erratic ticking eventually became a distraction when she was studying, so we have retired it for now. But we got a lot of amusement out of it.

avidiax 5 hours ago|
> Early clock - keeps time anywhere between 0 and 10 minutes fast. For those who like to set their watch ahead to avoid being late. This clock keeps you from trying to "compensate," because you never know how early it is at the moment.

That's pretty genius for many ADHD-type folks. Only problem is a modern household has many clocks in view, so you'd need to commit to just not setting them.

javawizard 5 hours ago|||
Oh now that would be a fun version 2 challenge: have all the clocks in one household synchronize such that they're all early by the same amount at any given time.

Easy enough for wifi enabled ones: a UDP broadcast to discover other clocks on the network, then sync how you will.

For non-wifi-enabled clocks, perhaps something like a CH572 would do the trick: a $0.20 RISC-V microcontroller with BLE support that all the clocks in the same vicinity could use to talk to each other.

You could really mess with your neighbors if they had the same clocks and you were within range...

seg_lol 4 hours ago||
You don't already do this with the NTP servers under your control?
javawizard 3 hours ago||
If I had any NTP servers under my control, I probably would :)
password4321 5 hours ago|||
Yes I'd have to convince Apple to play along on the iPhone and watch.
freedomben 5 hours ago||
Hell yeah, this is some badass hackery, and the type of stuff I love seeing on HN. In the last decade or so as more and more stuff becomes locked down and hacker unfriendly, I've found myself longing for simple things I can hack on. If I ever get to a point where I don't have to work for a living, one of the things I'd like to do is build everything from little gadgets up to major appliances that are simple, reliable, and hackable for people who want to. It pains me that my appliances have full computers driving them but I can't get access to them. Kudos for this awesome work and phenomenal write-up!
timonoko 4 hours ago||
On that note: Converting €0 scrap into €400 video editing deck. https://www.youtube.com/shorts/KlWYC6mzVkQ

https://github.com/timonoko/Jogwheel

kfarr 3 hours ago|
What a great idea. Legacy VCR controls upcycled for digital control! There's a lot of those old decks and LANC deck controllers lying around...
timonoko 3 hours ago||
This is a hard problem. Solvable only with try and error.

Those signals are just weird mess of coils, switches and resistors.

ESP32 clock speed may also be a contributing factor.

staplung 3 hours ago||
This is cool but it seems like it would be liable to drift. I.e. it "knows" the correct time but doesn't have any way to figure out that it's been driving the movement fast or slow by some number of milliseconds. Eventually, that will pile up to the point that it's not any better than running the thing off of batteries.

As the author points out, the cheap quartz mechanism has no way of reporting the position of the hands (other than the hands themselves) and that you have to set the PULSETIME constant by the right number of milliseconds. If you're off by even a millisecond, that's going to accumulate quick enough that it would make a difference over even a single day, wouldn't it?

EDIT: as some have pointed out, the Lavet stepper theoretically accounts for this in that it steps exactly one tick after so many oscillations. That number of oscillations does not change so that's all you need to get right.

However, that basically just kicks the can down the road a bit in that if each step is not exactly 1/60th of a circle or bits wear down or get sticky or you have analog noise in there you will presumably still have a source of biased drift that you won't be able to detect. But maybe those affects are small enough that they don't matter for a wall clock.

picture 3 hours ago||
The escapement is "synchronous" in that the motion is controlled by the number of pulses applied to the motor over time rather than the duration/width of each pulse. The pulsetime constant is only to accommodate mechanical/analog differences with the driving circuitry, from what I understand. https://en.wikipedia.org/wiki/Lavet-type_stepping_motor
lelandbatey 2 hours ago||
That's fascinating; the Lavet-type stepping motor acts as an escapement all on it's own by being a very simple stepper motor, so you don't end up needing a miniature version of a classic mechanical escapement, which is what I'd always imagined in my head when thinking about how cheap quartz wall clocks worked.

https://en.wikipedia.org/wiki/Escapement

bazodedo 3 hours ago||
The pulsetime is just to advance the clockwork one step, and is kept fixed, the advancement driven by the mechanism is discrete. As long as you keep track of the count, you wont accumulate drift. The adjustment is to get that stepping working, if it doesnt miss a step, youre good.
mlhpdx 3 hours ago||
In a perfect world, yes. But mechanisms aren’t perfect and it’s entirely possible if not likely that steps will be missed as friction increases over time and things wear.

I’m not saying these things matter much in this context.

The clock will still be far more accurate than purely mechanical version. And, re-synchronizing it is as trivial as turning the knob, just as you would for the all mechanical mechanism.

KaiserPro 2 hours ago||
its a fairly reliably stepper motor system. You're right it will degrade over time, you'd be surprised how many steps it can do before it degrades.
KaiserPro 2 hours ago||
If your budget is a bit more, and you want to hear a massive clunk every 30 seconds rather than a soft tick and you want to drive 2' (60cm) hands, then you might want this: https://waitingtrain.blogspot.com/2015/05/a-large-gents-turr...

The smaller ones look the same but are less beefy.

I used one to make this clock:

https://www.secretbatcave.co.uk/projects/electromechanical-c...

Which instead of using a well disciplined time source, uses a tuning fork and 74xx logic to drive it

montroser 4 hours ago||
What I really want is one of these powered by gps. The time already comes for free in the signal, and from your location you can derive the time zone. That way DST is accounted for automatically, but you don't have to set up and rely on wifi. This would be truly zero-config and always correct.
ssl-3 3 hours ago||
GPS isn't too hard, either.

The receivers are inexpensive ($5-$10 for the kind of accuracy that's useful here) and it's not hard to parse the NMEA strings and PPS they output into a spooky-accurate internal clock. It only takes a few connections and an antenna to integrate GPS into an MCU like an ESP (or an SBC like a Raspberry Pi or a whatever).

Like, really: The hardware is ridiculously easy.

The only difficult part is the code. But as we can see from this posting, the clock-driving bits are already written and are available for use.

Just graft in the GPS parts instead of the NTP parts, add your DST/location rules if you really must (hint: that part is harder than it sounds), and send it.

(And if the code still seems arduous, then remember: This is the kind of work that a reasonably-focused person who is armed with a decent bot can put together over a cup of coffee or two, even if they don't speak C. It may be popular here to poo-poo the bot here, but it's completely OK to get some help. Don't let pride get in the way of having fun, learning things, and building neat stuff.

The tailor doesn't lament the invention of the cotton gin.)

womod 4 hours ago|||
There's quite a few clocks available that get their time over the air from the NIST WWVB radio station[0]. They usually have a little switch on the back if your area does/doesn't observe daylight savings.

[0] - https://www.nist.gov/pml/time-and-frequency-division/time-di...

IncreasePosts 4 hours ago||
You would still need some kind of configuration because the start of DST can change year to year, and this is not accounted for in the time signal from GPS
montroser 3 hours ago||
Good point that DST dates can technically change -- but in practice it doesn't really change on a year-to-year basis. The current law establishing the start and end dates in the US has been in effect unchanged for the last ~20 years.
debbiedowner 5 hours ago|
How different is this to something you can buy like: https://www.amazon.com/ihreesy-Movement-Mechanism-Silent-Rep... ?
TechSquidTV 5 hours ago||
Well I notice that one is $36
xandrius 1 hour ago||
One is hacked and the other one is bought?
More comments...