Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use HELTEC WiFi Kit 32 #112

Open
mikekgr opened this issue Apr 29, 2018 · 46 comments
Open

How to use HELTEC WiFi Kit 32 #112

mikekgr opened this issue Apr 29, 2018 · 46 comments

Comments

@mikekgr
Copy link

mikekgr commented Apr 29, 2018

Dear Sirs,
I tried but unsuccessfully to work the HELTEC WiFi Kit 32 dev board with the ESP32-Radio.
For your info, the attached pdf shows all the pins of this dev board, also the occupied pins regarding the I2C OLED ( that now supported in the ESP32-Radio thanks to Mr. @Edzelf with his recent inclusion ).
If someone of you have this dev board working, or can suggest me what to do please send me a note.
All of my tries has always continious reset to ESP32...
Thanks and Best Regards,
Mike Kranidis
HELTEC WIFI_Kit_32-Diagram.pdf

@Edzelf
Copy link
Owner

Edzelf commented Apr 29, 2018

First, try to run the radio software without anything attached (or configured) to the Heltec board. If it does not crash, add the VS1063 and finally the OLED. Remember to first run radio-init, so you can check the WIFi.

@mikekgr
Copy link
Author

mikekgr commented Apr 29, 2018

Dear @Edzelf ,
what I already tried is to put the correct I2C pins OLED_scl=15, OLED_sda=4, OLED_rst=16.
I successfully compiled then the "main" ino file ESP32_radio.ino and then I did power on/off to the HELTEC dev board. Looking at the serial port, it started and after a few seconds do reset again and again.
I am not sure regarding your suggestion: " Remember to first run radio-init, so you can check the WIFi. ".
What is that?
Again thanks and Best Regards,
Mike Kranidis

I run first: Esp32_radio_init.ino but it did not helps. See:

D: Starting ESP32-radio running on CPU 1 at 240 MHz. Version Wed, 25 Apr 2018 14:45:00 GMT. Free memory 171084
D: Partition nvs found, 20480 bytes
D: Read 31 keys from NVS
D: pin_ir set to -1
D: pin_enc_clk set to -1
D: pin_enc_dt set to -1
D: pin_enc_sw set to -1
D: pin_tft_cs set to -1
D: pin_tft_dc set to -1
D: pin_tft_scl set to 15
D: pin_tft_sda set to 4
D: pin_sd_cs set to -1
D: pin_vs_cs set to 5
D: pin_vs_dcs set to 17
D: pin_vs_dreq set to 4
D: pin_shutdown set to -1
D: pin_spi_sck set to 18
D: pin_spi_miso set to 19
D: pin_spi_mosi set to 23
D: GPIO0 is HIGH
D: GPIO2 is HIGH
D: GPIO4 is HIGH
D: GPIO5 is HIGH
D: GPIO12 is HIGH
D: GPIO13 is HIGH
D: GPIO14 is HIGH
D: GPIO15 is HIGH
D: GPIO16 is HIGH
D: GPIO17 is HIGH
D: GPIO18 is HIGH
D: GPIO19 is HIGH
D: GPIO21 is HIGH
D: GPIO22 is HIGH
D: GPIO23 is HIGH
D: GPIO25 is HIGH
D: GPIO26 is HIGH
D: GPIO27 is HIGH
D: GPIO32 is HIGH
D: GPIO33 is HIGH
D: GPIO34 is LOW, probably no PULL-UP
D: GPIO35 is LOW, probably no PULL-UP
D: gpio_00 will execute uppreset = 1
D: gpio_12 will execute upvolume = 2
D: gpio_13 will execute downvolume = 2
D: Start display
D: Init TFT 4 15
D: Create list with acceptable WiFi networks
Guru Meditation Error: Core 1 panic'ed (LoadProhibited)
. Exception was unhandled.
Core 1 register dump:
PC : 0x4008c90d PS : 0x00060033 A0 : 0x4008dd93 A1 : 0x3ffd6b30
A2 : 0x00050023 A3 : 0x00000001 A4 : 0x3ffc8a74 A5 : 0x3ffc8c34
A6 : 0x00000001 A7 : 0x3ffc8c68 A8 : 0x00000016 A9 : 0x00000002
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x3ffc8c34 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000001 SAR : 0x00000013 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000048 LBEG : 0x40001609 LEND : 0x4000160d LCOUNT : 0x00000000

