--- title: "Etlas: e-paper dashboard" date: 2024-09-05 layout: post project: true thumbnail: thumb_sm.jpg --- 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
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. gui_plot_stocks() triggers WDT. vTaskDelay() prevents that. Stepped graph was easier to code for the bit-packed framebuffer (not enough memory for much else), but it's messy--too messy. Note to self: Refactor gui_plot_stocks(). Bresenham’s line algorithm perhaps? News: Channel NewsAsia RSS. MCU parses XML directly. Character glyphs stored as bitmaps in sprites directory. 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) { int t; static const uint16_t delta = 1; for (t = 0; t < timeout; t += delta) { ets_delay_us(delta); if (gpio_get_level(DHT_PIN) == state) return t; } return 0; } static inline int dht_get_raw_data(unsigned char buf[BUFLEN]) { int rc; unsigned char i, pwl, pwh; gpio_set_level(DHT_PIN, 0); ets_delay_us(1100); gpio_set_level(DHT_PIN, 1); if (!dht_await_pin_state(0, 40)) { rc = 1; xQueueSend(dht_evt_queue, &rc, (TickType_t) 0); return 0; } if (!dht_await_pin_state(1, 80)) { rc = 2; xQueueSend(dht_evt_queue, &rc, (TickType_t) 0); return 0; } if (!dht_await_pin_state(0, 80)) { rc = 3; xQueueSend(dht_evt_queue, &rc, (TickType_t) 0); return 0; } for (i = 0; i < BUFLEN; i++) { if (!(pwl = dht_await_pin_state(1, 50))) { rc = 4; xQueueSend(dht_evt_queue, &rc, (TickType_t) 0); return 0; } if (!(pwh = dht_await_pin_state(0, 70))) { rc = 5; xQueueSend(dht_evt_queue, &rc, (TickType_t) 0); return 0; } buf[i] = pwh > pwl; } return 1; } ``` Ported from ESP8266. 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? Once running, it runs: August 2024 - December 2025. Commit: [a92c86a](https://git.asciimx.com/etlas/commit/?id=a92c86ac1592c2137d3d1fec1668eacc2d0ca581)