-->
Page 1 of 2

Using a sh1106 OLED on NodeMCU

PostPosted: Tue Oct 13, 2015 1:30 pm
by Rolland Jones
I tried the dev and master NodeMCU builds on frightanic but none of the builds support the sh1106.
Strange because the dev branch states the u8g.sh1106_128x64_i2c() is among a few other.

-- setup I2c and connect display
function init_i2c_display()
-- SDA and SCL can be assigned freely to available GPIOs
local sda = 3 -- GPIO0
local scl = 4 -- GPIO2
local sla = 0x3c
i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g.sh1106_128x64_i2c(sla) -- This line causes the error.
end

Display.lua:8: attempt to call field 'sh1106_128x64_i2c' (a nil value)
stack traceback:
Display.lua:8: in function 'init_i2c_display'
Display.lua:145: in main chunk
[C]: in function 'dofile'
stdin:1: in main chunk

I didn't know I was buying an sh1106 instead of the popular SSH1306.
Thanks for your help.
Rolland

Re: Using a sh1106 OLED on NodeMCU

PostPosted: Fri Dec 04, 2015 5:28 am
by Moey
Hey,
I got that same problem. On documentation it says

I2C Display Drivers
u8g.sh1106_128x64_i2c() -- Only in dev branch


So I went to http://nodemcu-build.com/ and created an image from dev-tree. But I'm still getting a

Code: Select allattempt to call field 'sh1106_128x64_i2c' (a nil value)


I also checked out the dev-tree on github and didn't come up with any file related to the sh1106-controller :cry: Is this the right repository to look into? https://github.com/nodemcu/nodemcu-firm ... app/u8glib

Checked double I have firmware from dev-branch running:
Code: Select allNodeMCU custom build by frightanic.com
        branch: dev
        commit: f9400fdd35899298940ae90123bc297a6448c9da
        SSL: false
        modules: node,file,gpio,wifi,net,i2c,tmr,uart,bit,u8g
 build  built on: 2015-12-04 09:21
 powered by Lua 5.1.4 on SDK 1.4.0


Any help would be appreciated!

Re: Using a sh1106 OLED on NodeMCU

PostPosted: Mon Dec 07, 2015 5:01 pm
by Moey
Ok,
so I already looked into the right place, but the routine for the SH1106-controller is commented out in the source. So to make it work I had to bite the bullet and set up the esp-open-sdk, and check out the code from dev-branch of nodemcu:
Code: Select allgit clone -b dev https://github.com/nodemcu/nodemcu-firmware.git


From here it's pretty straigt forward. Adjust your nodemcu-firmware/app/include/user_modules.h to suit your needs and enable u8g as well as i2c.

Next step go into nodemcu-firmware/app/include/u8g_config.h and add the following line so it looks like my example:
Code: Select all#define U8G_DISPLAY_TABLE_I2C                           \
    U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_i2c)         \
    U8G_DISPLAY_TABLE_ENTRY(sh1106_128x64_i2c)          \


Don't forget the '\' at the end of the line. Now you can compile the whole thing. If you wish to get an Integer-firmware instead of Float, compile with make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL".

Last step I had to do, was to concatenate the two output-files (0x00000.bin and 0x10000.bin) so I got one single file:
Code: Select allsrec_cat -output nodemcu_float.bin -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000

I tried to flash them individually but the controller wouldn't come up after that.

I've also uploaded the ready to run image to my webspace in case you need it. It has the follwing modules enabled:
Code: Select all#define LUA_USE_MODULES_BIT
#define LUA_USE_MODULES_FILE
#define LUA_USE_MODULES_GPIO
#define LUA_USE_MODULES_I2C
#define LUA_USE_MODULES_NET
#define LUA_USE_MODULES_NODE
#define LUA_USE_MODULES_TMR
#define LUA_USE_MODULES_U8G
#define LUA_USE_MODULES_UART
#define LUA_USE_MODULES_WIFI


Here's the link: http://thinksilicon.de/data/elektronik/ ... nteger.bin

I hope this is of help for anyone else who'd like to use a display with SH1103-controller. ;)

Re: Using a sh1106 OLED on NodeMCU

PostPosted: Tue Dec 29, 2015 8:42 am
by Moey
Just in case you're interested. Tinkered a little Wifi-enabled thermometer with the ESP and the oled-display, since it's working perfectly now. It's written in German, but google translate should be doing a decent job translating it:

http://thinksilicon.de/77/Ein-WLAN-Thermometer.html