Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling Error on ESP32 with newest Library esp32 Library #2137

Closed
Erdnusschokolade opened this issue Sep 4, 2024 · 1 comment
Closed

Comments

@Erdnusschokolade
Copy link

Erdnusschokolade commented Sep 4, 2024

Version/revision of the library used

IRremote8266 2.8.6
esp32 Board library 3.0.4 (Bug only happens on 3.* and works fine on 2.*

Describe the bug

There seems to be a difference in the Timer Implementation in the newest esp32 library breaking the code in this library see Error below.

d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.cpp: In function 'void gpio_intr()':
d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.cpp:246:3: error: 'timerAlarmEnable' was not declared in this scope; did you mean 'timerAlarm'?
  246 |   timerAlarmEnable(timer);
      |   ^~~~~~~~~~~~~~~~
      |   timerAlarm
d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.cpp: In member function 'void IRrecv::enableIRIn(bool)':
d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.cpp:362:21: error: too many arguments to function 'hw_timer_t* timerBegin(uint32_t)'
  362 |   timer = timerBegin(_timer_num, 80, true);
      |           ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Users\Lars\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\cores\esp32/esp32-hal.h:84,
                 from C:\Users\Lars\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\cores\esp32/Arduino.h:36,
                 from d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.h:10,
                 from d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.cpp:6:
C:\Users\Lars\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\cores\esp32/esp32-hal-timer.h:35:13: note: declared here
   35 | hw_timer_t *timerBegin(uint32_t frequency);
      |             ^~~~~~~~~~
d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.cpp:371:3: error: 'timerAlarmWrite' was not declared in this scope; did you mean 'timerWrite'?
  371 |   timerAlarmWrite(timer, MS_TO_USEC(params.timeout), ONCE);
      |   ^~~~~~~~~~~~~~~
      |   timerWrite
d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.cpp:375:23: error: too many arguments to function 'void timerAttachInterrupt(hw_timer_t*, void (*)())'
  375 |   timerAttachInterrupt(timer, &read_timeout, false);
      |   ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Lars\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\cores\esp32/esp32-hal-timer.h:50:6: note: declared here
   50 | void timerAttachInterrupt(hw_timer_t *timer, void (*userFunc)(void));
      |      ^~~~~~~~~~~~~~~~~~~~
d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.cpp: In member function 'void IRrecv::disableIRIn()':
d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.cpp:401:3: error: 'timerAlarmDisable' was not declared in this scope
  401 |   timerAlarmDisable(timer);
      |   ^~~~~~~~~~~~~~~~~
d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.cpp: In member function 'void IRrecv::resume()':
d:\Daten\Benutzer\Lars\Documents\Arduino\libraries\IRremoteESP8266\src\IRrecv.cpp:429:3: error: 'timerAlarmDisable' was not declared in this scope
  429 |   timerAlarmDisable(timer);
      |   ^~~~~~~~~~~~~~~~~

exit status 1

To Reproduce

Use newest ESP32 Library and try to compile any of the Example Programs

Example code used

#include <WiFi.h>
#include <PubSubClient.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <ir_Coolix.h>
#include <ArduinoOTA.h>  // OTA-Bibliothek hinzufügen
#include <esp32-hal-timer.h>

// WLAN-Konfiguration
const char* ssid = "xxxx";
const char* password = "xxxx";
unsigned long previousMillis = 0;  // Variable, um den letzten Zeitpunkt zu speichern
const unsigned long interval = 90000;  // 1,5 Minuten in Millisekunden

// MQTT-Konfiguration
const char* mqtt_server = "192.168.xxx.xxx";
const char* topic_mode = "/Klima_Wohnen/mode";
const char* topic_temp = "/Klima_Wohnen/solltemp";
const char* topic_ifeel = "/Klima_Wohnen/isttemp";
int senstemp;

// IR-Sende-Pin
const uint16_t kIrLed = 2;  // GPIO4, kann entsprechend angepasst werden

IRCoolixAC ac(kIrLed);  // Instanz der Klimaanlage

WiFiClient espClient;
PubSubClient client(espClient);

// Funktion zur Verarbeitung eingehender MQTT-Nachrichten
void callback(char* topic, byte* payload, unsigned int length) {
  String messageTemp;
  for (int i = 0; i < length; i++) {
    messageTemp += (char)payload[i];
  }

  if (String(topic) == topic_mode) {
    int mode = messageTemp.toInt();
    switch (mode) {
      case 0:
        ac.off();
        break;
      case 1:
        ac.on();
        ac.setMode(kCoolixCool);
        break;
      case 2:
        ac.on();
        ac.setMode(kCoolixHeat);
        break;
      case 3:
        ac.on();
        ac.setMode(kCoolixAuto);
        break;
      default:
        break;
    }
    ac.send();
  }

  if (String(topic) == topic_temp) {
    uint8_t temperature = messageTemp.toInt();
    ac.setTemp(temperature);
    ac.send();
  }
  if (String(topic) == topic_ifeel) {
    senstemp = messageTemp.toInt();
  }
}

// WLAN verbinden
void setup_wifi() {
  delay(10);
  Serial.println();
  Serial.print("Verbinde mit WLAN: ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WLAN verbunden");
  Serial.print("IP Adresse: ");
  Serial.println(WiFi.localIP());
}

// MQTT wiederverbinden
void reconnect() {
  while (!client.connected()) {
    Serial.print("Verbinde mit MQTT...");
    if (client.connect("ESP8266Client")) {
      Serial.println("verbunden");
      client.subscribe(topic_mode, 1);
      client.subscribe(topic_temp, 1);
      client.subscribe(topic_ifeel, 1); // Stelle sicher, dass wir auf dieses Topic auch abonnieren
    } else {
      Serial.print("Fehler, rc=");
      Serial.print(client.state());
      Serial.println(" erneut versuchen in 5 Sekunden");
      delay(5000);
    }
  }
}

// OTA Initialisierung
void setup_ota() {
  ArduinoOTA.setHostname("IR-Klimaanlage");

  // Optional: OTA Passwort setzen
   ArduinoOTA.setPassword("xxxx");

  ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH) {
      type = "Sketch";
    } else {  // U_SPIFFS
      type = "Filesystem";
    }

    // Ausgeben von Informationen, was aktualisiert wird
    Serial.println("Start updating " + type);
  });

  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnde des OTA-Updates");
    ESP.restart();
  });

  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Fortschritt: %u%%\r", (progress / (total / 100)));
  });

  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Fehler[%u]: ", error);
    if (error == OTA_AUTH_ERROR) {
      Serial.println("Authentifizierungsfehler");
    } else if (error == OTA_BEGIN_ERROR) {
      Serial.println("Fehler beim Starten");
    } else if (error == OTA_CONNECT_ERROR) {
      Serial.println("Verbindungsfehler");
    } else if (error == OTA_RECEIVE_ERROR) {
      Serial.println("Empfangsfehler");
    } else if (error == OTA_END_ERROR) {
      Serial.println("Fehler beim Abschluss");
    }
  });

  ArduinoOTA.begin();
}