Backtrace: 0x4008c90d:0x3ffd6b30 0x4008dd90:0x3ffd6b50 0x4008dd46:0x4008bc90

Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_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:1
load:0x3fff0018,len:4
load:0x3fff001c,len:812
load:0x40078000,len:0
load:0x40078000,len:11572
entry 0x40078a5c

D: Starting ESP32-radio running on CPU 1 at 240 MHz. Version Wed, 25 Apr 2018 14:45:00 GMT. Free memory 171084
D: Partition nvs found, 20480 bytes
D: Read 31 keys from NVS
D: pin_ir set to -1
D: pin_enc_clk set to -1
D: pin_enc_dt set to -1
D: pin_enc_sw set to -1
D: pin_tft_cs set to -1
D: pin_tft_dc set to -1
D: pin_tft_scl set to 15
D: pin_tft_sda set to 4
D: pin_sd_cs set to -1
D: pin_vs_cs set to 5
D: pin_vs_dcs set to 17
D: pin_vs_dreq set to 4
D: pin_shutdown set to -1
D: pin_spi_sck set to 18
D: pin_spi_miso set to 19
D: pin_spi_mosi set to 23
D: GPIO0 is HIGH
D: GPIO2 is HIGH
D: GPIO4 is HIGH
D: GPIO5 is HIGH
D: GPIO12 is HIGH
D: GPIO13 is HIGH
D: GPIO14 is HIGH
D: GPIO15 is HIGH
D: GPIO16 is HIGH
D: GPIO17 is HIGH
D: GPIO18 is LOW, probably no PULL-UP
D: GPIO19 is HIGH
D: GPIO21 is HIGH
D: GPIO22 is HIGH
D: GPIO23 is LOW, probably no PULL-UP
D: GPIO25 is HIGH
D: GPIO26 is HIGH
D: GPIO27 is HIGH
D: GPIO32 is HIGH
D: GPIO33 is HIGH
D: GPIO34 is LOW, probably no PULL-UP
D: GPIO35 is LOW, probably no PULL-UP
D: gpio_00 will execute uppreset = 1
D: gpio_12 will execute upvolume = 2
D: gpio_13 will execute downvolume = 2
D: Start display
D: Init TFT 4 15
D: Create list with acceptable WiFi networks
Guru Meditation Error: Core 1 panic'ed (LoadProhibited)
. Exception was unhandled.
Core 1 register dump:
PC : 0x4008c90d PS : 0x00060033 A0 : 0x4008dd93 A1 : 0x3ffd6b30
A2 : 0x00050023 A3 : 0x00000001 A4 : 0x3ffc8a74 A5 : 0x3ffc8c34
A6 : 0x00000001 A7 : 0x3ffc8c68 A8 : 0x00000016 A9 : 0x00000002
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x3ffc8c34 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000001 SAR : 0x00000013 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000048 LBEG : 0x40001609 LEND : 0x4000160d LCOUNT : 0x00000000

Backtrace: 0x4008c90d:0x3ffd6b30 0x4008dd90:0x3ffd6b50 0x4008dd46:0x4008bc90

Rebooting...

@Edzelf
Copy link
Owner

Edzelf commented Apr 30, 2018

For radio_init see the documentation: "An extra sketch "Esp32_radio_init" is supplied as an alternative to initialize the preferences (in Non-Voltile Storage of the ESP32). Just change lines 39 and 40 (the specs for WiFi networks) to match your network(s).
Upload and run the sketch once and then load the ESP32-Radio."

@Edzelf
Copy link
Owner

Edzelf commented Apr 30, 2018

I also have a Heltec board. I tried it now and it keeps rebooting. I will see what's wronfg with this board.

@mikekgr
Copy link
Author

mikekgr commented Apr 30, 2018

Dear @Edzelf ,
yes I did, I fount Esp32_radio_init.ino inside the subdirectory tools and I loaded to Arduino IDE. Then after changed the lines 39,40:
preferences.putString ( "wifi_00", "myHomeWiFi/12345678" ) | preferences.putString ( "wifi_01", "SecondWiFi/12345678" ) |
I compiled and sent to ESP32. At the serial I took "ESP32_radio_init completed...".
Then I loaded the Esp32_radio.ino to Arduino IDE and the result is above, keep resetting...
Thanks

@Edzelf
Copy link
Owner

Edzelf commented Apr 30, 2018

The program crashed when no IR was configured. I have made a correction in the new version.

