wemos lolin esp32 oled ssd1306

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
exider
Posts: 8
Joined: Sat Jul 29, 2017 2:02 am

wemos lolin esp32 oled ssd1306

Post by exider » Sat Jul 29, 2017 2:48 am

Hi all,

Just got a new chinese clone of lolin wemos 32 with integrated oled ssd1306 display.
The board is flashed with the latest firmware (esp32-20170729-v1.9.1-391-g06168c92.bin ), and i am trying to work out an examle taken from this web page :
http://www.instructables.com/id/MicroPy ... ated-SSD1/

If i try to import the ssd1306 module i get an error 1st time ,but 2nd time it imports it correctly with no errors(i have tried importing all libraries i could have found.
for exaple this one .. https://github.com/adafruit/Adafruit_Ci ... /tag/1.0.2
if iscan i2c bus , ican see the display

>>>i2c = machine.I2C(scl=machine.Pin(4), sda=machine.Pin(5))
>>>i2c.scan()
[60]
Also the display works with arduino samples.

The problem comes when i try to use it:

>>>oled = ssd1306.SSD1306_I2C(128, 64, i2c) # --> at this point i get an error saying:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SSD1306_I2C'
>>>

I would appreciate any help you guys can provide!

Thanks

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: wemos lolin esp32 oled ssd1306

Post by deshipu » Sat Jul 29, 2017 9:24 am

What is the error you get when you try to import it?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: wemos lolin esp32 oled ssd1306

Post by pythoncoder » Sat Jul 29, 2017 9:41 am

Why are you using an Adafruit library? I'd use the official MicroPython one: drivers/display/ssd1306.py. I haven't tested it on ESP32 but it works on the Pyboard and ESP8266.
Peter Hinch
Index to my micropython libraries.

exider
Posts: 8
Joined: Sat Jul 29, 2017 2:02 am

Re: wemos lolin esp32 oled ssd1306

Post by exider » Sat Jul 29, 2017 6:53 pm

[quote="deshipu"]What is the error you get when you try to import it?[/quote]

Hi deshipu, thank you for asking. Your question helped me to figure out the problem. The indentation was messed up on the last line. Now I have to figure out how did that happen or which IDE did that as I didn't edit, just looked at the code and it obviously happened to all libraries I've tried. I am new to python, and as the code got imported second time I've tried, I tought the problem is somewhere else. Anyway, thank you guys for looking into this and help resolving the issue.

[code]
ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0008,len:8
load:0x3fff0010,len:3408
load:0x40078000,len:9488
load:0x40080000,len:252
entry 0x40080034
I (1393) cpu_start: Pro cpu up.
I (1393) cpu_start: Single core mode
I (1395) heap_init: Initializing. RAM available for dynamic allocation:
I (1406) heap_init: At 3FFAE2A0 len 00001D60 (7 KiB): DRAM
I (1425) heap_init: At 3FFD4FD8 len 0000B028 (44 KiB): DRAM
I (1444) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (1464) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1484) heap_init: At 400920A0 len 0000DF60 (55 KiB): IRAM
I (1503) cpu_start: Pro cpu start user code
I (1563) cpu_start: Starting scheduler on PRO CPU.
main.py: Hello
MicroPython v1.9.1-391-g06168c92 on 2017-07-29; ESP32 module with ESP32
Type "help()" for more information.
>>> import ssd1306
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ssd1306.py", line 161, in <module>
NameError: name 'self' is not defined
>>> import ssd1306
>>> import machine
[/code]

Post Reply