Trying to bring my data to thingspeak

im using a elegoo 2560 mega board with a esp-01 wifi. below here i will post my code which works on the arduino and getting data in my serial. how can i bring this data to thingspeak with these hardwares?

const int ledPin = 13; // LED connected to digital pin 13
const int knockSensor = A0; // the piezo is connected to analog pin 0
const int threshold = 10; // threshold value to decide when the detected sound is a knock or not

// these variables will change:
int sensorReading = 0; // variable to store the value read from the sensor pin
int ledState = LOW; // variable used to store the last LED status, to toggle the light

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
Serial.begin(9600); // use the serial port
}

void loop() {
// read the sensor and store it in the variable sensorReading:
sensorReading = analogRead(knockSensor);

// if the sensor reading is greater than the threshold:
if (sensorReading >= threshold) {
// toggle the status of the ledPin:
ledState = !ledState;
// update the LED pin itself:
digitalWrite(ledPin, ledState);
// send the string "Knock!" back to the computer, followed by newline
Serial.println("intruder alert!");
}
delay(100); // delay to avoid overloading the serial port buffer
}

You can post code by using this method that adds the code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

Depending on how much hardware you have connected to your 2560 Mega the easiest way to bring data to thingspeak is to
connect all your sensors, displays buttons etc. to a ESP32nodeMCU
and use the ESP32 as a replacement for your Arduino-mega 2560.

If you have a lot of sensors connected to the arduino mega I would use a serial connection from mega 2560 to an ESP32 node-MCU to transfer the data into the wifi-cabable microcontroller and then programming the wifi-cabable microcontroller to forward the data to thingspeak.

best regards Stefan

so ure saying it wont just work alone with the esp-01 wifi module?

Of course it will work. Google will give you many, many examples:

ill check this up now