#include <SoftwareSerial.h>

#define DEBUG true

SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 3, make TX Arduino line is pin 2.

void setup() {

    Serial.begin(9600);
    esp8266.begin(115200);
    
    sendData("AT+RST\r\n",2000,DEBUG); // reset module
    sendData("AT\r\n",2000,DEBUG); // reset module
    sendData("AT+CWMODE=1\r\n",2000,DEBUG); // configure as Wireless Station mode
    sendData("AT+CWJAP=\"Wokwi-GUEST\",\"\"\r\n", 6000, DEBUG); //Put Your SSID and password if activate as Station mode else comment down the line

}

void loop() {

    char payload[500];
    
    int v1 = analogRead(A0);
    int v2 = analogRead(A1);
    int v3 = analogRead(A2);
    int v4 = analogRead(A3);

    sprintf(payload,"AT+HTTPCLIENT=2,0,\"http://dweet.io/dweet/for/nome_dispositivo?A0=%d&A1=%d&A2=%d&A3=%d\",\"api.thingspeak.com\",\"/update?api_key=9Y72RW98SUEQXB1G&field1=%d&field2=%d&field3=%d&field4=%d\",1\r\n",v1,v2,v3,v4);

    sendData(payload,2000,DEBUG);

    delay(5000);

}

void sendData(String command, const int timeout, boolean debug)  {
    
    esp8266.print(command); // send the read character to the esp8266
    long int time = millis();

    while( (time+timeout) > millis()) {
      while(esp8266.available()) {
        Serial.write(esp8266.read());
      }  
    }
}
Loading
esp-01