logo elektroda
logo elektroda
X
logo elektroda

Operation of the ESP-12F OLED display on the NodeMCU with Arduino IDE

JanuszKornas 2433 17
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18490356
    JanuszKornas
    Level 11  
    I bought such a plate:

    https://abc-rc.pl/product-pol-9534-Modul-NODE...SP-12F-z-wyswietlaczem-OLED-0-96-Arduino.html

    It has an integrated Oled module. When power is applied via USB, it starts some demo, so the board is probably good. I've been programming the ESP32 through the Arduino IDE environment and wanted the same here. Unfortunately, but I can't find a library to support this OLED. ABC-RC writes that there is a 1306 and the display itself is 168x64. Libraries for 1306, on the other hand, have descriptions that they are up to 128x64 or smaller. Abstracting from the resolution, they do not work.
    I tried this library:
    https://github.com/ThingPulse/esp8266-oled-ssd1306

    But leaving SDA/SCL doesn't work, and swapping to D1/D2 (as the PCB descriptions suggest), throws errors.

    Anyone program such a board with the help of the Arduino IDE?
    Do you have a problem with Arduino? Ask question. Visit our forum Arduino.
  • ADVERTISEMENT
  • Helpful post
    #2 18490406
    khoam
    Level 42  
    JanuszKornas wrote:
    ABC-RC writes that there is a 1306, and the display itself is 168x64.
    .
    If the SSD1306 is there, it supports a resolution of 128x64.
    https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf

    I suggest you start with the examples provided by the manufacturer of this D-duino board:
    https://github.com/lspoplove/D-duino/tree/master/Arduino-examples
  • ADVERTISEMENT
  • #3 18490492
    vieleicht
    Level 37  
    Check the I2c address with a scanner. Maybe it is different from the example.
  • #4 18490558
    JanuszKornas
    Level 11  
    vieleicht wrote:
    Check the I2c address with a scanner. Maybe it is different from the example.
    .
    I tried it and it didn't detect anything. But I had a warning that bibiotego times.h, or wires.h was in several versions (I'll check carefully tonight). It sounded like I had it in several versions and now I don't know which one was loading.

    I will check these examples from the manufacturer in the evening.
  • #5 18490584
    khoam
    Level 42  
    JanuszKornas wrote:
    I tried and it did not detect anything.
    .
    This module uses D1 as SDA and D2 as SCL to control the display, the opposite of the default I2C pins for the ESP8266.
  • #6 18491589
    JanuszKornas
    Level 11  
    1) I don't know how in an I2C scanner I'm supposed to indicate that the SDA/SCL is on such and such port, I've looked and haven't figured out how to do that. If anyone knows, for sport I'd love to know.
    2.
    khoam wrote:
    I suggest starting with the examples that have been prepared by the manufacturer of this D-duino board:
    https://github.com/lspoplove/D-duino/tree/master/Arduino-examples
    .
    This link works, but there are links to two whitepapers, unfortunately the first one does not work (wrong link). On the other hand, I found the pin description (PinMap from this link to be crucial:
    https://github.com/lspoplove/D-duino
    The numbers used on the ArduinoIDE are described in blue. After entering the SDA/SCL numbers as pins 5 and 4, some examples work (I have examples that are described as "ESP8266 and ESP32 OLED driver for SSD1306 displays". These are examples from the library I indicated in the first post. The example from the link indicated in the current (this) post also works.

    UFF, something is already working to display. Thank you all for your help.
  • Helpful post
    #7 18491604
    khoam
    Level 42  
    JanuszKornas wrote:
    I don't know how in an I2C scanner I would indicate that the SDA/SCL is on such and such a port
    .
    Change Wire.begin(), to Wire.begin(D1, D2).

    Added after 4 [minutes]:

    JanuszKornas wrote:
    This link works, but there are links to two bibiots, unfortunately the first one does not work (wrong link).
    .
    I was referring to the examples contained in the individual subdirectories e.g. AdafruitGFX, OLED etc.
  • #8 18492123
    vieleicht
    Level 37  
    JanuszKornas wrote:
    1. I don't know how in the I2C scanner I would indicate that the SDA/SCL is on such and such port, I have searched and not figured out how to do this. If anyone knows, for sport I would be happy to know.
    .

    You can use the I2C Scanner to check the addresses of the devices that are on the bus, but of course they must already be properly integrated into it.
  • ADVERTISEMENT
  • #9 18503329
    xeank
    Level 2  
    There are also modules on sale with the ESP8266EX chip ( to be distinguished from ESP8266MOD ). They are sold commercially as: "ESP8266 NodeMCU v3 Wifi 2.4Ghz CH340". For interfacing the OLED display with the SSD1306 controller, set the pins: #define SCL D3 , #define SDA D5 ,// Initialize the OLED display using Wire library. SSD1306 display(0x3c, SDA, SCL);. Under the arduino we then select the board: "LOLIN(WEMOS) D1 mini PRO".
    An example program after modification should look like this:
    /**
    * The MIT License (MIT).
    *
    * Copyright (c) 2016 by Daniel Eichhorn
    *
    * Permission is hereby granted, free of charge, to any person obtaining a copy
    * of this software and associated documentation files (the "Software"), to deal
    * in the Software without restriction, including without limitation the rights
    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    * copies of the Software, and to permit persons to whom the Software is
    * furnished to do so, subject to the following conditions:
    *
    * The above copyright notice and this permission notice shall be included in all
    * copies or substantial portions of the Software.
    *
    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    * SOFTWARE.
    *
    */

    // Include the correct display library
    // For a connection via I2C using Wire include
    #include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
    #include "SSD1306.h" // alias for `#include "SSD1306Wire.h"`.
    // or #include "SH1106.h" alias for `#include "SH1106Wire.h"`.
    // For a connection via I2C using brzo_i2c (must be installed) include
    // #include <brzo_i2c.h> // Only needed for Arduino 1.6.5 and earlier
    // #include "SSD1306Brzo.h"
    // #include "SH1106Brzo.h"
    // For a connection via SPI include
    // #include <SPI.h> // Only needed for Arduino 1.6.5 and earlier
    // #include "SSD1306Spi.h"
    // #include "SH1106SPi.h"

    // Include custom images
    // #include "images.h"

    // Initialize the OLED display using SPI
    // D5 -> CLK
    // D7 -> MOSI (DOUT)
    // D0 -> RES
    // D2 -> DC
    // D8 -> CS
    // SSD1306Spi display(D0, D2, D8);
    // or
    // SH1106Spi display(D0, D2);

    // Initialize the OLED display using brzo_i2c
    // D3 -> SDA
    // D5 -> SCL
    // SSD1306Brzo display(0x3c, D3, D5);
    // or
    // SH1106Brzo display(0x3c, D3, D5);
    // D3 -> SCL
    // D5 -> SDA
    #define SCL D3
    #define SDA D5
    // Initialize the OLED display using Wire library
    SSD1306 display(0x3c, SDA, SCL);
    // SH1106 display(0x3c, D3, D5);


    #define DEMO_DURATION 3000
    typedef void(*Demo)(void);

    int demoMode = 0;
    int counter = 1;

    void setup() {
    Serial.begin(115200);
    Serial.println();
    Serial.println("ok");


    // Initialising the UI will initiate the display too.
    display.init();

    display.flipScreenVertically();
    display.setFont(ArialMT_Plain_10);

    }

    void drawFontFaceDemo() {
    // Font Demo1
    // create more fonts at http://oleddisplay.squix.ch/
    display.setTextAlignment(TEXT_ALIGN_LEFT);
    display.setFont(ArialMT_Plain_10);
    display.drawString(0, 0, "Hello world");
    display.setFont(ArialMT_Plain_16);
    display.drawString(0, 10, "Hello world");
    display.setFont(ArialMT_Plain_24);
    display.drawString(0, 26, "Hello world");
    }

    void drawTextFlowDemo() {
    display.setFont(ArialMT_Plain_10);
    display.setTextAlignment(TEXT_ALIGN_LEFT);
    display.drawStringMaxWidth(0, 0, 128,
    "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore." );
    }

    void drawTextAlignmentDemo() {
    // Text alignment demo
    display.setFont(ArialMT_Plain_10);

    // The coordinates define the left starting point of the text
    display.setTextAlignment(TEXT_ALIGN_LEFT);
    display.drawString(0, 10, "Left aligned (0,10)");

    // The coordinates define the center of the text
    display.setTextAlignment(TEXT_ALIGN_CENTER);
    display.drawString(64, 22, "Center aligned (64,22)");

    // The coordinates define the right end of the text
    display.setTextAlignment(TEXT_ALIGN_RIGHT);
    display.drawString(128, 33, "Right aligned (128,33)");
    }

    void drawRectDemo() {
    // Draw a pixel at given position
    for (int i = 0; i < 10; i++) {
    display.setPixel(i, i);
    display.setPixel(10 - i, i);
    }
    display.drawRect(12, 12, 20, 20);

    // Fill the rectangle
    display.fillRect(14, 14, 17, 17);

    // Draw a line horizontally
    display.drawHorizontalLine(0, 40, 20);

    // Draw a line horizontally
    display.drawVerticalLine(40, 0, 20);
    }

    void drawCircleDemo() {
    for (int i=1; i < 8; i++) {
    display.setColor(WHITE);
    display.drawCircle(32, 32, i*3);
    if (i % 2 == 0) {
    display.setColor(BLACK);
    }
    display.fillCircle(96, 32, 32 - i* 3);
    }
    }

    void drawProgressBarDemo() {
    int progress = (counter / 5) % 100;
    // draw the progress bar
    display.drawProgressBar(0, 32, 120, 10, progress);

    // draw the percentage as String
    display.setTextAlignment(TEXT_ALIGN_CENTER);
    display.drawString(64, 15, String(progress) + "%");
    }

    void drawImageDemo() {
    // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html
    // on how to create xbm files
    // display.drawXbm(34, 14, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits);
    }

    Demo demos[] = {drawFontFaceDemo, drawTextFlowDemo, drawTextAlignmentDemo, drawRectDemo, drawCircleDemo, drawProgressBarDemo, drawImageDemo};
    int demoLength = (sizeof(demos) / sizeof(Demo));
    long timeSinceLastModeSwitch = 0;

    void loop() {
    // clear the display
    display.clear();
    // draw the current demo method
    demos[demoMode]();

    display.setTextAlignment(TEXT_ALIGN_RIGHT);
    display.drawString(10, 128, String(millis()));
    // write the buffer to the display
    display.display();

    if (millis() - timeSinceLastModeSwitch > DEMO_DURATION) {
    demoMode = (demoMode + 1) % demoLength;
    timeSinceLastModeSwitch = millis();
    }
    counter++;
    delay(10);
    }
  • #10 18503479
    khoam
    Level 42  
    xeank wrote:
    There are also modules on sale with the ESP8266EX chip ( to be distinguished from ESP8266MOD )
    .
    The difference between the ESP8266EX and the ESP8266MOD is that the former is manufactured by Espressif and the latter is, or rather was, manufactured by AI-Thinker. Functionally there is no difference.

    xeank wrote:
    In the trade they are sold as: "ESP8266 NodeMCU v3 Wifi 2.4Ghz CH340". For interfacing the OLED display with the SSD1306 controller, set the pins: #define SCL D3 , #define SDA D5 ,// Initialize the OLED display using Wire library. SSD1306 display(0x3c, SDA, SCL);
    .
    On the ESP8266, the pins for I2C are set by software. They may or may not take default values, depending on which pins the display is connected to. This has nothing to do with the "type" of ESP8266.
  • #11 18504962
    JanuszKornas
    Level 11  
    My ArduinoIDE does not ingest D1, D2, D3 etc.... I had to manually add the appropriate definitions to use D1, D2.... How do you guys make it elegant so that I don't have to type it in manually? Maybe I have something not installed in my environment that something is not being incorporated?
  • #12 18505226
    khoam
    Level 42  
    JanuszKornas wrote:
    My ArduinoIDE does not ingest D1, D2, D3 and
    .
    Enumeration in the style of D1, D2 etc is optional and only applies to some of the board variants with ESP8266. IMHO it is better to use the natural GPIO numbering rather than this additional numbering. What board variant do you have selected in the Arduino IDE?
  • #13 18505647
    JanuszKornas
    Level 11  
    I have the "Generic ESP8266 Module" set up. Most of the examples I have looked at use D1....
  • ADVERTISEMENT
  • #14 18506161
    khoam
    Level 42  
    JanuszKornas wrote:
    I have "Generic ESP8266 Module" set up.
    .
    D1, D2, etc. are not defined in this board variant.

    JanuszKornas wrote:
    Most of the examples I have looked at use D1...
    .
    I regret this too ;) You can always take a look at the following link and see what's behind these Dx.
    https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/
    The unstated Dx designations are ambiguous and different for plate variants. It is really better to rely on the native GPIOx designation. At the link below are the pins_arduino.h files for various boards with ESP8266. Among other things, these files contain the Dx definitions.
    https://github.com/esp8266/Arduino/tree/master/variants
  • #15 19110455
    Aimeiz
    Level 16  
    Hi.
    I have two esp8266 modules with integrated 128x32 OLED displays.
    The board out of the bag has the wifi scanner program pre-loaded and it works seamlessly.
    Unfortunately I am having problems using other programs.
    I have tried different libraries, used in different examples:
    Adafruit_GFX with Adafruit_SSD1306
    OLED.h
    SSD1306Wire.h

    Seemingly everything works, but the display goes out after a few seconds or so and you have to reset or even turn it on and off.
    Unfortunately I don't see an ESP8266 OLED board in the board set, so I tried Generic, ESP-12E, same effect.
    I can't find anywhere the source of this program, the wifi scanner that was preloaded, because there it worked without problems and after loading other programs still the same problem.

    I thought the programs were hanging up - stack overflow etc, but when the program has communication via serial, it works all the time, only the display goes out.
    I use SDA and SCL in the display declarations - it works, but the problem with going out is there.

    Any ideas?
  • #16 19110628
    khoam
    Level 42  
    Aimeiz wrote:
    I have two esp8266 modules with integrated 128x32 OLED displays.
    .
    Which module is it specifically? There are several variants on the market.
  • #17 19134406
    Aimeiz
    Level 16  
    Hi.
    Bought two modules on Ebay last year.
    It is called:
    "ESP8266 Nodemcu WIFI Chip 0.91 inch OLED Display Screen CP2104 Board For Arduino".
    Dark coloured board. There are versions with a white board.
    Both behave in the same way. Original preloaded code - wifiscan works fine, so the module may work properly.
    OLED examples from the available libraries, both Adafruit and others available through the library manager behave similarly.
    The display either displays nothing or only for a short time and goes out.
    Nowhere could I find information about the library used in the preloaded program.
  • #18 19134566
    khoam
    Level 42  
    Aimeiz wrote:
    Nowhere could I find information about the library used in the factory loaded program.

    Link .

Topic summary

The discussion revolves around the operation of the ESP-12F OLED display integrated with the NodeMCU using the Arduino IDE. The user initially faced challenges in finding a compatible library for the OLED display, which is identified as an SSD1306 with a resolution of 128x64. Various responses suggested checking the I2C address, using specific pin configurations (D1 for SDA and D2 for SCL), and utilizing example codes from the manufacturer. The user encountered issues with library compatibility and pin definitions, leading to confusion over the correct GPIO numbering. Solutions included modifying the Wire.begin() function and using native GPIO numbering instead of D1/D2 designations. Additional users reported similar issues with different OLED sizes and libraries, emphasizing the importance of correct pin assignments and library usage for successful display operation.
Summary generated by the language model.
ADVERTISEMENT