I'm starting version 3 of my clock project and not sure where to start.
March 11, 2025 8:39 PM   Subscribe

I'm considering upgrading a clock project I've made, but I'm not sure how to do what I want to do...

This is a short synopsis of what I've done so far.

I found this meter in a yard sale a few years back. At first, I just kept it on a shelf because I liked the look of it. Than I started seeing clocks made with analog gauges, and thought this meter would be a perfect candidate.

I had just received a Raspberry Pi Pico as a promo item, so I figured this would be a great mix.

I had done some programming before, so I dove into microPython stuff and came up with version 1. I relabeled the meter, printed a little case for the electronics, kludged it all together. The program was very simple, when I pressed a button, the clock was set to midnight. If there was a power outage, the clock drifted or for twice-a-year time changes, I just pressed the button at midnight. Typical slapped together simplicity, but it worked.

Then I had a power hit that knocked out the Pico. Looked it up and found that there was one with WiFi built-in for only one dollar more. Bought it, dove back into the books, and added enough code to have it log into my WiFi and get the time, either on Sunday at 3am, or whenever I pushed the button. Version 2, no problem, and it keeps good time.

But there is one problem. The code is hardwired for my router and password.

The clock works for me, but I won't live forever. I'd like to just put a simple instruction card on the back that says "Look for WiFi 'Galvanometer-Clock' and connect using your routers name and password"

So for version 3 I'd like to be able to connect to the clock, set the name and password of a WiFi access point, set the time zone, maybe other things. I've seen bunches of code examples that show how to use the Pico as a web server, but they all have the SSID and password hardwired.

I'd like to have the Pico sent out an SSID, so anyone could, via their phone, connect to the Pico, setup the SSID and password, so then it can go get the time.

I'm not sure what this would be called.
posted by Marky to Computers & Internet (10 answers total) 1 user marked this as a favorite
 
You want to get a DS2431 1024 bit 1 wire EEPROM in a TO92 3 pin package, so you can store the name and password of the wifi access point. There is a one wire library that you can use to talk to a DS18B20 that you can use to talk to the DS2431.

The hardware interface is simplicity itself: a single 4.7K pull-up resistor in addition to the 3 wire component, and you just wire it directly up to 3.3 volt out, GP28, and GND pins.
posted by the Real Dan at 8:56 PM on March 11


You can make the Pico an access point, and run a minimalistic website on it.

For _real_ inspiration look at Tasmota. It has quite a learning curve though
posted by wrm at 10:33 PM on March 11 [2 favorites]


A standard thing, though I admit my preferred platform of choice is the ESP so I don't know any useful Pi relevant answers. Searching for 'captive configuration portal WiFi' got me to this and I imagine some combination of that sort of term would get you more results. I'd be surprised if you couldn't find something off the shelf.

But I admit that answer is a bit of a pretext so I could tack in this bit. Can I suggest you set up NTP? Then the system clock will sync with a time server continuously, and you can rely on the system time to always be correct. If you set the timezone on your box it'll also fix itself for DST. On a Pi, likely installing the ntp server package from whatever distribution you're using will get you a default config that just works.
posted by How much is that froggie in the window at 10:38 PM on March 11 [1 favorite]


I'd recommend something like ESPHome, which (despite the name) isn't limited just to ESP8266/ESP32 chips. It's a whole platform for making little smart home devices. Among the many features it has are a built-in web server, a captive wifi portal, an NTP time source, and a way to write a tiny bit of Arduino-style C++ (lambdas). You could wire pretty much all of a networked clock up with not much YAML!

It's straightforward to get started with if you're comfortable with the command line. Tasmota is a pretty similar concept, I'm just not familiar with it because I've really enjoyed my small hacky projects with ESPHome.

The big caveat is that I don't know which Pico you have! If you have the original Pico W, it's supported. Folks are working on the Pico 2 W but it's not supported yet.
posted by Brassica oleracea at 11:55 PM on March 11 [1 favorite]


I'd like to have the Pico sent out an SSID, so anyone could, via their phone, connect to the Pico, setup the SSID and password, so then it can go get the time.

The more common way to configure a device like this is to let it start with a standard captive portal, either when it has no config data yet, can't connect to to any of the access points it detects, or on holding a button during startup, like HMITFITW suggests. That's just a minimal webserver with a fixed SSID and password printed on a sticker on the back. One connects to that, sets the SSID and credentials for the access point it should connect to, after which it reboots as a client to that AP.
posted by Stoneshop at 1:04 AM on March 12 [1 favorite]


Another way to go might be Raspberry Pi Zero W, and run a web server that stores the ssid/password on a microSD card. Cost would be $15 for the Pi and $5 for a micro SD card.

The downside of this is that it puts you in the world of Linux. The upside is that it puts you in the world of Linux.
posted by at at 5:45 AM on March 12 [2 favorites]


I would use ESPHome: there's enough of your desired features built-in to the base to probably make the rest of it straightforward.
posted by wenestvedt at 6:31 AM on March 12


What wrm said. Here's some sample code that looks pretty good. I haven't tried it, but I've read it.

I think you can set up an access point without a password, or just include the password in the SSID. After that, create the web page to obtain an SSID and password, save it in the DS2431, and then re-init the networking to network.WLAN.IF_STA, and fetch your time.

You probably don't need the DS2431 if you are willing to reset SSID and password each time the Pico W loses power.
posted by the Real Dan at 10:17 AM on March 12


Ah, as Stoneshop said - or if you want to change platforms (eh, I dunno, maybe) to ESP32/ESP8266, WiFiManager has been good to me.

ESPHome always sort of felt limiting to me, although that might just be because I'm coming at embedded devices from an Arduino-y "spodge random code together until it compiles" direction rather than the other way around.
posted by Kyol at 11:57 AM on March 12


These are typically called wifi managers, a subset of a captive portal. The Awesome MicroPython directory lists a few. Some claim to be generic, but they mostly seem to target ESP32. They might work without modification on a Raspberry Pi Pico W.
posted by scruss at 1:13 PM on March 12


« Older LFL   |   Looking for custom tapestry maker who uses... Newer »

You are not logged in, either login or create an account to post comments