Giter Club home page Giter Club logo

ssd1306-esp-idf-i2c's Introduction

Sample code for driving 128x64 OLED display with SSD1306 driver via ESP-IDF's I2C master driver ====================

See main code main.c.

About

This sample code implement procedures to read values from 128x64 OLED display with SSD1306 driver via ESP-IDF's I2C master driver. It supports all features decribed in Solomon Systech's SSD1306 datasheet.

----------For local setup ----------

For your local setup, connect SDI pin to GPIO 15 pin and the SCK to GPIO 2 pin as they are default ports (I2C_SDA, I2C_SCL) for I2C master according to ESP32 datasheet, C.4. IO_MUX, Page 49.

Be aware about there are serveal models on 128x64 OLED display with SSD1306. Like one model with more pins works with both SPI/I2C, and another model with lesser pins works I2C only. This cample code is confirmed with a OLED model which have (GND, VDD, SCK, SDA) pins and it supports I2C only (no SPI available). Perhaps your model has slightly different pins, but it should works.

In case it does not work, please check your circit. Consider insert 10k ohm pull-up registors on between 3.3v power supply and (SDA, SCK) pins respectively, as OLED display consumes larger current comparing with other tiny I2C sensors. In my case, 10k ohm pull-up registors stabilized voltage level for clock and SDA and the code worked correctly.

ssd1306-esp-idf-i2c's People

Contributors

igrr avatar projectgus avatar spritetm avatar yanbe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ssd1306-esp-idf-i2c's Issues

Warning when compiling in PlatformIO

Compiling .pio/build/esp32doit-devkit-v1/src/main.o
src/main.c: In function 'app_main':
src/main.c:225:14: warning: passing argument 1 of 'xTaskCreate' from incompatible pointer type [-Wincompatible-pointer-types]
  xTaskCreate(&task_ssd1306_display_text, "ssd1306_display_text",  2048,
              ^
In file included from src/main.c:3:0:
/Users/raf/.platformio/packages/framework-espidf/components/freertos/include/freertos/task.h:432:37: note: expected 'TaskFunction_t {aka void (*)(void *)}' but argument is of type 'void (*)(const void *)'
  static inline IRAM_ATTR BaseType_t xTaskCreate(

sample code creates errors

hI,
when using the code,
xTaskCreate(&task_ssd1306_display_text, "ssd1306_display_text", 2048,
(void )"Hello world!\nMulitine is OK!\nAnother line", 6, NULL);
following error comes up :
note: expected 'TaskFunction_t {aka void (
)(void )}' but argument is of type 'void ()(const void *)'
static inline IRAM_ATTR BaseType_t xTaskCreate(
Can anyone advise why this error pops up , and how to solve it ?
thanks in advance
best regadrs
Ludo

Why not make it a library?

There is no decent SSD1306 library for ESP-IDF but several for Arduino platform. Wemos already have ESP32 model with built-in OLED, so it would be nice to have a native IDF support for the display.

Heltec - Makerhawk ESP32 Wifi

Just adding this comment to your project because from my google search there appears to be a number of people who have searched for an esp-idf based solution to driving this type of display which has been integrated into this board. Heltec themselves however only provide ardinuo based code. It is however very simple to get running, the key thing is a reset needs to be sent to the OLED display for it to start working.

diff --git a/main/main.c b/main/main.c
index 2f35dd2..c1f1776 100644
--- a/main/main.c
+++ b/main/main.c
@@ -11,8 +11,9 @@
 #include "ssd1366.h"
 #include "font8x8_basic.h"
 
-#define SDA_PIN GPIO_NUM_15
-#define SCL_PIN GPIO_NUM_2
+#define SDA_PIN GPIO_NUM_4
+#define SCL_PIN GPIO_NUM_15
+#define RST_PIN GPIO_NUM_16
 
 #define tag "SSD1306"
 
@@ -24,7 +25,7 @@ void i2c_master_init()
                .scl_io_num = SCL_PIN,
                .sda_pullup_en = GPIO_PULLUP_ENABLE,
                .scl_pullup_en = GPIO_PULLUP_ENABLE,
-               .master.clk_speed = 1000000
+               .master.clk_speed = 700000
        };
        i2c_param_config(I2C_NUM_0, &i2c_config);
        i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0);
@@ -35,6 +36,11 @@ void ssd1306_init() {
 
        i2c_cmd_handle_t cmd = i2c_cmd_link_create();
 
+        gpio_set_direction(RST_PIN,GPIO_MODE_OUTPUT);
+        gpio_set_level(RST_PIN, 0);
+        vTaskDelay( pdMS_TO_TICKS( 100 ) );
+        gpio_set_level(RST_PIN, 1);
+
        i2c_master_start(cmd);
        i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
        i2c_master_write_byte(cmd, OLED_CONTROL_BYTE_CMD_STREAM, true);

It is not working with esp-idf

Device: ESP32-WROOM-32

Steps:
Run get_idf in the directory
Run make all to build the app

Compilation crashes after a while with this
CC build/esp_wifi/src/wifi_init.o $IDF_PATH/esp/esp-idf/components/esp_wifi/src/wifi_init.c:32:2: error: #error "WiFi configuration check: WARNING, WIFI_RX_BA_WIN should not be larger than WIFI_DYNAMIC_RX_BUFFER_NUM!" #error "WiFi configuration check: WARNING, WIFI_RX_BA_WIN should not be larger than WIFI_DYNAMIC_RX_BUFFER_NUM!" ^~~~~ make[1]: *** [$IDF_PATH/esp/esp-idf/make/component_wrapper.mk:292: src/wifi_init.o] Error 1 make: *** [$IDF_PATH/esp/esp-idf/make/project.mk:642: component-esp_wifi-build] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.