summaryrefslogtreecommitdiffstats
path: root/_site/projects
diff options
context:
space:
mode:
Diffstat (limited to '_site/projects')
-rw-r--r--_site/projects/etlas/index.html78
1 files changed, 56 insertions, 22 deletions
diff --git a/_site/projects/etlas/index.html b/_site/projects/etlas/index.html
index f8f539f..6b2906b 100644
--- a/_site/projects/etlas/index.html
+++ b/_site/projects/etlas/index.html
@@ -44,9 +44,7 @@
<h2 class="center" id="title">ETLAS: E-PAPER DASHBOARD</h2>
<h6 class="center">05 SEPTEMBER 2024</h5>
<br>
- <div class="twocol justify"><p>Etlas is a news, stock market, and weather tracker powered by an ESP32 NodeMCU
-D1, featuring a 7.5-inch <a href="https://www.waveshare.com/" class="external" target="_blank" rel="noopener noreferrer">Waveshare</a> e-paper display and a
-DHT22 sensor module.</p>
+ <div class="twocol justify"><p>Etlas is a weather, news, and stock price tracking system.</p>
<table style="border: none;">
<tr style="border: none;">
@@ -55,34 +53,70 @@ DHT22 sensor module.</p>
</tr>
</table>
-<p>The top left panel displays the end-of-day stock prices from the <a href="https://polygon.io/" class="external" target="_blank" rel="noopener noreferrer">Polygon.io</a> API, relayed through my own
-FastCGI-wrapped Flask app hosted on a VPS. The stock symbols can be configured
-through the Flask app’s application settings. The server.fcgi script enclosed
-in the tarball at the end of the page contains the Flask app.</p>
+<h2 id="acknowledgements">Acknowledgements</h2>
-<p>The following diagram outlines this system architecture.</p>
+<p>The e-paper display driver in the epd.c file of the project is derived from <a href="https://github.com/waveshareteam/e-Paper" class="external" target="_blank" rel="noopener noreferrer">Waveshare examples</a> for Arduino
+and STM32 platforms.</p>
-<p><img src="etlas_arch.png" alt="architecture" /></p>
+<p>The exceptionally elegant algorithm in the file dht.c, which reads DHT22 sensor
+data by comparing consecutive pulses, I ported directly from <a href="https://github.com/Fonger/ESP8266-RTOS-DHT" class="external" target="_blank" rel="noopener noreferrer">this</a> implementation for ESP8266
+modules to my ESP32. All credit for the algorithm belongs to them.</p>
+
+<h2 id="overview">Overview</h2>
-<p>Unlike my <a href="/projects/e-reader">e-reader</a>, which worked with raster images,
-Etlas downloads time series data as CSV and computes the price curves on the
-ESP32.</p>
+<p>Etlas comprises an embedded system featuring an ESP32 NodeMCU D1
+microcontroller, a 7.5″ <a href="https://www.waveshare.com/" class="external" target="_blank" rel="noopener noreferrer">Waveshare</a> e-paper display, a
+DHT22 weather sensor, and a server backend consisting of a FastCGI-wrapped
+Flask app. The following diagram outlines this system architecture.</p>
+
+<p><img src="etlas_arch.png" alt="architecture" /></p>
-<p>The more prominent panel on the right of the e-paper display shows local
-(Singapore) and world news from the <a href="https://www.channelnewsasia.com/" class="external" target="_blank" rel="noopener noreferrer">Channel News Asia</a>
-RSS feed. The MCU downloads and parses XML data from the RSS feed directly
-before rendering it to the display. Although I did it this way to avoid writing
-server code, it limits the feeds from which Etlas can receive data. In a future
-version, I will relay the RSS feed through a server (like the stock prices) to
-make it more flexible.</p>
+<p>The embedded application, written in C with the help of the ESP-IDF v5.2.1,
+connects to a (2.4GHz) WiFi network at startup and obtains time from an NTP
+server. It then composites and updates an internal pixel buffer using data
+acquired from various data sources and renders to the screen by writing to its
+Serial Peripheral Interface.</p>
+
+<h2 id="price-curves">Price curves</h2>
+
+<p>On the e-paper display, the top-left panel displays end-of-day price curves
+over two weeks from the <a href="https://polygon.io/" class="external" target="_blank" rel="noopener noreferrer">Polygon.io</a> API. The
+microcontroller’s 512KB SRAM limits the price curves to two weeks. Instead of
+using raster images for complex graphics—like e-paper projects often do—Etlas
+computes the price curves from CSV data on the fly using the ESP32’s 160MHz
+microprocessor. To avoid the overhead of floating-point arithmetic, all
+computations are performed on integers. The <code class="language-plaintext highlighter-rouge">gui_plot_stocks()</code> function in the
+gui.c file contains the rendering logic.</p>
+
+<p>Proxying the price feeds through the Flask app permits me to configure the
+tickers I’m interested in via its application settings. The Flask app cycles
+through the tickers in its configuration file as it receives requests from the
+embedded software. The Flask app is secured with basic authentication
+implemented using htpasswd and OpenBSD’s httpd web server. This FastCGI-wrapped
+architecture dramatically reduces the complexity of the server code and
+increases system reliability.</p>
+
+<h2 id="news-feed">News feed</h2>
+
+<p>The more prominent panel on the right displays news from <a href="https://www.channelnewsasia.com/" class="external" target="_blank" rel="noopener noreferrer">Channel News Asia</a>. The embedded program downloads
+and parses the RSS feed before rendering it to the display. The character
+glyphs used for rendering news are stored in header files in the sprites
+directory as bitmaps. I created the glyphs manually by saving them as images in
+GIMP and rasterizing them with ImageMagick.</p>
+
+<p>I connected the embedded system directly to the RSS feed to write less server
+code (the focus of this project was the embedded system). In hindsight,
+however, it limits the feeds from which Etlas can receive data. In a future
+version, I will relay the RSS feed through the backend (like the stock prices)
+to make it more flexible.</p>
+
+<h2 id="weather-data">Weather data</h2>
<p>The bottom panels (middle and right) display the temperature and relative
humidity from a DHT22 sensor. The DHT22 driver, arguably the most interesting
part of the software, reads real-time sensor data by comparing relative pulse
widths. The pulses themselves are too quick for the ESP32 to reliably measure
-directly. I ported <a href="https://github.com/Fonger/ESP8266-RTOS-DHT" class="external" target="_blank" rel="noopener noreferrer">this</a>
-implementation for ESP8266 modules to my ESP32. All credit for the algorithm
-belongs to them.</p>
+directly.</p>
<p>Much of the heavy lifting of acquiring, interpreting, and rendering data from
different data sources is performed on the microcontroller using less than 512