using esp32 with a gsm/gprs module

Hello everybody; I have been working using the gsm module sim800l with an arduino board for send a data to a database from a website without problems. I've been trying to use the same module with an esp32 board (ESP-WROOM 32) but it hasn't work until now and i dont know how could be the problem.

Here's the code I'm using

//ESP32
#define GSM_TX 17      //To RX pin of SIM800L
#define GSM_RX 16      //To TX pin of SIM800L
#define GSM_RESET 5   

#define STATUS 2


// Set the GPRS Access Point Name (APN) to suit your SIM card.
#define AccessPointName "xxx"
// Set the address of the server where the measurements should be reported.
#define HTTPserver "xxx"
// Set the URL of the program that receives the measurements.
#define HTTPurl "/program2.php?"

// SoftwareSerial GSM_serial(GSM_RX, GSM_TX);
// Note that only GSM_TX is used. GSM_RX is not used.


void setup()
{
  Serial.begin(9600);
  Serial2.begin(9600, SERIAL_8N1, GSM_RX, GSM_TX);
  Serial.println("OK");

  pinMode(GSM_RESET, OUTPUT);
  digitalWrite(GSM_RESET, 1);

  pinMode(STATUS, OUTPUT);
  digitalWrite(STATUS, 0);

  reset_GSM();
}



void loop()  
{
  
    
  char buf[20];
  char buf2[20];

  float d1 = 10;                            // Read data and convert to string "dato=nn.n"
  float d2 = 20;
  dtostrf(d1, 3, 1, buf);
  dtostrf(d2, 3, 1, buf2);
  
  String message = String("dato=");
  message +=buf;
  String message2 = String("dato2=");
  message2 +=buf2;
  
  full_power_GSM();                        // Move to full power mode to get ready to send data.
  message.toCharArray(buf, 20);            // Prepare message.
  message2.toCharArray(buf2, 20);
  HTTPhead(buf, buf2);                           // Report measurement by sending HEAD message to internet URL.
  reset_GSM();                             // Reset SIM800L to prevent unwanted data usage.
  low_power_GSM();                         // SIM800L uses a lot of power if it is left if full power mode.
  delay(10);
}


void connect()
{
  Serial2.print("+++");

  delay(1000);
  Serial2.print("AT\r\n");

  delay(1000);
  Serial2.print("ATE1\r\n"); // Turn on echo, makes it easier to debug the SIM800L

  delay(1000);
  Serial2.print("AT+CGATT=1\r\n");

  delay(1000);
  Serial2.print("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"\r\n");

  delay(1000);
  Serial2.print("AT+SAPBR=3,1,\"APN\",\"");

  Serial2.print(AccessPointName);

  Serial2.print("\"\r\n");

  delay(1000);
  Serial2.print("AT+SAPBR=1,1\r\n");

  delay(3000);
}


void disconnect()
{
  Serial2.print("AT+SAPBR=0,1\r\n");
}


//void HTTPhead(char *message)
void HTTPhead(char *message, char *message2)
{
  digitalWrite(STATUS, 1);
  connect();
  Serial2.print("AT+HTTPINIT\r\n");

  delay(1000);
  Serial2.print("AT+HTTPPARA=\"CID\",1\r\n");

  delay(1000);
  Serial2.print("AT+HTTPPARA=\"URL\",\"");

  Serial2.print(HTTPserver);

  Serial2.print(HTTPurl);

  Serial2.print(message);

  Serial2.print("&");

  Serial2.print(message2);

  Serial2.print("\"\r\n");

  delay(1000);
  Serial2.print("AT+HTTPACTION=2\r\n"); // Request header only, reduces data usage

  delay(3000);
  Serial2.print("AT+HTTPTERM\r\n");

  disconnect();
  digitalWrite(STATUS, 0);
  delay(10000);  // To make function last 1 minute
}


void reset_GSM()
{
  digitalWrite(STATUS, 1);
  digitalWrite(GSM_RESET, 0);
  delay(100);
  digitalWrite(GSM_RESET, 1);
  digitalWrite(STATUS, 0);
  delay(10000);  // To make function last 1 minute
}


void low_power_GSM()
{
  Serial2.print("AT+CFUN=0,1\r\n");
  delay(10000); 
}


void full_power_GSM()
{
  Serial2.print("AT+CFUN=1,1\r\n");
  delay(10000); 
}

I'm using a 4V-2A power source for the module.

I appreciate any suggestion

Which Arduino were you using that had Serial2 ?
Does the ESP32 have a Serial2 ?

.