Error with my WiFi.h in Esp32

Hi,

I have problem compiling ESP32, there’s error showing that wifi.h can’t find , there’s no such file or directory. Complication terminated

The hardware is ESP-WROOM-32 and Ultrasonic Sensor HC-SR04 . I downloaded the Wifi libraries from here GitHub - arduino-libraries/WiFi: WiFi Library for Arduino , then put it in Documents/Arduino/libraries but still it doesn’t work , here’s my code :

#define BLYNK_TEMPLATE_ID         "TMPL67Hu8ObMu"
#define BLYNK_TEMPLATE_NAME "Pengukur Jarak Ultrasonik"
#define  BLYNK_AUTH_TOKEN "a2C5EjBewm-tuaxxxx"
#define BLYNK_PRINT Serial
#include <Wifi.h>
#include <Wifi.Client.h>
#includr <BlynkSimpleEsp.32>

char auth[ ] = BLYNK_AUTH_TOKEN;

char ssid[] = "ELDORA02";
char pass[] = "tanyapakkos";
 
#define trigPin 32
#define echoPin 33
float distance;

void setup()
{
  pinmode(trigPin, OUTPUT);
  pinModeechoPin, INPUT);
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
}

void loop() {
  Blynk.run();
  digitalWrite(trigPin, LOW);
  delaymicroseconds(5);
  digitalWrite(trgPin, HIGH);
  delayMicroseconds(10);
  digitalErite(trigPin, LOW);
  int duration = ulseIn(echoIn, HIGH);
  distance = duration*0.032/2

  Serial.print("Distance = ");
  Serial.print(distance);
  Serial.println("cm");

  Blynk.virtualWrite(V0,distance);
  delay(500);
}

Does anyone know how to solve this?
Thanks In advance

@Yulian125 Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

First of all, you need to undo this…

That library isn’t intended for your hardware, and may cause your compiler to attempt to use the incorrect library.

Which version of the ESP32 core do you have installed?

What board type are you choosing in the IDE when you compile the code?

There is a typo in this line, it should say #include not #includr

Your void loop is also an issue, you need to read this…

Pete.

Thank you for the reply
I have installed esp32 core version 3.0.7 and I am choosing ESP32 dev module board in Boards Manager

here’s the code I create again ,if I did code wrong let me know:

#include <WiFi.h>
#include <BlynkSimpleEsp32.h>

#define BLYNK_TEMPLATE_ID "TMPL67Hu8ObMu"
#define BLYNK_TEMPLATE_NAME "Pengukur Jarak Ultrasonik"
#define BLYNK_AUTH_TOKEN "a2C5EjBewm-tuaxxxx"

#define trigPin 32
#define echoPin 33

char auth[ ] = BLYNK_AUTH_TOKEN;
char ssid[] = "ELDORA02";
char pass[] = "tanyapakkos";

float distance;

BlynkTimer timer;

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);

  // Set up a timer to measure distance every 500ms
  timer.setInterval(500L, sendSensorData);
}

void sendSensorData() {
  long duration;
  
  // Trigger the ultrasonic sensor
  digitalWrite(trigPin, LOW);
  delayMicroseconds(5);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  
  // Measure the duration of the echo
  duration = pulseIn(echoPin, HIGH);
  
  // Calculate the distance
  distance = duration * 0.034 / 2;
  
  // Print to serial monitor
  Serial.print("Distance = ");
  Serial.print(distance);
  Serial.println(" cm");
  
  // Send distance to Blynk
  Blynk.virtualWrite(V0, distance);
}

void loop() {
  Blynk.run();    
  timer.run();    
}

and is there any idea which library should I use for this hardware??
Thanks.

You’re missing the #include <WiFiClient.h>

Can you please share the exact error message that you’re getting? (Copy/paste the text and use triple backticks, don’t post a screenshot).

Pete.

C:\Users\Owner\AppData\Local\Temp\.arduinoIDE-unsaved2024114-5432-1oxw33q.xavp\sketch_dec4\sketch#_dec4c.ino:3:20:fatal error:BlynkSimpleEsp32.h:No.such file or directory

  3 | #include<BlynkSimpleEsp32.h>

     |           ^~~~~~~~~~~~~~~~~~~~~

compilation terminated.

exit status 1



Compilation error:BlynkSimpleEsp32.h:No such file or directory

This error message is nothing to do with WiFi.h

What version of the Blynk C++ library do you have installed?

Pete.

It’s blynk version 1.3.2
Oh I think my issue has been resolved, previously I got an error in Wifi.h in my previous code but after I create again the code according to your suggestion, there was no more error in wifi.h… just an error in BlynkSimpleEsp32.h…
Thanks for the help