Remote control HVAC unit via IR from ESP32 controlled by FHEM
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

esp32_ir.ino 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
  3. An IR detector/demodulator must be connected to the input RECV_PIN.
  4. Version 0.1 July, 2009
  5. Copyright 2009 Ken Shirriff
  6. http://arcfn.com
  7. */
  8. #include <IRremote.h> // Einbinden der Bibliothek
  9. int RECV_PIN = 2; // Digitales Signal von Pin 11 abgreifen
  10. IRrecv irrecv(RECV_PIN); // Bibliothek den Eingangs Pin mitteilen
  11. decode_results results; // Die Ergebnisse decodieren
  12. void setup()
  13. {
  14. Serial.begin(9600); // Serielle Verbindung aktivieren
  15. pinMode (13, OUTPUT); // Pin 13 (LED) als Ausgang festlegen
  16. irrecv.enableIRIn(); // Eingang auf Pin 11 aktivieren
  17. // pinMode(2, INPUT_PULLUP);
  18. }
  19. void loop() {
  20. if (irrecv.decode(&results))
  21. {
  22. irrecv.resume(); // Das Signal empfangen
  23. switch (results.value) // Abhaengig vom Signal in den richtigen Modus springen
  24. {
  25. case 3838404932:
  26. printIR(F("Swing Off, 20°C Cooling"), results);
  27. break;
  28. case 3690363426:
  29. printIR(F("Swing Off, 21°C Cooling"), results);
  30. break;
  31. case 882009292:
  32. printIR(F("Swing Off, 22°C Cooling"), results);
  33. break;
  34. case 3556311322:
  35. printIR(F("Swing Off, 23°C Cooling"), results);
  36. break;
  37. case 3026199020:
  38. printIR(F("Swing Off, 24°C Cooling, 1"), results);
  39. break;
  40. case 2143461149:
  41. printIR(F("Swing Off, 24°C Cooling, 2"), results);
  42. break;
  43. case 4100230080:
  44. printIR(F("Swing Off, 25°C Cooling"), results);
  45. break;
  46. case 1452498520:
  47. printIR(F("Swing Off, 26°C Cooling, 1"), results);
  48. break;
  49. case 425423268:
  50. printIR(F("Swing Off, 26°C Cooling, 2"), results);
  51. break;
  52. case 2246699793:
  53. printIR(F("Swing Off, 26°C Cooling, 3"), results);
  54. break;
  55. case 790084768:
  56. printIR(F("Swing Off, 27°C Cooling, 1"), results);
  57. break;
  58. case 773307150:
  59. printIR(F("Swing Off, 27°C Cooling, 2"), results);
  60. break;
  61. case 2659219414:
  62. printIR(F("Swing Off, 28°C Cooling, 1"), results);
  63. break;
  64. case 921814487:
  65. printIR(F("Swing Off, 28°C Cooling, 2"), results);
  66. break;
  67. case 2359257124:
  68. printIR(F("Swing Off, 29°C Cooling, 1"), results);
  69. break;
  70. case 891459092:
  71. printIR(F("Swing Off, 29°C Cooling, 2"), results);
  72. break;
  73. case 2900425451:
  74. printIR(F("Swing Off, 29°C Cooling, 3"), results);
  75. break;
  76. case 1053999984:
  77. printIR(F("Swing Off, 29°C Cooling, 4"), results);
  78. break;
  79. case 2537206068:
  80. printIR(F("Swing Off, 29°C Cooling, 5"), results);
  81. break;
  82. case 1620861574:
  83. printIR(F("Swing Off, 30°C Cooling, 1"), results);
  84. break;
  85. case 3546591281:
  86. printIR(F("Swing Off, 30°C Cooling, 2"), results);
  87. break;
  88. case 3703255839:
  89. printIR(F("Swing Off, 30°C Cooling, 3 Fan 7"), results);
  90. break;
  91. case 3802299781:
  92. printIR(F("Swing Off, 30°C Cooling, 4 Fan 7"), results);
  93. break;
  94. case 4294967295:
  95. printIR(F("Failure"), results);
  96. break;
  97. case 1298439238:
  98. printIR(F("Swing Off, 19°C Cooling"), results);
  99. break;
  100. default:
  101. printIR(F("Unknown"), results);
  102. }
  103. }
  104. }
  105. void printIR(String text, decode_results results)
  106. {
  107. Serial.print(F("0b"));
  108. Serial.print(results.value, BIN);
  109. Serial.print(F(" 0x"));
  110. Serial.print(results.value, HEX);
  111. Serial.print(F(" "));
  112. Serial.print(results.value, DEC);
  113. Serial.print(F(" "));
  114. Serial.print(text);
  115. Serial.println(F(""));
  116. }