Arduino, esp-01 and display 16x2

Hi.

I’m making this project in which I use an arduino, esp-01 module to connect to the internet, and a 16x2 display to show the result of some requests i make over the net.

I’ve tested the module esp-01 , it works, i’m making requests and get answers back.
I’ve tested the display, it works, i can show messages.

The problem is that when i try to combine all 3,i upload my sketch but i’m getting something like
“reset code 3, boot mode (1, 7)”, but if i disconnect the display, i can upload it(after resetting the esp01), and it works.

The display was tested using arduino uno board from arduino ide, and the esp with the esp generic module.

Any idea what is happening? and how could i fix an issue like this ?

Thx

Without a schematic of your connections and the code that you are having trouble with, it is difficult to offer a solution.

I’ve uploaded the shematic and this is how i initialise the resources in code :

#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <LiquidCrystal.h>  

const int Contrast=100;
const char* ssid = ".....";
const char* password = "......";
const char* host = "......";
const int httpsPort = 443;


WiFiClientSecure client;
LiquidCrystal lcd(12, 11, 8, 6, 5, 3); 


void setup() {

  //set the contrast on display
  analogWrite(8, Contrast);
  lcd.begin(16,2); 

  Serial.begin(115200);
  Serial.println("Starting");

 //do wifi code and get requests
.....

}


void loop () {
  
  lcd.setCursor(0,0);
  Serial.println("Starting");
  delay(500);
}

14eaecf39072631c60b970cde57745888670311f.png

How to post images.

I assume that the posted code is uploaded to the Uno? The wiring of the LCD in the schematic does not match the constructor in the code.

Serial.println("Starting");

That is being sent to the ESP?

And I am concerned that there is no level shifter in the Uno TX to ESP RX line.

groundFungus:
I assume that the posted code is uploaded to the Uno? The wiring of the LCD in the schematic does not match the constructor in the code.

Serial.println("Starting");

That is being sent to the ESP?

And I am concerned that there is no level shifter in the Uno TX to ESP RX line.

I changed the constructor (my bad), but still doing the same.
After i upload the code, i open the monitor and it says this

ets Jan  8 2013,rst cause:4, boot mode:(1,6)

wdt reset"

You probably got a stack trace with that as well.
Install the ESP exception decoder to the Arduino IDE to decode what it says, at times there’s useful information to be found there.

A “wdt reset” means the device is stuck - but it being stuck may be both the cause or the result of the error.

you combined an Arduino sketch with an esp sketch?

Juraj:
you combined an Arduino sketch with an esp sketch?

Being someone that uses Arduino libraries all the time on the ESP8266 I can tell that's normally not an issue.

but the display is connected to Arduino :slight_smile:

Reset cause 4 is a wdt reset. So something in your program is stuck.
Most likely there's an error in your ESP code - and it's almost certainly in the parts you didn't post.

Here is a test sketch for an ESP8266 and Uno to illustrate software serial between the 2 and display the data sent by the ESP to the Uno on a LCD. Tested and prints the data from ESP to LCD connected to Uno. Not perfect but should work for testing the hardware and as a basis for future code. NOTE: change the LCD constructor and software serial pins as necessary.

The Uno code.

#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
SoftwareSerial esp(8, 9);

char inputBuffer[17]; // one LCD line + NULL
int strIndex = 0;

void setup()
{
  Serial.begin(115200);
  esp.begin(38400);
  lcd.begin(16, 2);
  lcd.print("LCD  UP");
  delay(2000);
}


void loop()
{
  if (esp.available())
  {
    char c = esp.read();
    if (c != '\n')
    {
      Serial.print(c);
      inputBuffer[strIndex] = c;
      strIndex++;
      inputBuffer[strIndex] = '\0';
    }
    else
    {
      Serial.println();
      lcd.clear();
      lcd.print(inputBuffer);
      strIndex = 0;
      inputBuffer[strIndex] = '\0';
    }
  }
}

The ESP code:

void setup()
{
  Serial.begin(38400);
}

void loop()
{
  static unsigned long timer = 0;
  unsigned long interval = 1000;
  static unsigned int index = 0;
  if (millis() - timer >= interval)
  {    
    timer = millis();
    Serial.print("The index ");
    Serial.println(index);
    index++;
  }
}

The circuit:

ESP-UNO TEST.jpg

wvmarle:
Reset cause 4 is a wdt reset. So something in your program is stuck.
Most likely there's an error in your ESP code - and it's almost certainly in the parts you didn't post.

void setup() {

  analogWrite(8, Contrast);
  lcd.begin(16,2);
  
  Serial.begin(115200);
  Serial.println("Starting");

}



void loop () {
  
  lcd.setCursor(0,0);
  lcd.print("ghfgh");
       delay(500);

  Serial.println("Starting");

  
}

