See bottom for solution.
I am trying to run the Arduino LiquidCrystal library example HelloWorld.ino on an ESP32. It seems like it never even executes the Setup() loop. The ESP resets after eight seconds and then repeats the cycle.
I have used character LCD many times before (with Arduino) but always using I2C. For the current design I am eliminating the I2C to parallel chip and I am instead driving the LCD directly from the ESP32. I am using 4 bit mode to reduce the number of pins required. I have connected Register select, Enable, and D4-D7. These details are not relevant since the ESP32 does not even run with the LiquidCrystal library.
I have looked at the library code and I didn't see anything that I thought would be a problem. But I am a hardware designer (for 36 years) and not a programmer. I use the Arduino IDE because it is quick and easy to test hardware.
The library code can be found here. https://github.com/arduino-libraries/LiquidCrystal/tree/master/src
This is what I get from the serial monitor.
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (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:0x3fff0030,len:1240
load:0x40078000,len:13012
load:0x40080400,len:3648
entry 0x400805f8
ets Jun 8 2016 00:22:57
I tried the example code, and when that didn't work so I added a couple of serial print lines to the code. I am listing that below.
#include <LiquidCrystal.h>
const int rs = 26, en = 25, d4 = 16, d5 = 17, d6 = 18, d7 = 19;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
Serial.begin(115200);
Serial.println("Start");
lcd.begin(16, 2);
lcd.print("hello, world!");
}
void loop() {
delay(1000);
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
Serial.println(millis() / 1000);
}
Details that I didn't list above. I am powering the LCD from 5 volts. The LCD data/control lines are specified as VinLo = 0.55v and VinHi = 2.4 volts. Not that this matters since the code above never executes. I have used a Arduino Nano powered with 3.3 volts, running the above code, to confirm that the display actually works under these conditions. I really want this to work with an ESP32-C3. I tried that originally but switched to the ESP32 because it wasn't working with the code.
I hope someone can provide some guidance here. My other option is not using the library and writing my own code, which ends up being brute force and simplistic.
EDIT:
A big thanks to Majenko who was spot on. After removal of the call the code executed properly.
::init()
.::init()
calls::begin()
.::begin()
uses delays. Those delays may depend on things that aren't configured yet when the constructors are running, and lock up causing a WDT. That library looks to be poorly written TBH. Remove the call tobegin()
in the::init()
function.