CO2 monitor
This projects monitors the current CO₂ emissions per kWh of electricity being generated in the Netherlands. It obtains the data from ned.nl, and gets updated every 15 minutes. It has three modes:
cli
This mode polls the API once per minute and outputs it in the current format:
2024-11-29 19:30: 310.45g CO2/kWh
tray
This creates a system tray icon showing the CO₂ emissions rounded to the nearest natural number, shown here below the tooltip:
On hover it shows more details, and on click it opens https://co2monitor.nl
screen
This mode shows the current emisions a small EPD screen connected to some GPIO pins of the Raspberry Pi. It assumes that we are running on a Raspberry Pi, and fails otherwise.
See here a photo of how it looks on my 2.9 inch screen:
It uses the current locale (specifically, LC_TIME) to determine how the date looks. See Pins for an overview of what pins need to be connected to the screen.
Installation
I show pip commands here. However, pip isn’t ideal for this: use pipx or, as I do, uv (uv tool install co2monitor[tray], for example).
$ pip install co2monitor
Is sufficient for the cli mode. The other modes require rather large libraries and are therefore excluded from the base package. Install the dependencies required for the tray mode (Qt) with
$ pip install co2monitor[tray]
And, shockingly,
$ pip install co2monitor[screen]
For the screen mode. This installs pillow, RPi.GPIO and spidev.
Development
See the Makefile for some handy dev commands. I use uv to manage my dependencies, but it does not really matter all that much.
pyproject.toml has an Entry Point, which means that it installs a binary called co2monitor in the virtual environment. If you have the virtual environment activated, you can run co2monitor. For uv, you can execute uv run co2monitor to run the project.
Usage
$ co2monitor --help
Usage: co2monitor [OPTIONS] COMMAND [ARGS]...
Shows the current CO2 emissions per kWh of electricity in the Netherlands.
Options:
--debug / --no-debug
--api-key TEXT Override API_KEY environment variable.
--api-url TEXT [default: https://api.ned.nl/v1]
--user-agent TEXT Override USER_AGENT environment varaible.
--polltime INTEGER [default: 60]
--version Show the version and exit.
-h, --help Show this message and exit.
Commands:
cli Print emissions to the commandline.
screen Show emissions on an EPD screen connected via GPIO.
tray Add a system tray icon with emissions.
Pins
Screen
| Name | Function | Color | Pin number | GPIO |
|---|---|---|---|---|
| VCC | Power | Grey | 1 | - |
| GND | Ground | Brown | 6 | - |
| DIN | SPI MOSI | Blue | 19 | 10 (SPI0 MOSI) |
| CLK | SPI Clock | Yellow | 23 | 11 (SPI0 SCLK) |
| CS | SPI chip selection | Orange | 24 | 8 (SPI0 CE0) |
| DC | Data/Command selection | Green | 22 | 25 |
| RST | Reset | White | 11 | 17 |
| BUSY | Busy status output | Purple | 18 | 24 |
Metadata
Release files for co2monitor 2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| co2monitor-2.3.tar.gz | 25.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| co2monitor-2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.4 kB
Release files / co2monitor-2.3.tar.gz
| Download URL | co2monitor-2.3.tar.gz |
|---|---|
| Size | 25.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d21c44758c0368bfddb6e604cacc528bc112e35b69a420325ba8bf7f3115140
|
|
BLAKE2b-256 checksum How to use checksums |
ba9ac3a6c5062c043a14f9aac487d98e3e849a9e86d7a17a9ed829b5c779cb64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / co2monitor-2.3-py3-none-any.whl
| Download URL | co2monitor-2.3-py3-none-any.whl |
|---|---|
| Size | 14.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4eae10e89ba91840f3215cd13877e345066f16ec41a5d551bf39619928ee0835
|
|
BLAKE2b-256 checksum How to use checksums |
13623242b2ff3607bce1f0cd8c2ec1dc9627030f698c5ffeec4663aad983fc11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for co2monitor 2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.