Run ESP_UniClock on the NixieIN12v2 clock

Adds CLOCK_90 and the nixie595.ino driver: two 74HC595s on hardware
SPI (GPIO13/14, latch GPIO15), multiplexed from an IRAM-only timer1
ISR. Neon dots on P1; P2 is the decimal-point line on this board.

Also:
- NeoPixel on any ESP8266 pin via bit-bang (GPIO12), and take the pin
  back after SPI.begin() claimed it as MISO
- ArduinoOTA (USE_ARDUINO_OTA), with an OTA upload env in platformio.ini
- DST: EU end date (last Sunday of October) instead of the first Sunday
  of November, and recompute the time from the rules when DST is
  toggled instead of shifting it by 1 h
- forward declarations so PlatformIO's .ino conversion compiles
- FIRMWARE_SERVER can be overridden; empty for CLOCK_90

Verified on the clock: tubes, order, dots, LEDs, LDR, NTP time with DST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-10-25 21:23:10 +01:00
1 parent b347f1c63f
commit 0d3e878051
7 files changed
+304 -34

No files matched your search

+27 -21
View File
@@ -6,8 +6,9 @@ with ArduinoOTA and Home Assistant (MQTT) support.
## The device
- On the network at **10.1.1.97** (WiFi `dlink-iot`). Stock web UI on port 80, nothing else
open: no OTA, no API, no MQTT.
- On the network at **10.1.1.97** (WiFi `dlink-iot`). Since 2026-10-25 it runs ESP_UniClock
(`firmware/uniclock/`, CLOCK_90): web UI on port 80 (JSON at `/getConfiguration`,
`/getCurrentInfos`), ArduinoOTA on UDP 8266 (hostname `nixie-in12`, no password yet).
- Board: RetroModding (Konstantin Repnikov) "NixieIN12v2 HV2.0", stock firmware **SV1.3**
(©2020). ESP-12 (ESP8266, MAC 30:83:98:99:BF:DE, Espressif).
- **Powered by USB-C 5 V only** (no DC jack). Most likely the maker's "v2.0L lightweight
@@ -34,28 +35,29 @@ with ArduinoOTA and Home Assistant (MQTT) support.
## Pinout
From the 12 V v2 schematic (`docs/schematic_v2_12V.jpg`), checked against the stock firmware
by disassembly (`docs/stock-firmware-pins.md`, tools in `tools/`). "Binary" = confirmed in
the stock SV1.3 code; it has not yet been tested on the hardware.
by disassembly (`docs/stock-firmware-pins.md`, tools in `tools/`). "Hardware" = also works
on the clock with UniClock; "Binary" = only confirmed in the stock SV1.3 code.
| Function | GPIO | Source |
|---|---|---|
| 74HC595 DATA / CLOCK (OE tied to GND) | 13 / 14 = HSPI MOSI / SCK (hardware SPI, MSB first) | Binary |
| 74HC595 LATCH | 15, plain `digitalWrite` (has 1k pull-down) | Binary |
| WS2812 data | 12 (NeoPixel bit-bang, GRB 800 kHz; stock assumes 12 LEDs, 8 fitted) | Binary |
| Photoresistor (LDR, 10k to GND) | ADC (A0) | Binary |
| 74HC595 DATA / CLOCK (OE tied to GND) | 13 / 14 = HSPI MOSI / SCK (hardware SPI, MSB first) | Hardware |
| 74HC595 LATCH | 15, plain `digitalWrite` (has 1k pull-down) | Hardware |
| WS2812 data | 12 (NeoPixel bit-bang, GRB 800 kHz; 8 fitted, stock assumes 12). `SPI.begin()` turns GPIO12 into MISO: set it back to OUTPUT afterwards | Hardware |
| Photoresistor (LDR, 10k to GND) | ADC (A0) | Hardware |
| BTN1 / BTN2 (not fitted) | 0 / 2, INPUT_PULLUP. Stock: GPIO0 is a button, GPIO2 a motion/presence input that wakes the display | Binary |
| DFPlayer Mini (stock feature) | UART0: GPIO1 TX / GPIO3 RX, 9600 Bd | Binary |
| DS3231M RTC SDA / SCL | 4 / 5. **Stock firmware has no I2C code** (NTP only); if fitted, unknown | Schematic only |
| DS3231M RTC SDA / SCL | 4 / 5: **no I2C device answers** (UniClock scan), so no RTC on this board; NTP only | Hardware |
Two chained 74HC595s make one 16-bit word, all bits active-high (confirmed from the binary;
the high byte is sent first and goes to U2):
- U1 QA..QH = cathodes 0..7 (bits 0..7), U2 QA = cathode 8 (bit 8), QB = cathode 9 (bit 9)
(via 2x ULN2003, shared by all tubes)
- U2 QC = P1 (neon dot 1, bit 10), QD..QG = anodes A1..A4 (bits 11..14, MMBTA42/92), QH = P2
(bit 15; neon dot 2, and the decimal point if jumper JP2 is closed)
- U2 QC = P1 (bit 10) drives **both** IN-3 neon dots. QD..QG = anodes A1..A4 (bits 11..14,
MMBTA42/92). QH = P2 (bit 15) drives the IN-12B **decimal points** on this board (JP2 closed),
not a neon.
- The display is multiplexed: one anode on at a time. **A1 = leftmost tube (hour tens),
A4 = rightmost (minute ones)**, from the stock digit order. Stock lights P1/P2 in only one
multiplex slot.
A4 = rightmost (minute ones)** (verified on the tubes). The dots are lit in the minute-tens
slot only, as on stock.
## Programming header
@@ -65,7 +67,12 @@ Wiring: GND-GND, adapter TXD -> clock RXD, adapter RXD -> clock TXD, adapter 3.3
connected (the clock is powered from its own USB-C). No auto-reset: to enter flash mode, hold
GPIO0 to GND, tap RST to GND, then release GPIO0.
- esptool is installed for the user (`python -m esptool`, v5.6.0).
- esptool is installed for the user (`python -m esptool`, v5.6.0). After `--after no-reset`
the stub keeps running at the new baud rate and the next esptool call can't connect: do
everything in one call, or re-enter flash mode.
- Normal updates go over WiFi: `pio run -e nixie_in12_ota -t upload` in `firmware/uniclock/`.
ArduinoOTA does not answer after the clock switched from AP mode to WiFi without a reboot
(first setup); a power cycle fixes it.
- `firmware/stock/` holds the stock flash dump. **Never overwrite or delete it**; it is the
only way back to SV1.3 (`write-flash 0 <dump>`). Dumps are gitignored because the flash
holds the WiFi password; never commit them.
@@ -79,10 +86,9 @@ GPIO0 to GND, tap RST to GND, then release GPIO0.
## Plan
1. Dump and inspect the stock firmware (version strings, pins if possible).
2. Write a test sketch that steps through the 16 shift-register bits, to verify the pinout
and the tube order.
3. Add a 74HC595-multiplex driver + CLOCK config to ESP_UniClock, plus ArduinoOTA and
Home Assistant controls (display on/off, brightness, LEDs); its stock MQTT only
publishes sensors.
4. Work continues in VS Code (PlatformIO).
1. Done: dump and inspect the stock firmware.
2. Skipped (the disassembly was enough): bit-stepping test sketch.
3. Done: 74HC595-multiplex driver (`nixie595.ino`) + CLOCK_90 in ESP_UniClock, ArduinoOTA,
EU DST fix. Runs on the clock.
4. Next: Home Assistant controls over MQTT (display on/off, brightness, LEDs; upstream MQTT
only publishes sensors), OTA password via `secrets.h`.