@mikekgr
Copy link
Author

mikekgr commented Apr 30, 2018

Thanks a lot dear @Edzelf for your fast responce and the bug fixing!
I will try it when at home.
Have a nice day.

@mikekgr
Copy link
Author

mikekgr commented Apr 30, 2018

Dear @Edzelf ,
I have the HELTEC board with me so I can tested in my workplace and I did.
I discovered that If I change the "default" display from BLUETFT to OLED then I still get the "always restarting and crashing". If I leave your default BLUETFT then it is starting without problems but without OLED of course.
Please check if you can.
Thanks

//#define BLUETFT                      // Works also for RED TFT 128x160
#define OLED                         // 64x128 I2C OLED

@Edzelf
Copy link
Owner

Edzelf commented Apr 30, 2018

I could not reproduce that. I made a small correction. The display will work now without VS1063.

@mikekgr
Copy link
Author

mikekgr commented Apr 30, 2018

Sorry something wrong in my browser cache, ignore it
dear @Edzelf making the diff between your latest Esp32_radio.ino and the Esp32_radio.ino that was 5 days ago I found them 100% the same. Can you check and make sure that the today changes has been uploaded to github? Thanks

@Edzelf
Copy link
Owner

Edzelf commented Apr 30, 2018

Yeah, wrong directory

@mikekgr
Copy link
Author

mikekgr commented Apr 30, 2018

Dear @Edzelf ,
yes it is working now. To help somebody looking the same, to have OLED activated in ESP32-Radio using HELTEC WiFi Kit 32 { ESP32 }, the following changes should be done to Esp32_radio.ino file:

/// change / correct the next two lines 2380, 2381
    { "pin_tft_scl",  &ini_block.tft_scl_pin,     15          },   // Display I2C version /// by mikek ///
    { "pin_tft_sda",  &ini_block.tft_sda_pin,     4          },   // Display I2C version /// by mikek ///

The only small glitch remained and that is: the OLED does not show correctly the last (?) line, I see only some pixels, but this is trivial.

Thanks a lot Mr. @Edzelf for your help and your fantastic work in ESP32-Radio !!!

@Edzelf
Copy link
Owner

Edzelf commented Apr 30, 2018

Last line on OLED: must be a long text line in the lower section. Try to change the volume, this will paint the last pixel line of the display.
And try to run th OLED without using pin 16. I don't think the OLED needs a reset.

@mikekgr
Copy link
Author

mikekgr commented Apr 30, 2018

Dear @Edzelf Pin 16 must be High in order to get OLED up and running. if you don't initialize then OLED is off.

@Edzelf
Copy link
Owner

Edzelf commented Apr 30, 2018

Yes, I understand. But 16 will be pulled to high by the software. I think it is not necessary to pulse it low for reset.

@mikekgr
Copy link
Author

mikekgr commented Apr 30, 2018

I agree with you. The temporary low is just for reset as you already told. The only question left: Do you have any provision to pull up GPIO 16 High? Because, before I put it in setup section, the OLED was not started.
Thanks.

@mikekgr
Copy link
Author

mikekgr commented Apr 30, 2018

Dear @Edzelf I am not sure how to connect VS1053 to HELTEC Dev board. Can you suggesting me the pin to pin connections?
Thanks.

@Edzelf
Copy link
Owner

Edzelf commented Apr 30, 2018

As I said: Gpio 16 is pulled up by the software. All unused pins are pulled HIGH. You will see it in the debug logging: "D:GPIO16 is HIGH".

@mikekgr
Copy link
Author

mikekgr commented Apr 30, 2018

Yes you are right, I can confirm @Edzelf that the lines I put at void setup to set GPIO 16 not needed. Thanks

@Edzelf
Copy link
Owner

Edzelf commented May 1, 2018

To connect the VS1053 to the Heltec board, you may us someting like:

