diff options
| -rw-r--r-- | _log/etlas.md | 70 |
1 files changed, 26 insertions, 44 deletions
diff --git a/_log/etlas.md b/_log/etlas.md index 1d2697f..9fd5ded 100644 --- a/_log/etlas.md +++ b/_log/etlas.md @@ -1,14 +1,13 @@ --- -title: Etlas +title: Repurposed the e-reader into a news tracker date: 2024-09-05 layout: post project: true thumbnail: thumb_sm.jpg --- -Repurposed [e-reader](../e-reader/) into something for regular use. News, -stocks, weather dashboard. ESP32 NodeMCU D1 + 7.5" Waveshare e-paper + DHT22 -sensor. +Repurposed the [e-reader](../e-reader/) for regular use as a news, stocks, and +weather dashboard. <table style="border: none;"> <tr style="border: none;"> @@ -20,21 +19,14 @@ sensor. </tr> </table> -Stocks: Two weeks EOD data (max possible) from Polygon.io. Flask app on VPS -manages watchlist, relays feed. Backend: httpd + htpasswd + slowcgi + Flask. +Swapped out the ESP-32-WROOM for an ESP32 NodeMCU D1—smaller, better form +factor. Connected a DHT22 sensor for temperature and humidity data. -gui_plot_stocks() draws stepped graph. Was easier to implement, but the code is -hideous—vTaskDelay() needed to prevent watchdog timer from triggering. - -NOTE: Bresenham’s? - -News: Channel NewsAsia RSS. MCU parses feed. Didn't plan to have a backend at -the time. Now that I have one for stocks, should relay feed for flexibility. - -Weather: DHT22 single-wire protocol. 26µs/50µs/70µs pulses are too fast for -standard ESP32 APIs. Bit-banged relative pulse widths (ported from <a +Weather: 26µs/50µs/70µs pulses from the DHT22's single-wire protocol are too +fast for ESP32 standard APIs. Ported <a href="https://github.com/Fonger/ESP8266-RTOS-DHT" class="external" -target="_blank" rel="noopener noreferrer">ESP8266</a>): +target="_blank" rel="noopener noreferrer">this</a> clever bit-banging from +ESP8266 to ESP32: ``` static inline int dht_await_pin_state(int state, int timeout) @@ -52,28 +44,7 @@ static inline int dht_await_pin_state(int state, int timeout) 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; - } + /* init code and preamble */ for (i = 0; i < BUFLEN; i++) { if (!(pwl = dht_await_pin_state(1, 50))) { @@ -92,12 +63,23 @@ static inline int dht_get_raw_data(unsigned char buf[BUFLEN]) } ``` -epd_init() stalls intermittently on first refresh() after flash. Toggling delay -values in refresh() resolves it. If the first refresh succeeds, system remains -stable. Root cause unknown—suspect noisy supply due to powering display via -MCU. +Stocks: Obtained two weeks EOD data from Polygon.io—maximum possible with 512 +KB RAM. Deployed a simple Flask API on VPS to manage the watchlist and relay +the feed. Wrapped the API in FastCGI and exposed it through chroot-ed +htpasswd + slowcgi + httpd—battle-tested OpenBSD base-system tools. + +Rolled my own stepped graph for simplicity, but the code is hideous. Needed +vTaskDelay() to prevent the watchdog timer from triggering. Will look into +Bresenham’s in a future revision. + +News: Used Channel NewsAsia RSS feed for news. Hand-coded the XML parsing in +C—no Flask backend at the time. Now that I have one for stocks, will move the +feed through the Flask backend in the next revision. -Uptime: August 2024 - February 2026 +epd_init() stalled intermittently on first refresh() after flash. Toggling +delay values in refresh() resolved it. If the first refresh succeeded, system +remained stable. Could not find the root cause. Suspect noisy supply due to +powering display via MCU. Commit: <a href="https://git.asciimx.com/etlas/commit/?id=a92c86ac1592c2137d3d1fec1668eacc2d0ca581" |