I removed my code, and only left this inside and it still doesn't work. Running on esp8266 generic board. It's the same error as above

Juraj:
you combined an Arduino sketch with an esp sketch?

Can't i do that ?

wvmarle:
You probably got a stack trace with that as well.
Install the ESP exception decoder to the Arduino IDE to decode what it says, at times there's useful information to be found there.

A "wdt reset" means the device is stuck - but it being stuck may be both the cause or the result of the error.

I will try it, thx.

again: the LCD is not connected to esp8266

Juraj:
again: the LCD is not connected to esp8266

well, of course it's not. I don't think i can do that.

groundFungus:
Here is a test sketch for an ESP8266 and Uno to illustrate software serial between the 2 and display the data sent by the ESP to the Uno on a LCD. Tested and prints the data from ESP to LCD connected to Uno. Not perfect but should work for testing the hardware and as a basis for future code. NOTE: change the LCD constructor and software serial pins as necessary.

The Uno code.

#include <LiquidCrystal.h>

#include <SoftwareSerial.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
SoftwareSerial esp(8, 9);

char inputBuffer[17]; // one LCD line + NULL
int strIndex = 0;

void setup()
{
  Serial.begin(115200);
  esp.begin(38400);
  lcd.begin(16, 2);
  lcd.print(“LCD  UP”);
  delay(2000);
}

void loop()
{
  if (esp.available())
  {
    char c = esp.read();
    if (c != ‘\n’)
    {
      Serial.print(c);
      inputBuffer[strIndex] = c;
      strIndex++;
      inputBuffer[strIndex] = ‘\0’;
    }
    else
    {
      Serial.println();
      lcd.clear();
      lcd.print(inputBuffer);
      strIndex = 0;
      inputBuffer[strIndex] = ‘\0’;
    }
  }
}




The ESP code:



void setup()
{
  Serial.begin(38400);
}

void loop()
{
  static unsigned long timer = 0;
  unsigned long interval = 1000;
  static unsigned int index = 0;
  if (millis() - timer >= interval)
  {   
    timer = millis();
    Serial.print("The index ");
    Serial.println(index);
    index++;
  }
}




The circuit:

![ESP-UNO TEST.jpg|1500x1328](upload://3ftX4DFS6hOi0VtPb8m3GS6jybs.jpeg)

Tell me if i what i think is right.

So i take the esp code, i upload it while the esp is on, after that i disconnect the esp, i upload the code of the display on the arduino, then i connect the esp back ?

That is how I did it and that’s what you will need to do unless you set up a software serial port on the ESP to talk to the Uno and upload via Serial. But does the ESP8266-01 have enough pins? I have an FTDI connected to the ESP. Vcc, ground, RX and TX of the FTDi to the ESP. Upload the code to the ESP. Disconnect the FTDI TX and RX. Use just the FTDI Vcc and ground to power the ESP. Connect the Uno software serial RX and TX to the TX and RX of the ESP with Uno TX through the voltage divider to ESP RX.

JarAfmat:
well, of course it's not. I don't think i can do that.

but than you can't wonder that the esp8266 sketch stops while trying to communicate with the LCD

JarAfmat:

void setup() {

analogWrite(8, Contrast);
  lcd.begin(16,2);
 
  Serial.begin(115200);
  Serial.println("Starting");

}

void loop () {
 
  lcd.setCursor(0,0);
  lcd.print("ghfgh");
      delay(500);

Serial.println("Starting");

}




I removed my code, and only left this inside and it still doesn't work. Running on esp8266 generic board. It's the same error as above

Is that code (which again is a snippet - it misses not only essential includes and variable contrast is not declared) running on the Arduino or on the ESP8266? If the latter, what is that lcd code doing there? If on the Arduino, where's the offending code?

wvmarle:
Is that code (which again is a snippet - it misses not only essential includes and variable contrast is not declared) running on the Arduino or on the ESP8266? If the latter, what is that lcd code doing there? If on the Arduino, where's the offending code?

Please read the first posts of tis thread. Above i just completed what i said earlier. And about the esp and display, i thought the esp sends the data to the arduino, and the arduino will display it. I didn't think that the esp module it's something on it's own. But i understand now thanks to groundFungus. I guess.

I will try to do it that way , maybe I will succeed. I will come back with an answer in a couples of hours.

I read them all and that's where the confusion comes from.

You talk about a crashing ESP01, with the LCD connected to the Arduino. Now when we ask for the offending code you only provide partial code, claiming it runs on the ESP01 but it has LCD code in it, while you say the LCD is not connected to the ESP01 but to the Arduino!

Maybe the problem is indeed in the connections, hope you can get it work. But I also hope you understand the confusion you cause by posting contradicting information (and of course incomplete code is useless), and that this wastes our time.