// Heltec   Signal  Wired to OLED       Wired to VS1053      SDCARD   Wired to the rest
// -------- ------  --------------      -------------------  ------   ---------------
// GPIO16           Reset               -                     -       -
// GPIO5            -                   pin 2 XCS             -       -
// GPIO4            SDA                 -                     -       -
// GPIO2            -                   pin 4 DREQ            -       -
// GPIO17           -                   -                     CS      -
// GPIO18   SCK     -                   pin 5 SCK             CLK     -
// GPIO19   MISO    -                   pin 7 MISO            MISO    -
// GPIO23   MOSI    -                   pin 6 MOSI            MOSI    -
// GPIO15           SCL                 -                     -       -
// GPI03    RXD0    -                   -                     -       Reserved serial input
// GPIO1    TXD0    -                   -                     -       Reserved serial output
// GPIO34   -       -                   pin 1 XDCS            -       Optional pull-up resistor
// GPIO35   -       -                   -                     -       Infrared receiver VS1838B
// GPIO25   -       -                   -                     -       Rotary encoder CLK
// GPIO26   -       -                   -                     -       Rotary encoder DT
// GPIO27   -       -                   -                     -       Rotary encoder SW
// -------  ------  ---------------     -------------------  ------   ----------------
// GND      -       pin 8 GND           pin 8 GND                     Power supply GND
// VCC 5 V  -       pin 7 BL            -                             Power supply
// VCC 5 V  -       pin 6 VCC           pin 9 5V                      Power supply
// EN       -       pin 1 RST           pin 3 XRST                    -

@mikekgr
Copy link
Author

mikekgr commented May 1, 2018

Dear @Edzelf
My VS1053 has the following pinout:

VS1053 Module
Pin.1 +5V
Pin.2 GND
Pin.3 CS
Pin.4 MISO
Pin.5 MOSI
Pin.6 SCK
Pin.7 XCS
Pin.8 XRESET
Pin.9 XDCS
Pin.10 DEREQ

following your proposed pinout I have two questions,

  1. What signal is your designated signal ( at HELTEC side ) EN that is connected with XRST of VS1053? My HELTEC board does not have it. I presume that you speak for XRESET as it been referenced to my VS1053 board
  2. My VS1053 board has also CS. Where to connect ( if any ) ?

Thanks a lot

@Edzelf
Copy link
Owner

Edzelf commented May 1, 2018

1 - RST on your Heltec board is the same as EN.
2 - CS is probably for the SD card, so you can use GPIO17 for this.

@mikekgr
Copy link
Author

mikekgr commented May 1, 2018

Dear @Edzelf Many thanks. It is working fine now!

@FrankBoesing
Copy link

FrankBoesing commented Oct 16, 2020

I had to insert a manual OLED reset to make the display work:

SSD1306.h, first lines of constructor:

//Reset OLED
pinMode(16, OUTPUT);
digitalWrite(16, LOW);
delay(50);
digitalWrite(16, HIGH);
delay(50);

@timo619
Copy link

timo619 commented Apr 24, 2022

Hi, I have an Heltec ESP32 WiFi Lora Board https://www.fambach.net/esp32-wifi-lora-433/. Therefore the pin layout is different. I have a working PCM5102A and a rotary encoder connected to it.

The OLED display is not working yet.

Before configuring the GPIO I have the error:
E (942333) i2c: i2c_set_pin(860): scl and sda gpio numbers are the same

After adding the OLED GPIO (SCL: 15 and SDA: 4) I get the following error (audio and encoder still works), but not OLED display:

D: pin_enc_clk set to 17
D: pin_enc_dt set to 22
D: pin_enc_sw set to 2
D: pin_tft_scl set to 15
D: pin_tft_sda set to 4
D: pin_i2s_bck set to 25
D: pin_i2s_lck set to 14
D: pin_i2s_din set to 27
D: pin_spi_sck set to 18
D: pin_spi_miso set to 19
D: pin_spi_mosi set to 23
D: GPIO0 is HIGH
D: GPIO2 is HIGH
D: GPIO4 is HIGH
D: GPIO5 is HIGH
D: GPIO12 is HIGH
D: GPIO13 is HIGH
D: GPIO14 is HIGH
D: GPIO15 is HIGH
D: GPIO16 is HIGH
D: GPIO17 is LOW, probably no PULL-UP
D: GPIO18 is HIGH
D: GPIO19 is HIGH
D: GPIO21 is HIGH
D: GPIO22 is LOW, probably no PULL-UP
D: GPIO23 is HIGH
D: GPIO25 is HIGH
D: GPIO26 is LOW, probably no PULL-UP
D: GPIO27 is HIGH
D: GPIO32 is LOW, probably no PULL-UP
D: GPIO33 is LOW, probably no PULL-UP
D: GPIO34 is LOW, probably no PULL-UP
D: GPIO35 is LOW, probably no PULL-UP
D: GPIO39 is LOW, probabl���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

