{"id":13802124,"url":"https://github.com/lemariva/uPyEINK","last_synced_at":"2025-05-13T12:32:27.232Z","repository":{"id":49352343,"uuid":"184952024","full_name":"lemariva/uPyEINK","owner":"lemariva","description":"Control a Waveshare 7.5\" E-INK display using an ESP32 running MicroPython ","archived":false,"fork":false,"pushed_at":"2020-02-23T21:37:45.000Z","size":1497,"stargazers_count":29,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T17:51:40.110Z","etag":null,"topics":["e-ink","esp32","micropython","waveshare-eink"],"latest_commit_sha":null,"homepage":"https://lemariva.com/blog/2020/02/micropython-e-ink-display-controlled-esp32","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lemariva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-04T22:56:30.000Z","updated_at":"2024-12-18T11:50:44.000Z","dependencies_parsed_at":"2022-09-06T21:40:53.573Z","dependency_job_id":null,"html_url":"https://github.com/lemariva/uPyEINK","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyEINK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyEINK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyEINK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyEINK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemariva","download_url":"https://codeload.github.com/lemariva/uPyEINK/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253942647,"owners_count":21988105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["e-ink","esp32","micropython","waveshare-eink"],"created_at":"2024-08-04T00:01:36.643Z","updated_at":"2025-05-13T12:32:26.853Z","avatar_url":"https://github.com/lemariva.png","language":"Python","readme":"# uPyEINK\nThis project runs on the [e-Paper ESP32 Driver board](https://www.banggood.com/custlink/mKvmb95GQR) and allows you to display information (weather, news, notes) on a [Waveshare 7.5\" E-INK V1 display](https://www.banggood.com/custlink/3GGmQZH3nV).\n\nThree widgets displaying following information are available:\n* Weather: weather forecast obtained using the [OpenWeatherMap api](https://openweathermap.org/api).\n* News: news highlights obtained using the [NewsApi api](https://newsapi.org/).\n* Notes: notes that can be added using a web-server that runs on the ESP32.\n## More Information\n[MicroPython: an E-INK display controlled using an ESP32](https://lemariva.com/blog/2020/02/micropython-e-ink-display-controlled-esp32)\n## DIY\nThe RAM of the ESP32-WROOM (512kb) running MicroPython is very limited. Therefore, it is not possible to load the un-compiled modules and run the code. You will get the annoying error:\n```\nMemoryError: memory allocation failed, allocating xxxx bytes\n```\nTo avoid that, you should include the modules under the folder `frozen_modules` as \"frozen\" modules on your MicroPython firmware. If you don't know how to do that, check the sub-section \"Freeze MicroPython Module\" below.\n\n### Configure the project\nRename the files:\n* `boot.py.sample` to `boot.py` and include your Wi-Fi credentials:\n    * ssid_ = ''\n    * wpa2_pass = ''\n\n    You need that your ESP32 connect to Wi-Fi to update the widgets.\n* `settings.py.sample` to `settings.py` and set up the following variables:\n    * news_api_key ([info here](https://newsapi.org/register))\n    * weather_api_key ([info here](https://openweathermap.org/appid))\n\nUpload the code to the ESP32, using e.g. [VSCode and PyMakr extension](https://lemariva.com/blog/2018/12/micropython-visual-studio-code-as-ide) and have fun!\n\nThe web-server is available under `http://\u003cesp32-ip\u003e` and you can add and remove notes that will be displayed on the E-INK display. \n\nThe E-INK update frequency is set to 2 hours (`settings.update_interval` in milliseconds) and after 5 updates (`settings.calibration_interval`) the ESP32 cleans the display to avoid ghosting and reset the board to update the clock using a ntp server. If you want to, you can activate the deep sleep functionality (`settings.deep_sleep`) but you lose the web-server and you can only update the notes only when the ESP32 is updating the display.\n\n## Reduce memory use on MicroPython (ESP32)\nThere are two ways to reduce memory use on MicroPython:\n* Compile the MicroPython module using the `mpy-cross` compiler, or\n* Include the modules as \"frozen\" modules inside the MicroPython firmware.\n\n### Compile MicroPython modules\nTo compile a module you need to download the MicroPython repository.\n```\ngit clone https://github.com/micropython/micropython.git\n```\nThen, go to the `mpy-cross` folder and compile the cross-compiler:\n```\ncd micropython/mpy-cross\nmake\n```\nThen, you can compile a MicroPython file using:\n```\n./my-cross foo.py\n```\nThis generates a `.mpy` file that you can load on your ESP32 board. You need to remove the original `.py`, otherwise you import the un-compiled file every time you use `import ...`.\n\nMore info: [here](https://github.com/micropython/micropython/tree/master/mpy-cross).\n\nIf you use another MicroPython version (e.g. [MicroPython LoBo](https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo)), you need to clone that repository and `make` the cross-compiler, otherwise the obtained `.mpy` file won't work on your ESP32\n\n### Freeze MicroPython modules\nTo include your module in the firmware, you need to clone the MicroPython repository using:\n```\ngit clone https://github.com/micropython/micropython.git\ncd micropython\ngit submodule update --init\n```\nand copy the module files that you want to freeze into `micropython/ports/esp32/modules`. This way is a bit more complicated but it makes you code [faster](https://kapusta.cc/2018/03/31/epd/). After cloning the repository, you have to compile it but first you need to set up the toolchain and the ESP-IDF:\n\n#### Setting up the toolchain and ESP-IDF\nThe binary toolchain (binutils, gcc, etc.) can be installed using the following\nguides:\n\n  * [Linux installation](https://docs.espressif.com/projects/esp-idf/en/stable/get-started/linux-setup.html)\n  * [MacOS installation](https://docs.espressif.com/projects/esp-idf/en/stable/get-started/macos-setup.html)\n  * [Windows installation](https://docs.espressif.com/projects/esp-idf/en/stable/get-started/windows-setup.html)\n\nOnce everything is set up, you will need to update your PATH environment variable to include the ESP32 toolchain. For example, you can issue the following commands on (at least) Linux:\n```\nexport PATH=$PATH:$HOME/esp/crosstool-NG/builds/xtensa-esp32-elf/bin\n```\n\nThen, clone the esp-idf repository under e.g. `~/esp/` using the following code:\n```\ncd ~/esp32/\ngit clone https://github.com/espressif/esp-idf.git\ngit checkout \u003ccurrent supported ESP-IDF commit hash\u003e\ngit submodule update --init --recursive\n```\n`\u003ccurrent supported ESP-IDF commit hash\u003e` this hash can be seen in the file `micropython/ports/esp32/Makefile`:\n\n```\n# the git hash of the currently supported ESP IDF version\nESPIDF_SUPHASH_V3 := 6ccb4cf5b7d1fdddb8c2492f9cbc926abaf230df\nESPIDF_SUPHASH_V4 := 310beae373446ceb9a4ad9b36b5428d7fdf2705f\n```\n\nOtherwise, you can type `make` inside the `micropython/ports/esp32/` and you get an error, if you don't have the correct ESP-IDF version. Of course, this can be done, after setting the environmental variable `$IDF_PATH` to the cloned repository e.g.:\n```\nexport $IDF_PATH=$HOME/esp/esp-idf\n```\n#### Making and deploying the firmware\nAfter those steps, you can type `make deploy` inside the folder `micropython/ports/esp32/`. The command compiles the firmware and if your board is connected to the USB (`/dev/ttyUSB0`, otherwise check the `Makefile` to change it), it uploads the firmware to the board.\n\nYou should see something like this:\n```\nUse make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.\nBuilding with ESP IDF v3\nMPY e7in5.py\n[...]\nMPY fonts/monaco16.py\n[...]\nMPY widgets/forecast.py\n[...]\nGEN build-GENERIC/frozen_content.c\n[...]\nWriting build-GENERIC/firmware.bin to the board\nesptool.py v2.8-dev\nSerial port /dev/ttyUSB0\nConnecting.....\nChip is ESP32D0WDQ6 (revision 1)\nFeatures: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None\nCrystal is 40MHz\nMAC: cc:50:e3:a8:80:cc\nUploading stub...\nRunning stub...\nStub running...\nChanging baud rate to 460800\nChanged.\nConfiguring flash size...\nAuto-detected Flash size: 4MB\nCompressed 1336896 bytes to 816859...\nWrote 1336896 bytes (816859 compressed) at 0x00001000 in 20.9 seconds (effective 510.7 kbit/s)...\nHash of data verified.\n\nLeaving...\nHard resetting via RTS pin...\n```\n\nThe modules are compiled (MPY) and added to the MicroPython firmware as frozen modules. \n\nIf you have some problems to load the firmware/code to your ESP32 board, try erasing the flash first using:\n```\nesptool.py --port /dev/ttyUSB0 erase_flash\n```\nand then deploying the firmware again. This is needed, if you were using the ESP32 with arduino's code.\n\n## Acknowledgement\nI took code and ideas from following repos and wikis:\n* [A MicroPython implementation for a smaller display](https://kapusta.cc/2018/03/31/epd/)\n* [Database implementation and HTML/CSS designs](https://github.com/pfalcon/notes-pico)\n* [LUT and some code](https://github.com/mcauser/micropython-waveshare-epaper)\n* [Some other code](https://www.waveshare.com/wiki/Libraries_Installation_for_RPi)\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Display"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemariva%2FuPyEINK","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemariva%2FuPyEINK","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemariva%2FuPyEINK/lists"}