void setup() {
  Serial.begin(115200);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);

  setup_ota();  // OTA Setup hinzufügen

  ac.begin();
  ac.on();  // Einschalten der Klimaanlage
  ac.setMode(kCoolixAuto);  // Starten im Automatikmodus
  ac.setTemp(24);  // Standardtemperatur einstellen
  ac.send();  // Sende initiale Befehle
}

void ifeel() {
  ac.setSensorTemp(senstemp);
  ac.setZoneFollow(true);
  ac.send();
}

void loop() {
  unsigned long currentMillis = millis();  // Aktuelle Zeit in Millisekunden
  if (!client.connected()) {
    reconnect();
  }

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;  // Aktualisiere den letzten Zeitpunkt
    ifeel();  // Rufe die Funktion auf
  }

  client.loop();
  ArduinoOTA.handle();  // OTA-Handler in der Loop-Funktion
}

I have followed the steps in the Troubleshooting Guide & read the FAQ

Yes no apliccable solution found

Has this library/code previously worked as expected for you?

yes worked fine for ESP8266 and Works with my ESP32 if i downgrade the esp32 library from 3.0.4 to 2.0.17

Other useful information

It works fine with the older esp32 library tested with 2.0.17
Bug only happens on 3.*

@NiKiZe
Copy link
Collaborator

NiKiZe commented Sep 4, 2024

Duplicate of #2039

@NiKiZe NiKiZe marked this as a duplicate of #2039 Sep 4, 2024
@NiKiZe NiKiZe closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants