HelTec WIFI KIT 32 and MicroPython

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
AlbSan
Posts: 8
Joined: Thu Nov 02, 2017 2:44 am
Location: Shanghai

HelTec WIFI KIT 32 and MicroPython

Post by AlbSan » Thu Nov 02, 2017 3:16 am

Hi guys,
I recent bought one WIFI KIT 32 from chinese HeltTec Automation ( http://www.heltec.cn/index.php/project/wifi_kit_32/ )
It seems well done and robust, integrate a ssd1306 based OLED display (128x64) LiPo chargher, Flash size: 32M-Bits, and it's very cheap! I live in Sahnghai and I paied only 8$ .
I installed micropython (following this guide https://www.instructables.com/id/MicroP ... ated-SSD1/ ) and almost work fine, this is the home screen:

>>> 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:0x3fff0018,len:4
load:0x3fff001c,len:4332
load:0x40078000,len:0
load:0x40078000,len:10992
entry 0x4007a6c4
I (355) cpu_start: Pro cpu up.
I (355) cpu_start: Single core mode
I (356) heap_init: Initializing. RAM available for dynamic allocation:
I (359) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (365) heap_init: At 3FFDCD60 len 000032A0 (12 KiB): DRAM
I (371) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (377) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (384) heap_init: At 4008FC7C len 00010384 (64 KiB): IRAM
I (390) cpu_start: Pro cpu start user code
I (184) cpu_start: Starting scheduler on PRO CPU.
main.py: Hello
MicroPython v1.9.2-443-g236297f4 on 2017-11-01; ESP32 module with ESP32
Type "help()" for more information.

The blink test was good, I2C scan too, But when I try to start the display, I have this error:

>>> import machine, ssd1306
>>> i2c = machine.I2C(scl=machine.Pin(15), sda=machine.Pin(4))
>>> oled = ssd1306.SSD1306_I2C(128, 64, i2c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ssd1306.py", line 117, in __init__
File "ssd1306.py", line 37, in __init__
File "ssd1306.py", line 62, in init_display
File "ssd1306.py", line 122, in write_cmd
OSError: [Errno 19] ENODEV

Can anyone help me?
Thaks
Alberto (Sorry for my poor english ...)

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

Re: HelTec WIFI KIT 32 and MicroPython

Post by pythoncoder » Sun Nov 05, 2017 9:01 am

The SSD1306 driver is evidently failing to communicate with the device, which is puzzling if it showed up with the correct address in an I2C scan.

I'm not sure why Adafruit modified the SSD1306 driver but you might like to try the MicroPython one. This is located here https://github.com/micropython/micropyt ... ssd1306.py. If you try it, please report the outcome.
Peter Hinch
Index to my micropython libraries.

AlbSan
Posts: 8
Joined: Thu Nov 02, 2017 2:44 am
Location: Shanghai

Re: HelTec WIFI KIT 32 and MicroPython

Post by AlbSan » Sun Nov 05, 2017 10:59 am

Thank you for your reply and your help.
Isn't library fault, the labrary works fine, but ...
The embedded display, is mounted on SCL(15) SDA(4), but there is another pin must be considered, the pin 16 is the OLED_RST .
The OLED_RST must be high during normal operations (I putted a LED on pin, to don't forghet it anymore!).
With this code everythings works fine!
import machine
pin16 = machine.Pin(16, machine.Pin.OUT)
pin16.value(1)
import machine, ssd1306
i2c = machine.I2C(scl=machine.Pin(15), sda=machine.Pin(4))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
oled.fill(0)
oled.text('MicroPthonForum:', 0, 0)
oled.show()

I take the opportunity to advise you to play with HelTec board, it's chip and fun :)
Alberto

db4linq
Posts: 1
Joined: Wed Nov 08, 2017 1:20 pm

Re: HelTec WIFI KIT 32 and MicroPython

Post by db4linq » Wed Nov 08, 2017 1:24 pm

from machine import I2C, Pin
import ssd1306

rst = Pin(16, Pin.OUT)
rst.value(1)
scl = Pin(15, Pin.OUT, Pin.PULL_UP)
sda = Pin(4, Pin.OUT, Pin.PULL_UP)
i2c = I2C(scl=scl, sda=sda, freq=450000)
oled = ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3c)

oled.fill(0)
oled.text('ESP32', 45, 5)
oled.text('MicroPython', 20, 20)
oled.show()

work for me :)

AlbSan
Posts: 8
Joined: Thu Nov 02, 2017 2:44 am
Location: Shanghai

Re: HelTec WIFI KIT 32 and MicroPython

Post by AlbSan » Thu Nov 09, 2017 2:22 am

Yes, now everything works fine!
Recently I managed to read data from this devices:
DS3231
SHT31
MS5611 (GY-63 board)
and show they on the display!
I'm really satisfy, and experimentation continues!

PS: I've som problem with WiFi hang, but I'll write on the right forum section.
Alberto

vairamani
Posts: 1
Joined: Wed Oct 24, 2018 6:12 pm

Re: HelTec WIFI KIT 32 and MicroPython

Post by vairamani » Wed Oct 24, 2018 6:18 pm

[quote=db4linq post_id=23063 time=1510147491 user_id=3376]
from machine import I2C, Pin
import ssd1306

rst = Pin(16, Pin.OUT)
rst.value(1)
scl = Pin(15, Pin.OUT, Pin.PULL_UP)
sda = Pin(4, Pin.OUT, Pin.PULL_UP)
i2c = I2C(scl=scl, sda=sda, freq=450000)
oled = ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3c)

oled.fill(0)
oled.text('ESP32', 45, 5)
oled.text('MicroPython', 20, 20)
oled.show()

above code works for me in my heltec lora oled

[/quote]

dahult
Posts: 5
Joined: Mon Feb 27, 2017 5:16 am

Re: HelTec WIFI KIT 32 and MicroPython

Post by dahult » Tue Oct 22, 2019 5:38 pm

Thanks vairamani for your post. I was having trouble getting the display on my Heltec-Esp32-Lora working with Micropython until I saw your post. I don't know how you found this but defining SDA and SCL as Pin.OUT with Pin.PULLUP made the difference for me. I have never had to use software Pin.PULL_UP on i2c lines and didn't not even know you could do that with Pin.OUT. One possible alternative could be to use external 10k resistors to VDD on the SDA and SCL lines, which probably should have been there anyway. Thanks for your post!

tannenba
Posts: 4
Joined: Fri Oct 25, 2019 3:07 am

Re: HelTec WIFI KIT 32 and MicroPython

Post by tannenba » Fri Oct 25, 2019 4:26 pm

I receive the error ImportError: no module named 'ssd1306'

I see the library on github (ssd1306.py) but can't find how to use it.

running upycraft version 1.0
Heltec wifi kit 32 with oled.

Thank you for any help.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: HelTec WIFI KIT 32 and MicroPython

Post by kevinkk525 » Fri Oct 25, 2019 7:00 pm

copy it onto your device.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

tannenba
Posts: 4
Joined: Fri Oct 25, 2019 3:07 am

Re: HelTec WIFI KIT 32 and MicroPython

Post by tannenba » Fri Oct 25, 2019 7:42 pm

Thank you! I knew it would be simple, just too much info out there for a new to this person.
Thanks for the answer.

Post Reply