@Bethce

Решил сделать метеостанцию, пишу прошивку, как исправить ошибки?

Ошибки
AHT10_Serial_Test:35: error: redefinition of 'void setup()'
   35 | void setup()
      |      ^~~~~
C:\Users\E8E5~1\AppData\Local\Temp\arduino_modified_sketch_21862\AHT10_Serial_Test.ino:16:6: note: 'void setup()' previously defined here
   16 | void setup() {
      |      ^~~~~
C:\Users\E8E5~1\AppData\Local\Temp\arduino_modified_sketch_21862\AHT10_Serial_Test.ino: In function 'void setup()':
AHT10_Serial_Test:40: error: 'ath' was not declared in this scope
   40 |   ath.begin(0x77);
      |   ^~~
AHT10_Serial_Test:41: error: 'bme' was not declared in this scope
   41 |   bme.begin(0x76);
      |   ^~~
C:\Users\E8E5~1\AppData\Local\Temp\arduino_modified_sketch_21862\AHT10_Serial_Test.ino: At global scope:
AHT10_Serial_Test:68: error: redefinition of 'void loop()'
   68 | void loop()
      |      ^~~~
C:\Users\E8E5~1\AppData\Local\Temp\arduino_modified_sketch_21862\AHT10_Serial_Test.ino:26:6: note: 'void loop()' previously defined here
   26 | void loop() {
      |      ^~~~
C:\Users\E8E5~1\AppData\Local\Temp\arduino_modified_sketch_21862\AHT10_Serial_Test.ino: In function 'void handle_OnConnect()':
AHT10_Serial_Test:75: error: 'bme' was not declared in this scope
   75 |   temperature = bme.readTemperature();
      |                 ^~~
AHT10_Serial_Test:77: error: 'SEALEVELPRESSURE_HPA' was not declared in this scope
   77 |   altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
      |                               ^~~~~~~~~~~~~~~~~~~~
AHT10_Serial_Test:78: error: 'ath' was not declared in this scope
   78 |   humidity = ath.readHumidity() / 100.0
      |              ^~~
exit status 1
redefinition of 'void setup()'


Код
#include <Wire.h>
#include <AHT10.h>
#include <ESP8266WebServer.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>

AHT10Class AHT10;
ESP8266WebServer server(80);  

float temperature, humidity, pressure, altitude;

/* Введите SSID и пароль от вашей сети */
const char* ssid = "HUAWEI-3F84";   // SSID
const char* password = "01942527";  // пароль

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Wire.begin();
  if(AHT10.begin(eAHT10Address_Low))
    Serial.println("Init AHT10 Sucess.");
  else
    Serial.println("Init AHT10 Failure.");
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("//Thinary Eletronic AHT10 Module//");
  Serial.println(String("")+"Humidity(%RH):\t\t"+AHT10.GetHumidity()+"%");
  Serial.println(String("")+"Temperature(℃):\t"+AHT10.GetTemperature()+"℃");
  Serial.println(String("")+"Dewpoint(℃):\t\t"+AHT10.GetDewPoint()+"℃");
  delay(500);
}             
 
void setup() 
{
  Serial.begin(9400);
  delay(100);

  ath.begin(0x77);
  bme.begin(0x76);   
  
  if(AHT10.begin(eAHT10Address_Low))
  
  Serial.println("Connecting to ");
  Serial.println(ssid);

  // подключиться к вашей локальной wi-fi сети
  WiFi.begin(ssid, password);

  // проверить, выполнено ли подключение wi-fi сети
  while (WiFi.status() != WL_CONNECTED) 
  {
    delay(1000);
    Serial.print(".");
  }
  Serial.println("...");
  Serial.println("WiFi connected...!");
  Serial.print("Got IP: ");  Serial.println(WiFi.localIP());

  server.on("/", handle_OnConnect);
  server.onNotFound(handle_NotFound);

  server.begin();
  Serial.println("HTTP server started");

}
void loop() 
{
  server.handleClient();
}

void handle_OnConnect() 
{
  temperature = bme.readTemperature();
  pressure = bme.readPressure() / 100.0F;
  altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
  humidity = ath.readHumidity() / 100.0 
  server.send(200, "text/html", SendHTML(temperature,humidity,pressure,altitude)); 
}

void handle_NotFound()
{
  server.send(404, "text/plain", "Not found");
}

String SendHTML(float temperature,float humidity,float pressure,float altitude)
{
  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>ESP8266 Weather Station</title>\n";
  ptr +="<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
  ptr +="body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;}\n";
  ptr +="p {font-size: 24px;color: #444444;margin-bottom: 10px;}\n";
  ptr +="</style>\n";
  ptr +="</head>\n";
  ptr +="<body>\n";
  ptr +="<div id=\"webpage\">\n";
  ptr +="<h1>ESP8266 Weather Station</h1>\n";
  ptr +=temperature;
  ptr +="<p>Temperature: ";
  ptr +="&deg;C</p>";
  ptr +="<p>Pressure: ";
  ptr +=pressure;
  ptr +="hPa</p>";
  ptr +="</div>\n";
  ptr +="</body>\n";
  ptr +="</html>\n";
  ptr +="<p>:humidity";
  ptr +=humidity;
  return ptr;
}
">


Датчики bmp280,aht10

прошу не судить строго, первый код
библиотеки нужные ставил
  • Вопрос задан
  • 202 просмотра
Пригласить эксперта
Ответы на вопрос 1
GavriKos
@GavriKos
Так у тебя два сетапа и два лупа. ТАк не будет работать.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы