بنده دارم يك وب سرور داخلي با esp32 براي راه اندازي سنسور adxl345 درست مي كنم و در زماني كه ران ميكنم اين خطا ها رو مي دهد. در ضمن كد رو به همراه خطا قرار مي دهم.
#include <WiFi.h>
#include <WebServer.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
#include <Wire.h>
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified();
#include <NTPClient.h>
#include <WiFiUdp.h>
//#define DHTPin 2
//#define DHTTYPE DHT22
//DHT dht(DHTPin, DHTTYPE);
WiFiUDP ntpUDP;
const long utcOffsetInSeconds = 28800;
NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds);
unsigned long epochTime = timeClient.getEpochTime();
struct tm *ptm = gmtime ((time_t *)&epochTime);
const char* ssid = "Rm";
const char* password = "R262m262k";
WebServer server(80); // Object of WebServer(HTTP port, 80 is defult)
String SendHTML(float TemperatureWeb,float HumidityWeb, String TimeWeb, String DateWeb);
void handle_OnConnect();
void handle_NotFound();
//float shetab;
String formattedTime;
float a;
String Date;
int Day;
int Month;
int Year;
void setup() {
Serial.begin(115200);
//pinMode(DHTPin, INPUT);
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("");
Serial.println("Connected to WiFi");
Serial.print("IP: "); Serial.println(WiFi.localIP());
server.on("/", handle_OnConnect);
server.onNotFound(handle_NotFound);
server.begin();
// dht.begin();
timeClient.begin();
if(!accel.begin())
{
Serial.println("No valid sensor found");
while(1);
}
/* Set the range to whatever is appropriate for your project */
accel.setRange(ADXL345_RANGE_16_G);
//accel.setRange(ADXL345_RANGE_8_G);
// accel.setRange(ADXL345_RANGE_4_G);
// accel.setRange(ADXL345_RANGE_2_G);
}
void loop() {
server.handleClient();
}
void handle_OnConnect() {
timeClient.update();
unsigned long epochTime = timeClient.getEpochTime();
String formattedTime = timeClient.getFormattedTime();
struct tm *ptm = gmtime ((time_t *)&epochTime);
int monthDay = ptm->tm_mday;
int currentMonth = ptm->tm_mon+1;
int currentYear = ptm->tm_year+1900;
formattedTime = timeClient.getFormattedTime();
Date = String(currentYear) + "-" + String(currentMonth) + "-" + String(monthDay);
sensors_event_t event;
accel.getEvent(&event);
// Serial.print("X= ");
//Serial.print(event.acceleration.x);
// Serial.print(" ");
// Serial.print(",");
//Serial.print("Y= ");
//Serial.print(event.acceleration.y);
// Serial.print(" ");
//Serial.print(",");
//Serial.print("Z= ");
Serial.println(event.acceleration.z);
//Serial.print(" ");
a=event.acceleration.z;
//Serial.println("m/s^2 ");
delay(20);
//shetab = dht.readTemperature();
//Humidity = dht.readHumidity();
server.send(200, "text/html", SendHTML(a,formattedTime,Date));
}
void handle_NotFound(){
server.send(404, "text/plain", "Not found");
}
String SendHTML(float a, String TimeWeb,String DateWeb){
String ptr = "<!DOCTYPE html> <html>\n";
ptr +="<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
ptr +="<title>ESP32 Global Server</title>\n";
ptr +="</head>\n";
ptr +="<body>\n";
ptr +="<div id=\"webpage\">\n";
ptr +="<h1>ES32 Global Server</h1>\n";
ptr +="<p>Date: ";
ptr +=(String)DateWeb;
ptr +="</p>";
ptr +="<p>Time: ";
ptr +=(String)TimeWeb;
ptr +="</p>";
ptr +="<p>a: ";
//ptr +=(int)TemperatureWeb;
ptr +="C</p>";
//ptr +="<p>Humidity: ";
// ptr +=(int)HumidityWeb;
ptr +="%</p>";
ptr +="</div>\n";
ptr +="</body>\n";
ptr +="</html>\n";
return ptr;
}
//////////////////////////////////////////////////////////////////////خطاها
Sketch uses 746186 bytes (56%) of program storage space. Maximum is 1310720 bytes.
Global variables use 40000 bytes (12%) of dynamic memory, leaving 287680 bytes for local variables. Maximum is 327680 bytes.
esptool.py v3.0-dev
Serial port COM10
Traceback (most recent call last):
File "esptool.py", line 3682, in <module>
File "esptool.py", line 3675, in _main
File "esptool.py", line 3329, in main
File "esptool.py", line 263, in __init__
File "site-packages\serial\__init__.py", line 88, in serial_for_url
File "site-packages\serial\serialwin32.py", line 62, in open
serial.serialutil.SerialException: could not open port 'COM10': WindowsError(5, 'Access is denied.')
Failed to execute script esptool
Failed uploading: uploading error: exit status 0xffffffff