Software apps and online services
The german government started a long time ago to promote renewable energy sources like photovoltaics and wind turbines with subsidies. That worked out well. On sunny and windy days around noon up to 75% (and sometimes even more) of the electricity production is from renewable sources. That is when I want to switch on my dishwasher or washing machine.
I wrote an email to the Umweltbundesamt (german federal environment agency) and asked them, if they have a webservice that returns the current share of renewable energy in electricity production. They do not have one, but they pointed me to Bundesnetzagentur. Bundesnetzagentur is a federal office that takes care of the telecommunications, electricity, gas, post and railway markets. They do not have such a webservice either, but they publish the required raw data in a machine-readable format. So I coded some lines of Python and a Bitbucket pipeline, registered at Google Cloud Platform and deployed my own webservice for that :-)
Then I used my ATOM Matrix to build a clock that also displays the share of renewables. The project is based on MicroPython. The Python program has four parts:
- Lines 16 to 44 connect to WLAN.
- Lines 47 to 96 call the webservice.
- Lines 99 to 145 parse the response of the webservice. The
Dateheader is used to get the local time. That is a bit complicated by the european rules for daylight saving time.
- Lines 148 to 210 scroll the time and the renewable share on the LED matrix.
Here are the installation instructions.1. Install Python, Esptool and Ampy
If you have no Python 3 installation on your computer please download the installer from https://www.python.org/downloads/ and execute it. Then install Esptool and Ampy with
> pip3 install esptool
> pip3 install adafruit-ampy
on the command line.2. Download and Install Firmware
Download https://micropython.org/resources/firmware/esp32-20220618-v1.19.1.bin. Connect your ATOM Matrix to your computer via USB. If you connect it the first time wait a little until Windows installed the driver. Open the Windows Device Manager and look into "COM & LPT" to find the correct COM port, e.g. COM6. Then install the firmware with
> esptool.py --chip esp32 --port COM6 erase_flash
> esptool.py --chip esp32 --port COM6 write_flash -z 0x1000 esp32-20220618-v1.19.1.bin
Reset your device after the installation is finished.3. Download and Install Libraries
Create a folder named
lib on your computer. Download the files
neopixel_scroller.mpy from https://bitbucket.org/amotzek/micro-python/downloads/ into that
lib folder. In the command line navigate to the folder above
lib and then execute
> ampy.exe --port COM6 --delay 3 put lib
to upload the folder to your ATOM Matrix.4. Edit and Upload main.py
From the Code section of this project copy the file
main.py to your computer and fill in your WLAN credentials in line 26 and a host name in line 24. Execute
> ampy.exe --port COM6 --delay 3 put main.py
to upload the file to your ATOM Matrix.What if you are not from Germany?
If you are from one of the neighbour countries of Germany you might just use my project. It is a good guess that the intraday changes of renewable energy are similar. Otherwise just try to ask the relevant government agencies as I did. Many good things started by asking for help. Happy hacking!