From 260cb31975911a75498e9ce85efd432832b4c25e Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Sat, 27 Dec 2025 21:54:08 +0800 Subject: Etlas. --- _log/etlas.md | 66 +++++++++++++++++++++++++---------------------------------- 1 file changed, 28 insertions(+), 38 deletions(-) (limited to '_log') diff --git a/_log/etlas.md b/_log/etlas.md index c274401..cc45ea4 100644 --- a/_log/etlas.md +++ b/_log/etlas.md @@ -6,41 +6,34 @@ project: true thumbnail: thumb_sm.jpg --- -Etlas is a news, stock market, and weather tracker powered by an ESP32 NodeMCU -D1, featuring a 7.5-inch Waveshare e-paper display and a -DHT22 sensor module. +Repurposed [e-reader prototype](../e-reader/) into something for regular use. +News, stocks, weather dashboard. ESP32 NodeMCU D1 + 7.5" Waveshare e-paper + +DHT22 sensor. + + +
front back
front
-The top-left panel shows two weeks of end-of-day prices—the maximum the ESP32's -SRAM can hold—from the Polygon.io API. The price feed is relayed through a -FastCGI-wrapped Flask app hosted on a VPS. This lets me configure stock symbols -in its application settings. The app cycles through them as requests come in -from the ESP32. Running the Flask app as a FastCGI process while exposing it -via httpd with htpasswd authentication keeps the server code simple and secure. +Stocks: Two weeks EOD prices from Polygon.io (max SRAM holds). Flask app on VPS +relays feed, lets me swap symbols via config. FastCGI + httpd + htpasswd. -The following diagram outlines the Etlas's overall system architecture. +gui_plot_stocks() is CPU heavy and triggers the WDT. vTaskDelay() prevents +that. Stepped graph easier to code for the bit-packed framebuffer (especially +under current memory constraints), but its messy--too messy. -![architecture](etlas_arch.png) +Note to self: Refactor gui_plot_stocks(). Bresenham’s Line Algorithm perhaps? -The more prominent panel on the right of the display shows local and world news -from Channel NewsAsia. The MCU downloads and parses XML data from the RSS feed -directly before rendering it to the display. The character glyphs used are -stored as bitmaps in the sprites directory. I skipped the proxy for news to -avoid writing more server code, but in hindsight it limits the feeds Etlas can -handle. I will fix this in a future version. +News: Channel NewsAsia RSS. MCU parses XML directly. Character glyphs stored as +bitmaps in sprites directory. -The middle and bottom right panels display the temperature and relative -humidity from the DHT22 sensor. The DHT22 uses pulse-width modulation to -transmit data to the host. The 26µs, 50µs, and 70µs pulses are too fast for the -ESP32 to measure reliably with standard APIs. Instead, the driver compares -relative pulse widths to differentiate zeros from ones: +Weather: DHT22 via PWM. 26µs/50µs/70µs pulses too fast for standard ESP32 APIs. +Compare relative pulse widths: ``` static inline int dht_await_pin_state(int state, int timeout) @@ -51,12 +44,12 @@ static inline int dht_await_pin_state(int state, int timeout) for (t = 0; t < timeout; t += delta) { ets_delay_us(delta); if (gpio_get_level(DHT_PIN) == state) - return t; + return t; } return 0; } -static inline int dht_get_raw_data(unsigned char buf[DHT_DATA_LEN]) +static inline int dht_get_raw_data(unsigned char buf[BUFLEN]) { int rc; unsigned char i, pwl, pwh; @@ -81,7 +74,7 @@ static inline int dht_get_raw_data(unsigned char buf[DHT_DATA_LEN]) return 0; } - for (i = 0; i < DHT_DATA_LEN; i++) { + for (i = 0; i < BUFLEN; i++) { if (!(pwl = dht_await_pin_state(1, 50))) { rc = 4; xQueueSend(dht_evt_queue, &rc, (TickType_t) 0); @@ -98,18 +91,15 @@ static inline int dht_get_raw_data(unsigned char buf[DHT_DATA_LEN]) } ``` -I ported this implementation from ESP8266 -to ESP32—all credit for the algorithm belongs to them. +Ported from ESP8266. -Etlas is a networked embedded system. All acquisition, processing, and -rendering of data are performed on the ESP32's 160MHz microprocessor using less -than 512KB of SRAM. The embedded software that makes this possible is written -in C using ESP-IDF v5.2.1. The e-paper display driver is derived from Waveshare -examples for Arduino and STM32 -platforms. +After flashing new versions, display would stop responding. Didn't observe this +with e-reader. Issue occurs spontaneously. Couldn't find root cause. Making a +change like adding a comment or tweaking delay in refresh() (then changing +back) fixed it. Noisy electrical connections? -Etlas has been running reliably for over a year since August 2024. +Once running, it runs: August 2024 - December 2025. -Files: [source.tar.gz](source.tar.gz) +Commit: +[a92c86a](https://git.asciimx.com/etlas/commit/?id=a92c86ac1592c2137d3d1fec1668eacc2d0ca581) -- cgit v1.2.3