im having an error with my code

This is my code

#include <ESP8266WiFi.h>;


#include <ThingSpeak.h>;

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//Define variables for the LCD

#define I2C_ADDR          0x27        //Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN      3
#define En_pin             2
#define Rw_pin             1
#define Rs_pin             0
#define D4_pin             4
#define D5_pin             5
#define D6_pin             6
#define D7_pin             7







#define TRIGGER 0
#define ECHO    2
// NodeMCU Pin d3 > TRIGGER | Pin d4 > ECHO

const char* ssid = "Eric"; //Your Network SSID

const char* password = "1234554321"; //Your Network Password

int val;

//int LDRpin = A0; //LDR Pin Connected at A0 Pin



WiFiClient client;

unsigned long myChannelNumber =  842412; //Your Channel Number (Without Brackets)

const char * myWriteAPIKey = "SPEC45UHZ1QY37D9"; //Your Write API Key

void setup()

{
  
lcd.begin(16,2);  
  
  
  

Serial.begin(115200);



  pinMode(TRIGGER, OUTPUT);
  pinMode(ECHO, INPUT);
  //pinMode(BUILTIN_LED, OUTPUT);

delay(10);

// Connect to WiFi network


 WiFi.begin(ssid, password);
}


ThingSpeak.begin(client);

}



void loop()

{
  
  
  long duration, distance;
  digitalWrite(TRIGGER, LOW);  
  delayMicroseconds(2); 
  
  digitalWrite(TRIGGER, HIGH);
  delayMicroseconds(10); 
  
  digitalWrite(TRIGGER, LOW);
  duration = pulseIn(ECHO, HIGH);
distance= duration*0.034/2;
 long level = 34 -  distance;
Serial.print(distance);
  Serial.println("Centimeter:");
 
  Serial.print(level);
  Serial.println("Centimeter:");
  delay(1000);

//val = analogRead(LDRpin); //Read Analog values and Store in val variable

//Serial.print(distance); //Print on Serial Monitor

lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("Dam Lev: "); // Prints string "Distance" on the LCD
lcd.print(level); // Prints the distance value from the sensor
lcd.print(" cm ");
delay(10);
lcd.setCursor(0,1);
lcd.print("Danger Lev:");
lcd.print("15");
lcd.print(" cm");
delay(10);




delay(1000);

ThingSpeak.writeField(myChannelNumber, 1,level, myWriteAPIKey); //Update in ThingSpeak



delay(100);

And im getting this error message. Please help

Arduino: 1.8.9 (Windows 8.1), Board: "Generic ESP8266 Module, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

ultra_25_jul_cppy2__test3_checking_lc_and_ultra_working_eric3:80:1: error: 'ThingSpeak' does not name a type

 ThingSpeak.begin(client);

 ^

ultra_25_jul_cppy2__test3_checking_lc_and_ultra_working_eric3:82:1: error: expected declaration before '}' token

 }

 ^

exit status 1
'ThingSpeak' does not name a type

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I know nothing about the ThingSpeak.h library, but it doesn't look like you've instantiated an object of the ThingSpeak class. You probably should, and don't give it the same name as the class.

Does that library come with any example code. Have you tried it? Have you compared the example code against your code?

Very similar topic here

If you use AutoFormat (Ctrl-T) you will see that you have ended setup() early so that error line is not within any function and that ain’t allowed. Probably all those useless blank lines in your code make it harder for you to see your mistake.

Steve

gfvalvo:
I know nothing about the ThingSpeak.h library, but it doesn't look like you've instantiated an object of the ThingSpeak class. You probably should, and don't give it the same name as the class.

Does that library come with any example code. Have you tried it? Have you compared the example code against your code?

OK, looking here: thingspeak-arduino/src at master · mathworks/thingspeak-arduino · GitHub
I see that the library does indeed define a default object of the ThingSpeakClass class for you. So, start by fixing the problem that @slipstick pointed out.