Any suggestion where the problem comes from? (tested the display and gpios with Adafruit GFX library)

@timo619
Copy link

timo619 commented Apr 29, 2022

The cause is a problem with the Wire.cpp and ESP32 and Platformio. My PlatformIO setup apparently cannot use the Wire.cpp with the ESP32. Simple GFXSketch shows the error: Bus is in Slave Mode. Same GFX script in Arduino IDE causes no problems and OLED works.

Any suggestions which setting/library mismatch causes the error and therefore non-working OLED on Platformio?

@Edzelf
Copy link
Owner

Edzelf commented Apr 30, 2022

Maybe not the cause, but your 3 rotary encoder pins should be high at start-up.

@Edzelf
Copy link
Owner

Edzelf commented Apr 30, 2022

Try to disconnect the display. It may consume too much power for your power supply.
Try version 2 of the radio software.

@timo619
Copy link

timo619 commented Apr 30, 2022

I am testing with a simple code snippet with only i2c scanner + OLED, compiles on both (Arduino IDE and PlatformIO), but only works on the Heltec Dev Board, when compiled on Arduino IDE. Therefore I assume, that the cause has to come from my settings/libraries in PlatformIO.

main.cpp (OLED+i2c works, when compiled with Arduino IDE)

#include "Arduino.h"
#include "heltec.h"

void setup()
{
	Heltec.begin(true, false, true);
	Wire.begin(SDA_OLED, SCL_OLED); //Scan OLED's I2C address via I2C0
	//Wire1.begin(SDA, SCL);        //If there have other device on I2C1, scan the device address via I2C1
}

void loop()
{
	byte error, address;
	int nDevices;

	Serial.println("Scanning...");

	nDevices = 0;
	for(address = 1; address < 127; address++ )
	{
		Wire.beginTransmission(address);
		error = Wire.endTransmission();

//		Wire1.beginTransmission(address);
//		error = Wire1.endTransmission();

		if (error == 0)
		{
			Serial.print("I2C device found at address 0x");
			if (address<16)
			Serial.print("0");
			Serial.print(address,HEX);
			Serial.println("  !");

			nDevices++;
		}
		else if (error==4)
		{
			Serial.print("Unknown error at address 0x");
			if (address<16)
				Serial.print("0");
			Serial.println(address,HEX);
		}
	}
	if (nDevices == 0)
	Serial.println("No I2C devices found\n");
	else
	Serial.println("done\n");

	delay(5000);
}

platformio.ini

[env:heltec_wifi_lora_32_Test2]
platform = espressif32
board = heltec_wifi_lora_32
framework = arduino
monitor_speed = 115200
monitor_flags = 
	--filter=esp32_exception_decoder
	--echo
build_flags = 
	-DCORE_DEBUG_LEVEL=0
	-Os
lib_deps = 
	heltecautomation/Heltec ESP32 Dev-Boards @ ^1.1.0

build output:

Processing heltec_wifi_lora_32_Test2 (platform: espressif32; board: heltec_wifi_lora_32; framework: arduino)
------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/heltec_wifi_lora_32.html
PLATFORM: Espressif 32 (4.2.0) > Heltec WiFi LoRa 32
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 3.20002.0 (2.0.2) 
 - tool-esptoolpy 1.30300.0 (3.3.0) 
 - toolchain-xtensa-esp32 8.4.0+2021r2-patch3
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 44 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Heltec ESP32 Dev-Boards> 1.1.0
|   |-- <SPI> 2.0.0
|   |-- <Wire> 2.0.0
Building in release mode
Retrieving maximum program size .pio/build/heltec_wifi_lora_32_Test2/firmware.elf
Checking size .pio/build/heltec_wifi_lora_32_Test2/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   5.3% (used 17436 bytes from 327680 bytes)
Flash: [==        ]  19.8% (used 259473 bytes from 1310720 bytes)
=========================== [SUCCESS] Took 2.35 seconds ===========================

@timo619
Copy link

timo619 commented May 3, 2022

I am using Version 2 of your script and I could narrow my problem down to the following code line, which is not executed correctly:

oled.cpp in the OLED constructor
i2c_param_config ( I2C_NUM_0, &i2c_config ) ;

Unfortunately my coding knowledge stops there. I also don't see any CLK or DATA on the i2c-lines with my oscilloscope. Which makes sense, since the i2c is not started correctly, in my opinion.

