ESP-01 ESP8266WiFi module Connect to Arduino Mega

Hi All, I am desperately looking for help.
I sent data, mostly "0" and "1" from a ESP32S3 Touch screen to a ESP-01 ESP8266 WIFI Module and then to a Arduino Mega. I can see the data on the Mega Serial.print but no matter what I do it does not run my motors. It seems like there is no connections between the received data and end code.

ESP8266_v2_working_29_11_24.ino (2.4 KB)

MotorTest_29_11_24.ino (4.0 KB)

in loop() you start by reading Serial1 and printing it

void loop() {

    if (Serial1.available()) {
    // Read data from ESP-01S and forward to Serial Monitor
    Serial.write(Serial1.read());
    }

but you don't do anything with the data read

Thanks for the reply, Would you mind to give me an example of how to use it to run the motor please.

Store what you read in a variable and use that variable

void loop()
{
  char ch = 0;
  if (Serial1.available())
  {
    // Read data from ESP-01S
    ch = Serial1.read();
    // and forward to Serial Monitor
    Serial.write(ch);

    // do something with ch here
  }

The data I receive is "Received Value_StringUP: 1" and values "0" when not pressed on transmitter.
Is the following what you mean to do?

void loop()
{
  char Value_StringUP = 0;
  if (Serial1.available())
  {
    // Read data from ESP-01S
    Value_StringUP = Serial1.read();
    // and forward to Serial Monitor
    Serial.write(Value_StringUP);

    // do something with ch here
  }

Kind off

Because you're receiving multiple characters from the other side, I suggest that you study Robin's Serial Input Basics - updated.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.