遇到了这几个错误需要更改那一部分程序才能顺利运行?
C:\Users\99270\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\Wire\Wire.cpp:38:2: error: #error Wire library is not supported on this board
38 | #error Wire library is not supported on this board
| ^~~~~
C:\Users\99270\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\Wire\Wire.cpp:56:30: error: 'SDA' was not declared in this scope
56 | static int default_sda_pin = SDA;
| ^~~
C:\Users\99270\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\Wire\Wire.cpp:57:30: error: 'SCL' was not declared in this scope; did you mean 'SCK'?
57 | static int default_scl_pin = SCL;
| ^~~
| SCK
exit status 1
Compilation error: exit status 1
以下是程序:
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
// 传感器引脚定义
const int pressureSensorPin = A0;
const int temperatureSensorPin = A0;
// WiFi设置
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// 创建一个Web服务器实例
ESP8266WebServer server(80);
// 读取压力传感器数据
int readPressureSensor() {
int pressureValue = analogRead(pressureSensorPin);
return pressureValue;
}
// 读取温度传感器数据
float readTemperatureSensor() {
int temperatureValue = analogRead(temperatureSensorPin);
float temperature = (temperatureValue * 3.3 / 1023.0 - 0.5) * 100; // 转换为摄氏度
return temperature;
}
// 处理网页请求
void handleRoot() {
String html = "<html><body>";
html += "<h1>实时呼吸频率和体温监测</h1>";
html += "<p>呼吸频率: " + String(readPressureSensor()) + "</p>";
html += "<p>体温: " + String(readTemperatureSensor()) + " ℃</p>";
html += "</body></html>";
server.send(200, "text/html", html);
}
void setup() {
// 初始化串口通信
Serial.begin(115200);
// 初始化压力传感器和温度传感器引脚
pinMode(pressureSensorPin, INPUT);
pinMode(temperatureSensorPin, INPUT);
// 连接WiFi
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
// 设置网页请求处理函数
server.on("/", handleRoot);
// 启动服务器
server.begin();
Serial.println("HTTP server started");
}
void loop() {
// 处理客户端请求
server.handleClient();
}