The display works with other libraries with PlatformIO. Therefore:

  • display connected correct
  • enough power supplied
  • i2c is working with other libraries (Wire.h, Adafruit GFX)
  • tested with and without encoder
  • tested with second bus i2c_param_config ( I2C_NUM_1, &i2c_config ) ;
  • tested slower i2c speed: 100000
  • all other functionalities work: i2s (PCM5102A), WLAN, webserver, rotary encoder

Any further tips?

@Edzelf
Copy link
Owner

Edzelf commented May 3, 2022

The I2C address of the OLED is 0x3C. Is that equal to the adress of you OLED?
You have to define OLED1309, OLED1306 or OLED1106 in confog.h.Maybe you can add a simple I2Cscan function in setup().
The SDA and SCL pin numbers are printen in the serial monitor. Are they correct for your set-up?

@timo619
Copy link

timo619 commented May 3, 2022

  • My OLED address is also 0x3C
  • I defined the OLED (#define OLED1306) in config.h (just the one)
  • the pin numbers are printed correct (D: pin_tft_scl set to 15, D: pin_tft_sda set to 4)
  • I cannot establish a i2c connection, since: (i2c_param_config ( I2C_NUM_0, &i2c_config ) ;) is not working
  • therefore I think, that a scanner would not work and additionally I cannot program one
  • the i2c scanner examples Iuesd all use the Wire.h library and with that the OLED is found correctly

@Edzelf
Copy link
Owner

Edzelf commented May 3, 2022

There is a chance that there is output to the display before proper initialization. I will check that.

@Edzelf
Copy link
Owner

Edzelf commented May 4, 2022

I have changed the OLED library. It will now use the Wire library. You also have to replace the main program.
Please test it.

@timo619
Copy link

timo619 commented May 4, 2022

Thank you very much for your effort.
I tested the up-to-date version (v2 / 04May2022) with the Wire library. No errors, but also no signals on the i2c sda and clk lines. Will test it further with i2c scanner the next days. Probably a weird behaviour of the specific heltec esp32 lora oled board.

@Edzelf
Copy link
Owner

Edzelf commented May 5, 2022

There may be a reset pin for the display. Try to pull this high.

@timo619
Copy link

timo619 commented May 5, 2022

SOLVED!
Problem in oled.cpp and oled.h --> the variables sda and scl are probably not in the right format, since when I pass them as int instead of uint8_t the i2c OLED is address correctly. Thank you very much for your work and your tips. Great work with the radio library.

//***********************************************************************************************
//                                O L E D constructor                                           *
//***********************************************************************************************
// Constructor for the display.                                                                 *
//***********************************************************************************************
OLED::OLED ( int sda, int scl )  //<-- changed from uint8_t to int
{
  uint8_t      initbuf[] =                                   // Initial commands to init OLED
                  {
                    OLED_CONTROL_BYTE_CMD_STREAM,            // Stream next bytes
                    OLED_CMD_DISPLAY_OFF,                    // Display off
                    OLED_CMD_SET_DISPLAY_CLK_DIV, 0x80,      // Set divide ratio
                    OLED_CMD_SET_MUX_RATIO, SCREEN_HEIGHT-1, // Set multiplex ration (1:HEIGHT)
                    OLED_CMD_SET_DISPLAY_OFFSET, 0,          // Set diplay offset to 0
                    OLED_CMD_SET_DISPLAY_START_LINE,         // Set start line address
                    OLED_CMD_SET_CHARGE_PUMP, 0x14,          // Enable charge pump
                    OLED_CMD_SET_MEMORY_ADDR_MODE, 0x00,     // Set horizontal addressing mode
                    OLED_CMD_SET_SEGMENT_REMAP,              // Mirror X
                    OLED_CMD_SET_COM_SCAN_MODE,              // Mirror Y
                    OLED_CMD_SET_COM_PIN_MAP, 0x12,          // Set com pins hardware config
                    OLED_CMD_SET_CONTRAST, 0xFF,             // Set contrast
                    OLED_CMD_SET_PRECHARGE, 0xF1,            // Set precharge period
                    OLED_CMD_SET_VCOMH_DESELCT, 0x20,        // Set VCOMH
                    OLED_CMD_DISPLAY_RAM,                    // Output followes RAM
                    OLED_CMD_DISPLAY_NORMAL,                 // Set normal color
                    OLED_CMD_SCROLL_OFF,                     // Stop scrolling
                    OLED_CMD_DISPLAY_ON                      // Display on
                  } ;
  ssdbuf = (page_struct*) malloc ( 8 * sizeof(page_struct) ) ;  // Create buffer for screen
  font = OLEDfont ;
  Wire.begin (sda, scl) ; //, 150000 ) ;                             // Init I2c, only pass int
  Wire.beginTransmission ( OLED_I2C_ADDRESS ) ;                 // Begin transmission
  Wire.write ( initbuf, sizeof(initbuf) ) ;                     // Write init buffer
  Wire.endTransmission() ;                                      // End of transmission
  clear() ;                                                     // Clear the display
}

oled.h (line 64) also int instead of uint8_t


class OLED
{
  public:
    OLED    ( int sda, int scl ) ;            // Constructor  //<-- changed from uint8_t to int
    void      clear() ;                               // Clear buffer
    void      display() ;                             // Display buffer
    void      print ( char c ) ;                      // Print a character
    void      print ( const char* str ) ;             // Print a string
    void      setCursor ( uint8_t x, uint8_t y ) ;    // Position the cursor
    void      fillRect ( uint8_t x, uint8_t y,        // Fill a rectangle
                         uint8_t w, uint8_t h,
                         uint8_t color ) ;
    //void      drawBitmap ( uint8_t x, uint8_t y,      // Bitmap to display buffer
    //                       uint8_t* buf,
    //                       uint8_t w,
    //                       uint8_t h ) ;        
  private:
    struct page_struct*     ssdbuf = NULL ;
    const  uint8_t*         font ;                    // Font to use
    uint8_t                 xchar = 0 ;               // Current cursor position (text)
    uint8_t                 ychar = 0 ;               // Current cursor position (text)
    void                    openI2Cchan() ;           // Open I2C channel
    void                    closeI2Cchan() ;          // Close I2C channel
    void                    wrI2Cchan ( uint8_t b ) ; // Send 1 byte to I2C buffer
} ;

webradio_oled

@Edzelf
Copy link
Owner

Edzelf commented May 5, 2022

Good! But strange.....

@timo619
Copy link

timo619 commented May 10, 2022

I probably found the real cause of the problem:
https://esp32.com/viewtopic.php?t=21030

There was a new item added to the i2c config struct. I had to add the line:

i2c_config.clk_flags = 0 ;

to the constructor. Then the i2c works with your library. Thanks again.

@frycol
Copy link

frycol commented Oct 27, 2022

I probably found the real cause of the problem: https://esp32.com/viewtopic.php?t=21030

There was a new item added to the i2c config struct. I had to add the line:

i2c_config.clk_flags = 0 ;

to the constructor. Then the i2c works with your library. Thanks again.

Can You tell me where exactly you add "i2c_config.clk_flags = 0 ;"

@Codemixer271
Copy link

Hi all,

First of all:
Thanks for your great work.

I´m running into the same problem, display was working before, lost my old source.
Compiled new and the OLED display doesn't work anymore.
In the debug I found this, ongoing with senseless characters:

D: gpio_00 will execute uppreset = 1
D: gpio_12 will execute upvolume = 2
D: gpio_13 will execute downvolume = 2
D: Enable pin ÿþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿ

I changed the code as timo619 described in his post from May 5th but this did not resolve the problem.
Will I have to add the line i2c_config.clk_flags = 0 ; somewhere?
If yes, please tell me where to add it.

Thanks for your help.

@Edzelf
Copy link
Owner

Edzelf commented Dec 10, 2022

A crash like that is usually caused by a weqak power supply.

@Codemixer271
Copy link

Thanks for your answer.
I can exclude a week power supply. (tested the circuit with a laboratory power supply)
The hardware was working for about 2 years without any issue.
The ESP32 got some problems to connect to the network sometimes, so I decided to rebuild the software.
When I build the firmware without a display (activated DUMMYTFT), all is OK.
Building with each one of the OLED options results in this debug, display stays dark, but the radio is working.

Meanwhile I also tried the code on a WEMOS 32, without anything connected and it runs into the same problem.

@Edzelf
Copy link
Owner

Edzelf commented Dec 26, 2022

Could you please try the version 2 of the radio?

@Codemixer271
Copy link

Great !
Was a good Christmas gift.
With V2 it´s running.

Thanks a lot for your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants