Esp32 serial1 problem

i try to communicate with GSM module via serial1 (txd1 rxd1)

when i run this code i dont get the replay i just see

GSM_replay:

so i dont see anything from

Serial.println(cmd);


int test(){
  error_ms=millis();
  Serial1.println("AT");
  
  while (true) {//wait for replay
    if (Serial1.available() > 0) {
      String cmd = Serial1.readString();
      Serial.print("GSM_replay:");
      Serial.println(cmd);

      if (cmd.startsWith(replay_cmd)) {
        return 1;
      }
    }

    if (millis() - error_ms > 10000) {  
      return 0;
    }

  }
}

The code is incomplete, it does not compile.

We need to see all the code because we can't guess what you've typed (e.g. I saw you delete a trim_msg() function call in the code snippet you show us).

Regards

code is big and is for other things also, i try to write here simple so i can show just problem

example if device replay

OK

+QMTOPEN: 0,0

i see just

GSM_replay:
GSM_replay:OK

i never get the
> +QMTOPEN: 0,0

So you don't have a communication problem, you have a code problem.

Good luck!

1 Like

good luck

Without enough information I cannot solve the problem. I would guess you do not have an annotated schematic either. Without the needed information Good Luck!

Post an MRE. This is the smallest, complete code that compiles and demonstrates the issue at hand.

One possibility is that the GSM is replying, but the conditions of your read are not correct so the program doesn't receive it. If there isn't one already put a led (and resistor) on the gsm->esp line.

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