PowerLight: Difference between revisions

From RevSpace
Jump to navigation Jump to search
Line 105: Line 105:
Source code: https://github.com/bertrik/energymix-server
Source code: https://github.com/bertrik/energymix-server


Runs as a REST-like resource at:
Runs as a REST-like resource, with the following endpoints:
* http://stofradar.nl:9001/electricity/generation with details about the current (35-50 minute ago) energy generation mix
* http://stofradar.nl:9001/electricity/generation with details about the current (35-50 minute ago) electricity generation mix
* http://stofradar.nl:9001/electricity/price with day-ahead hourly price-per-MWh for today
* http://stofradar.nl:9001/electricity/price with day-ahead hourly electricity price-per-MWh for today
* http://stofradar.nl:9001/naturalgas/price with daily natural gas prices (neutral gas price) of [https://en.wikipedia.org/wiki/Title_Transfer_Facility TTF] spot market, in euro/MWh, multiply by 35.17/3600 to get euro/m3
(1-minute rate limit)
(1-minute rate limit)



Revision as of 09:02, 31 October 2022

Project PowerLight
PowerLight.jpg
Show energy mix of dutch power generation as a pie chart on a LED ring
Status Completed
Contact bertrik
Last Update 2022-10-31

The concept

Draw the current dutch electrical power generation-mix as pie chart on a LED ring light, with colors representing fractions of a specific power generation source.

For example:

  • yellow: solar
  • blue: wind
  • red: fossil
  • green: nuclear
  • grey: other/waste

Power generation data

Information about energy in Europe is collected at the european organisation https://www.entsoe.eu/ . The section about electrical energy is collected in ENTSO-E. Data is available from this platform at a 15-minute interval.

TenneT is the organisation that supplies ENTSO-E with data from the Netherlands.

Information about ENTSO-E generation domain API: https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html#_generation_domain

Also possibly interesting (requires an API key), but might actually just use the entso-e data: https://static.electricitymap.org/api/docs/index.html#introduction

ENTSO-E data

ENTSO-E distinguishes energy generation into several types ("PsrType"). This is how they are relevant to the data from the Netherlands:

  • B01 (biomass): always 0, not useful
  • B02: not available
  • B03: not available
  • B04 (fossil hard coal): useful
  • B05 (fossil gas): useful
  • B06: not available
  • B07: not available
  • B08: not available
  • B09 (geothermal): not available
  • B10 (hydro): not available
  • B11 (hydro): always 0
  • B12 (hydro): not available
  • B13 (marine): not available
  • B14 (nuclear): useful
  • B15 (other renewable): not available
  • B16 (solar): hugely underreported, *not* useful
  • B17 (waste): useful
  • B18 (wind offshore): useful
  • B19 (wind onshore): useful
  • B20 (other): useful

Additionally, ENTSO-E provides a day-ahead forecast for:

  • B16 (solar)
  • B18 (wind offshore)
  • B19 (wind onshore)

A model for the energy generation mix of the Netherlands

For me, the most insightful information came from this article by Bert Hubert: https://berthub.eu/articles/posts/dutch-electrical-power-figures-2/

Main points relevant for me:

  • the solar part reported to entso-e is way too small
  • on-shore wind data is unreliable, but off-shore wind data is probably OK
  • no biomass data is reported to entso-e

Note also in https://energy-charts.info/charts/energy_pie/chart.htm?l=en&c=NL how the solar part is tiny

There is a model that estimates the solar fraction, also at a regional level and at fine time resolution, at https://api.netanders.io/ However use of this model requires a paid subscription, so I cant't use that.

In my application, energy generation fractions are calculated as follows:

  • solar = B16 (from the time-shifted forecast document A69)
  • wind = B18 (offshore, from generation document A75) + B19 (onshore, from time-shifted forecast document A69)
  • fossil = B04 (gas) + B05 (coal)
  • nuclear = B14
  • waste = B17
  • other = B20

