Nokia or oled on nodemcu - hardware connections

Posted on
Page
of 2
/ 2
Next
  • Has anyone managed to use the esp8266 to drive a graphics display?

    I'm confused on how the nodemcu.D? pin outs correspond to the sp1 labeled on the board, and which pins are free to use - I know that nodemcu.D4 is the serial debug, so pins D5 upwards are ok, but unsure on how these map.

    A fritzing diagram or similar would be appreciated!

    So far I have:

    SPI1.setup({ sck:NodeMCU.D8, mosi:NodeMCU.D7 });
    
    var g = require("PCD8544").connect(SPI1, NodeMCU.D7 /*DC*/, NodeMCU.D8 /*CE*/, NodeMCU.D9 /*RST*/, function() {
      g.clear();
      g.drawString("Hello",0,0);
      g.drawLine(0,10,84,10);
      g.flip();
    });
    
     RST   Brown  D9?
     CE    red    D8?
     DC    orange D7
     DIN   yellow D6  MOSI  
     CLK   green  D5  
     VCC   blue   +
     LIGHT purple  GND
     GND   grey    GND
    

    Thanks

  • Honestly, I'd ignore the hardware SPI, and go straight for software - then you can use whatever pins you want:

    var s = new SPI();
    s.setup({ sck:NodeMCU.D8, mosi:NodeMCU.D7 });
    var g = require("PCD8544").connect(s, ...);
    
  • Thanks. I have that a go - however still a blank screen. I'm unsure in the nodemcu board the upper tx and rd are D8 and D9.

    I might have to pull the one wire and led stuff I have on lower pins and try that next.

  • Hm, I remember having problems using software SPI - nothing seemed to work, but I didn't have the scope on hand to figure out what was going on.

    What's wrong with using hardware SPI?

  • Hardware SPI on ESP8266 is a huge copy/paste hack that ignores all the pin assignments, and sets up all the SPI registers and blocks for every single byte sent. As a result you might feel better, but realistically it's actually going to be less efficient than just using software.

    Software really should work - I guess a while back there were issues with the internal pinMode calls not working sometimes (due to pinStateIsManual not being reset) that might have tripped you up, but that's been fixed for ages.

  • I've had it working. This is the code I used for a Nokia 5110 aka the PCD8544

    SPI1.setup({ sck:NodeMCU.D5, mosi:NodeMCU.D7 });
    var g = require("PCD8544").connect(SPI1, NodeMCU.D2 /* RS / DC */, NodeMCU.D8 /* CS / CE */, NodeMCU.D1 /*RST*/, function() {
      g.clear();
      g.setRotation(2); //Flip display 180
      g.drawString("Hello",0,0);
      g.drawLine(0,10,84,10);
      g.flip();
    });
    
    Display		NodeMCU		ESP-12
    
    LED         3V3			3V3
    SCLCK       D5			GPIO14
    DN<MOSI>    D7			GPIO13
    D/C         D2			GPIO04
    RST         D1			GPIO05
    SCE         D8			GPIO15
    GND         GND			GND
    VCC         3V3			3V3
    
  • I've also had it working with an I2C OLED, the SSD1306, here's that code:

    function draw(){
      g.clear();
      g.drawString("Hello World",0,0);
      g.flip();
    }
    
    I2C1.setup({scl:NodeMCU.D4,sda:NodeMCU.D3});
    var g = require("SSD1306").connect(I2C1, draw);
    
    Display     NodeMCU     ESP-12
    
    SCL			D4			GPIO2
    SDA			D3			GPIO0
    GND         GND         GND
    VCC         3V3         3V3
    

    These should probably be put on some wiki somewhere.

  • Thanks @Ducky - I'll give your pin assignments a go.

  • @Ducky some OLED need a reset before init, so add another pin to your table for RST.

  • i have that error in console when use last @Ducky code

    Uncaught ReferenceError: "Graphics" is not defined
     at line 1 col 20
    k(c);var g=Graphics.createArrayBuffer(128,f[4]+1,1,{vertical...
                       ^
    in function "connect" called from line 1 col 40
    var g = require("SSD1306").connect(I2C1);
                                           ^
    =undefined
    

    how can I fix it?

  • Your firmware version is out of date and does not have the graphics module built it. Update the firmware.

  • I can't upload new firmware by

    ./wiflash 192.168.1.9 espruino_esp8266_user1.bin espruino_esp8266_user2.bin
    

    I've got terminal error

    Error retrieving http://192.168.1.9/flash/next
    
  • it needs the port:

    ./wiflash 192.168.1.9:88 espruino_esp8266_user1.bin espruino_esp8266_user2.bin

  • thank you @Wilberforce it works on esp-12E,
    but can't run it on NodeMCU Lolin

  • For the wiflash to work - the device has to be connected to the network and will have it's own ip address. Did you check the address the Lolin was getting?

    You could try using the serial flash.

  • I still have same error in console, even after sucessful firmware upgrade by ./wiflash

    Uncaught ReferenceError: "Graphics" is not defined
     at line 1 col 20
    k(c);var g=Graphics.createArrayBuffer(128,f[4]+1,1,{vertical...
                       ^
    in function "connect" called from line 1 col 40
    var g = require("SSD1306").connect(I2C1);
                                           ^
    =undefined
    

    I've been trying to upload this code

    pinMode(NodeMCU.D3,'input_pullup');
    pinMode(NodeMCU.D4,'input_pullup');
    
    function draw(){
      g.clear();
      g.drawString("Hello World",0,0);
      g.flip();
    }
    I2C1.setup({scl:NodeMCU.D4,sda:NodeMCU.D3});
    var g = require("SSD1306").connect(I2C1);
    

    I deal with another NodeMcu, before I tried with Lolin board and now with CP2101 chip, but still can't connect OLED

  • What is the output of
    process.env and process.memory()

  • @bigplik You need the latest binaries with Graphics support in them. Download the latest release and use wiflash to flash them to the ESP8266.

    Just to add, if you're on Windows I believe if you install Git, and select "Use Git and optional Unix tools from the windows command prompt", you can run wiflash (Inside the download zip in the ESP8266 Folder) on windows with "sh wiflash" instead of "./wiflash" just remember to change the IP but keep the port number (":88"). Would be awesome if that was added to the docs page.

  • Will do. Shouldn't wiflash be renamed to wiflash.sh? Also, I just want to double check that "sh" does the same thing as "./" on Linux.

  • @ducky

    @tve has pushed a patch through that adds .sh to wiflash - the current git hub version has it, so v1.86 will have this

  • Sweet, I'll do a pull request to update the Docs in preparation

  • Is this only applicable to ESP-12 ? Because i try connect I2C SSD1306 on ESP-01 (1MB version, Espruino v1.91), console show error: "Graphics" is not defined.

  • I think the graphics module was removed from recent esp8266 builds as the firmware got too large to fit.

    @MaBe might have a recent build with graphics defined.

  • Hi @user72844

    check this build and follow the instruction in README_flash.txt to flash your ESP with this build.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Nokia or oled on nodemcu - hardware connections

Posted by Avatar for Wilberforce @Wilberforce

Actions