https://github.com/derf/esp8266-nodemcu-ssd1306
ESP8266 Lua/NodeMCU framebuffer + module for SSD1306 OLEDs
https://github.com/derf/esp8266-nodemcu-ssd1306
Last synced: 7 days ago
JSON representation
ESP8266 Lua/NodeMCU framebuffer + module for SSD1306 OLEDs
- Host: GitHub
- URL: https://github.com/derf/esp8266-nodemcu-ssd1306
- Owner: derf
- Created: 2022-05-31T20:12:07.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2026-01-25T09:13:18.000Z (4 months ago)
- Last Synced: 2026-01-26T00:12:43.092Z (4 months ago)
- Language: Lua
- Homepage: https://finalrewind.org/projects/esp8266-nodemcu-ssd1306/
- Size: 313 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSES/BSD-2-Clause.txt
Awesome Lists containing this project
README
# ESP8266 Lua/NodeMCU framebuffer + module for SSD1306 OLEDs
This repository provides an ESP8266 NodeMCU Lua module (`ssd1306.lua`),
framebuffer (`framebuffer.lua`) and fonts (`pixeloperator.lua`,
`terminus16.lua`) for 128×64 and 128×32 **SSD1306** OLEDs connected via I²2C.
## Dependencies
ssd1306.lua and framebuffer.lua have been tested with Lua 5.1 on NodeMCU
firmware 3.0.1 (Release 202112300746, integer build). They require the
following modules.
* bit
* i2c
## Usage
Copy **framebuffer.lua**, **ssd1306.lua** and (depending on your font choice)
**pixeloperator.lua** or **terminus16.lua** to your NodeMCU board and set them
up as follows.
```lua
i2c.setup(0, sda_pin, scl_pin, i2c.SLOW)
ssd1306 = require("ssd1306")
fn = require("pixeloperator") -- or "terminus16"
fb = require("framebuffer")
collectgarbage()
ssd1306.init(128, 64) -- assuming that a 128x64 OLED is connected
ssd1306.contrast(128) -- medium contrast
fb.init(128, 64) -- initialize framebuffer for 128x64 pixels
fb.print(fn, "Hello from NodeMCU!\nHello yes, this is Lua\n")
ssd1306.show(fb.buf)
```
128×32 OLEDs are also supported by adjusting the arguments to `ssd1306.init`
and `fb.init` accordingly.
## Flashing
This repository contains a NodeMCU build that provides the required modules.
You can flash it using e.g. esptool:
```bash
esptool write_flash 0x00000 firmware/nodemcu-release-11-modules-2024-01-18-18-47-17-integer.bin
```
After flashing, the firmware will need a few seconds to initialize the
filesystem. You then flash the Python code, e.g. using nodemcu-uploader:
```bash
ext/nodemcu-uploader/nodemcu-uploader.py upload *.lua
```
Afterwards, you can check whether everything works using the serial connection,
e.g.
```bash
pyserial-miniterm --dtr 0 --rts 0 /dev/ttyUSB0 115200
```
You may need to adjust the `/dev/tty` device name.
## References
Mirrors of this repository are maintained at the following locations:
* [Chaosdorf](https://chaosdorf.de/git/derf/esp8266-nodemcu-ssd1306)
* [Finalrewind](https://git.finalrewind.org/derf/esp8266-nodemcu-ssd1306)
* [GitHub](https://github.com/derf/esp8266-nodemcu-ssd1306)