Solar energy values from the forecast document show a systematic shift of about 30 minutes compared to other sources (e.g. sunrise/sunset data from national weather institute KNMI, energieopwek.nl) so forecast data from the ENTSO-E document is shifted by 30 minutes in my model.

Data schedule

Entso-E provides data with a resolution of 15 minutes. It appears to become available about 5m20s after the start of each 15 minute period (:00, :15, :30, :45). At that point, the most recent data is from an interval that ended 30 minutes ago. So, including the 5m20s minute processing delay, the most recent data available is about 35 minutes old.

Hardware

Parts:

Software

The software consists of two parts:

  • The backend part that collects the power generation data, written in Java, running on a VPS
  • The light part that visualizes the power generation as fractions on a LED ring, running on an Arduino

Backend

Source code: https://github.com/bertrik/energymix-server

Runs as a REST-like resource, with the following endpoints:

(1-minute rate limit)

Returns a JSON-structure like:

{
  "time": 1657057500,
  "total": 9122,
  "mix": [
    { "id": "solar", "power": 0, "color": "#FFFF00"},
    { "id": "wind", "power": 4, "color": "#0000FF"},
    { "id": "fossil", "power": 86, "color": "#FF0000"},
    { "id": "nuclear", "power": 5, "color": "#FF00FF"},
    { "id": "other", "power": 4, "color": "#444444"},
    { "id": "waste", "power": 1, "color": "#444444"}
  ]
}
  • time is a unix time stamp in seconds, representing the end of the 15-minute period that the power figures refer to
  • total is the total most recent electrical power (megawatt), suitable for display (on a numeric display inside the ring for example)
  • mix is an array of power sources, each with:
    • a short unique id
    • most recent known power (megawatt)
    • hex color, for display on the led ring

Display

Powerlight

Shows the dutch energy generation mix by source. Source code: https://github.com/bertrik/PowerLight

The Arduino sketch polls the REST API using HTTP every minute.

WiFi is managed by WifiManager. LEDs are controlled using FastLED. JSON content is parsed using ArduinoJSON.

ElectricityPrice

Shows the current dutch electricity price, based on the day-ahead prices from yesterday. Source code: https://github.com/bertrik/ElectricityPrice

The Arduino sketch polls the REST price API using HTTP every 5 minutes. WiFi is managed by WifiManager. JSON content is parsed using ArduinoJSON.

Hardware is an ESP8266 controlling a 7-segment display based on a TM1637, on pins D3 and D4.

T-Display
Nlecprice mockup.png

Alternative: use a TTGO ESP32 T-Display.

It has a 240x135 pixel display. Plan is to show a kind of bar graph with 24 bars (one bar for each hour), each bar's height indicates the price of that hour. The background color shows green/black/red, to indicate cheap/moderate/expensive. Current price is shown as a big number.

Each bar is therefore 10 pixels wide, 9 pixels for the bar + 1 pixel separation.

SHA-badge

The SHA2017 badge has an ESP32 capable of performing the HTTP request, processing the JSON and displaying the result on its display. These badges are limited-edition, a few thousand of them were made for the SHA-2017 event and they're no longer being produced.

It has a 296x128 pixel epaper panel. So that could be a bar graph of 24 bars with a width of 12 pixels each, on the bottom 2/3rds of the display, and a current price on the top 1/3rd of the display.

Could be run as a micropython sketch. Alternatively could be run as an Arduino sketch.

Micropython:

  • ++ possibly quick development, script can be shared with other people
  • ++ has working libs for fetching HTTP, decoding JSON, controlling the display
  • -- script needs frequent garbage collection to avoid crashing?
  • -- unclear how to get a python script on this thing
  • -- sha badge firmware bootloops, currently unusable to me

Arduino:

  • ++ I know this environment, don't have to debug existing bootlooping firmware, no compiler setup required
  • ++ Already have HTTP and JSON working on Arduino
  • ++ Code starts immediately, no user interaction required
  • -- not sure if there is a usable epaper driver