-->
Page 1 of 2

SPI OLED Example

PostPosted: Sat Aug 20, 2016 7:09 am
by mfny
Anyone have a working on current build of NodeMCU(Master) example for "Hello World" on a 128x64 SSD1306 based display ?

Re: SPI OLED Example

PostPosted: Sat Aug 20, 2016 5:34 pm
by hkubota
mos has a good one. I bought one of those modules and had a hard time finding a working example. Arduino code is found left and right, but not NodeMCU code.
So I built something from scratch and it was pretty painful.
And then I found out they have a fully working one. Works like a charm.
Uses I2C and not SPI, but the difference is only one initialization call: disp = u8g.ssd1306_64x48_i2c(sla) replace with the corresponding spi call. And you need to set up SPI of course.

http://www.wemos.cc/Products/oled_shield.html

Re: SPI OLED Example

PostPosted: Sun Aug 21, 2016 6:04 pm
by mfny
Cant seem to get this code: http://pastebin.com/2ij55FpR in a file named "app.lua" to work at all, keep getting the following error:

NodeMCU custom build by frightanic.com
branch: dev
commit: 5e01b51123e3bc8344627a23602147de9b01be45
SSL: false
modules: bit,file,gpio,net,node,spi,tmr,u8g,uart,wifi
build built on: 2016-08-21 21:20
powered by Lua 5.1.4 on SDK 1.5.4.1(39cb9a32)
> PANIC: unprotected error in call to Lua API (app.lua:6: attempt to call field 'ssd1306_128x64_spi' (a nil value))

My init.lua looks like this: http://pastebin.com/UNVM3Ypu

Re: SPI OLED Example

PostPosted: Wed Aug 24, 2016 10:33 am
by marcelstoer
mfny wrote:PANIC: unprotected error in call to Lua API (app.lua:6: attempt to call field 'ssd1306_128x64_spi' (a nil value))


ssd1306_128x64_spi references the specific OLED display. Make sure you include the correct driver when you build the firmware. Also, as per https://nodemcu.readthedocs.io/en/dev/e ... ay-drivers it should be u8g.ssd1306_128x64_hw_spi() (note the extra 'hw_').