2019-02-27 10:10:09 +01:00
|
|
|
SSD1306 OLED Display
|
|
|
|
====================
|
2018-08-22 22:05:28 +02:00
|
|
|
|
2018-11-14 22:12:27 +01:00
|
|
|
.. seo::
|
2019-02-27 10:10:09 +01:00
|
|
|
:description: Instructions for setting up SSD1306 OLED display drivers.
|
2018-11-14 22:12:27 +01:00
|
|
|
:image: ssd1306.jpg
|
|
|
|
|
2019-02-27 10:10:09 +01:00
|
|
|
.. _ssd1306-i2c:
|
|
|
|
|
|
|
|
Over I²C
|
|
|
|
--------
|
|
|
|
|
|
|
|
The ``ssd1306_i2c`` display platform allows you to use
|
2019-02-27 18:32:47 +01:00
|
|
|
SSD1306 (`datasheet <https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf>`__,
|
|
|
|
`Adafruit <https://www.adafruit.com/product/326>`__)
|
|
|
|
and SH1106 (`datasheet <https://www.elecrow.com/download/SH1106%20datasheet.pdf>`__,
|
|
|
|
`electrodragon <https://www.electrodragon.com/product/1-3-12864-blue-oled-display-iicspi/>`__)
|
2019-02-27 10:10:09 +01:00
|
|
|
displays with ESPHome. Note that this component is for displays that are connected via the :ref:`I²C Bus <i2c>`.
|
|
|
|
If your SSD1306 or SH1106 is connected via the 4-Wire :ref:`SPI bus <spi>`, see :ref:`ssd1306-spi`.
|
|
|
|
|
|
|
|
.. figure:: images/ssd1306-full.jpg
|
|
|
|
:align: center
|
|
|
|
:width: 75.0%
|
|
|
|
|
|
|
|
SSD1306 OLED Display
|
|
|
|
|
|
|
|
Connect D0 to the SCL pin you chose for the :ref:`I²C Bus <i2c>`, and connect D1 to the SDA pin. For power, connect
|
|
|
|
VCC to 3.3V and GND to GND. Optionally you can also connect the ``RESET`` pin to a pin on the ESP which may
|
|
|
|
improve reliability.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
i2c:
|
|
|
|
sda: D1
|
|
|
|
scl: D2
|
|
|
|
|
|
|
|
display:
|
|
|
|
- platform: ssd1306_i2c
|
|
|
|
model: "SSD1306 128x64"
|
|
|
|
reset_pin: D0
|
|
|
|
address: 0x3C
|
|
|
|
lambda: |-
|
|
|
|
it.print(0, 0, id(font), "Hello World!");
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
************************
|
|
|
|
|
|
|
|
- **model** (**Required**): The model of the display. Options are:
|
|
|
|
|
|
|
|
- ``SSD1306 128x32`` (SSD1306 with 128 columns and 32 rows)
|
|
|
|
- ``SSD1306 128x64``
|
|
|
|
- ``SSD1306 96x16``
|
|
|
|
- ``SSD1306 64x48``
|
|
|
|
- ``SH1106 128x32``
|
|
|
|
- ``SH1106 128x64``
|
|
|
|
- ``SH1106 96x16``
|
|
|
|
- ``SH1106 64x48``
|
|
|
|
|
|
|
|
- **reset_pin** (*Optional*, :ref:`Pin Schema <config-pin_schema>`): The RESET pin. Defaults to not connected.
|
|
|
|
- **address** (*Optional*, int): Manually specify the :ref:`I²C <i2c>` address of the display. Defaults to 0x3C.
|
|
|
|
- **rotation** (*Optional*): Set the rotation of the display. Everything you draw in ``lambda:`` will be rotated
|
|
|
|
by this option. One of ``0°`` (default), ``90°``, ``180°``, ``270°``.
|
2021-02-20 22:02:46 +01:00
|
|
|
- **brightness** (*Optional*, percentage): Set display brightness in %. Defaults to ``100%``
|
2019-02-27 10:10:09 +01:00
|
|
|
- **external_vcc** (*Optional*, boolean): Set this to true if you have the VCC pin connected to an external power supply.
|
|
|
|
Defaults to ``false``.
|
|
|
|
- **lambda** (*Optional*, :ref:`lambda <config-lambda>`): The lambda to use for rendering the content on the display.
|
|
|
|
See :ref:`display-engine` for more information.
|
|
|
|
- **update_interval** (*Optional*, :ref:`config-time`): The interval to re-draw the screen. Defaults to ``5s``.
|
|
|
|
- **pages** (*Optional*, list): Show pages instead of a single lambda. See :ref:`display-pages`.
|
|
|
|
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2020-05-10 21:27:59 +02:00
|
|
|
To speed up the display update process you can select higher I²C frequencies.
|
2019-02-27 10:10:09 +01:00
|
|
|
|
|
|
|
.. _ssd1306-spi:
|
|
|
|
|
|
|
|
Over SPI
|
|
|
|
--------
|
|
|
|
|
2018-08-22 22:05:28 +02:00
|
|
|
The ``ssd1306_spi`` display platform allows you to use
|
|
|
|
SSD1306 (`datasheet <https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf>`__, `Adafruit <https://www.adafruit.com/product/326>`__)
|
2019-02-27 18:32:47 +01:00
|
|
|
and SH1106 (`datasheet <https://www.elecrow.com/download/SH1106%20datasheet.pdf>`__,
|
|
|
|
`electrodragon <https://www.electrodragon.com/product/1-3-12864-blue-oled-display-iicspi/>`__)
|
2019-02-16 23:25:23 +01:00
|
|
|
displays with ESPHome. Note that this component is for displays that are connected via the 4-Wire :ref:`SPI bus <spi>`.
|
2019-02-27 10:10:09 +01:00
|
|
|
If your SSD1306 or SH1106 is connected via the :ref:`I²C Bus <i2c>`, see :ref:`ssd1306-i2c`.
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
.. figure:: images/ssd1306-full.jpg
|
|
|
|
:align: center
|
|
|
|
:width: 75.0%
|
|
|
|
|
|
|
|
SSD1306 OLED Display
|
|
|
|
|
|
|
|
Connect D0 to the CLK pin you chose for the :ref:`SPI bus <spi>`, connect D1 to the MOSI pin and ``DC`` and ``CS``
|
2020-07-25 14:24:02 +02:00
|
|
|
to some GPIO pins on the ESP. For power, connect
|
|
|
|
VCC to 3.3V and GND to GND. Optionally you can also connect the ``RESET`` pin to a pin on the ESP which may
|
|
|
|
improve reliability.
|
2018-08-22 22:05:28 +02:00
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
spi:
|
|
|
|
clk_pin: D0
|
|
|
|
mosi_pin: D1
|
|
|
|
|
|
|
|
display:
|
|
|
|
- platform: ssd1306_spi
|
|
|
|
model: "SSD1306 128x64"
|
|
|
|
cs_pin: D2
|
|
|
|
dc_pin: D3
|
|
|
|
reset_pin: D4
|
|
|
|
lambda: |-
|
|
|
|
it.print(0, 0, id(font), "Hello World!");
|
|
|
|
|
|
|
|
Configuration variables:
|
2019-02-27 10:10:09 +01:00
|
|
|
************************
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
- **model** (**Required**): The model of the display. Options are:
|
|
|
|
|
|
|
|
- ``SSD1306 128x32`` (SSD1306 with 128 columns and 32 rows)
|
|
|
|
- ``SSD1306 128x64``
|
|
|
|
- ``SSD1306 96x16``
|
2018-10-07 16:52:00 +02:00
|
|
|
- ``SSD1306 64x48``
|
2018-08-22 22:05:28 +02:00
|
|
|
- ``SH1106 128x32``
|
|
|
|
- ``SH1106 128x64``
|
|
|
|
- ``SH1106 96x16``
|
2018-10-07 16:52:00 +02:00
|
|
|
- ``SH1106 64x48``
|
2018-08-22 22:05:28 +02:00
|
|
|
|
2020-07-25 14:24:02 +02:00
|
|
|
- **cs_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The Chip Select (CS) pin.
|
2018-08-22 22:05:28 +02:00
|
|
|
- **dc_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The DC pin.
|
|
|
|
- **reset_pin** (*Optional*, :ref:`Pin Schema <config-pin_schema>`): The RESET pin. Defaults to not connected.
|
|
|
|
- **rotation** (*Optional*): Set the rotation of the display. Everything you draw in ``lambda:`` will be rotated
|
|
|
|
by this option. One of ``0°`` (default), ``90°``, ``180°``, ``270°``.
|
2021-02-20 22:02:46 +01:00
|
|
|
- **brightness** (*Optional*, percentage): Set display brightness in %. Defaults to ``100%``
|
2018-08-22 22:05:28 +02:00
|
|
|
- **external_vcc** (*Optional*, boolean): Set this to true if you have the VCC pin connected to an external power supply.
|
|
|
|
Defaults to ``false``.
|
|
|
|
- **lambda** (*Optional*, :ref:`lambda <config-lambda>`): The lambda to use for rendering the content on the display.
|
|
|
|
See :ref:`display-engine` for more information.
|
|
|
|
- **update_interval** (*Optional*, :ref:`config-time`): The interval to re-draw the screen. Defaults to ``5s``.
|
2019-02-22 21:17:31 +01:00
|
|
|
- **pages** (*Optional*, list): Show pages instead of a single lambda. See :ref:`display-pages`.
|
2018-08-22 22:05:28 +02:00
|
|
|
- **spi_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the :ref:`SPI Component <spi>` if you want
|
|
|
|
to use multiple SPI buses.
|
|
|
|
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
|
|
|
|
|
|
|
|
See Also
|
|
|
|
--------
|
|
|
|
|
|
|
|
- :doc:`index`
|
2019-05-12 22:44:59 +02:00
|
|
|
- :apiref:`ssd1306_base/ssd1306_base.h`
|
2018-11-19 18:32:16 +01:00
|
|
|
- `SSD1306 Library <https://github.com/adafruit/Adafruit_SSD1306>`__ by `Adafruit <https://www.adafruit.com/>`__
|
2019-02-07 13:54:45 +01:00
|
|
|
- :ghedit:`Edit`
|