TurnOnDaikinAC.ino 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Copyright 2017 sillyfrog
  2. *
  3. * An IR LED circuit *MUST* be connected to the ESP8266 on a pin
  4. * as specified by kIrLed below.
  5. *
  6. * TL;DR: The IR LED needs to be driven by a transistor for a good result.
  7. *
  8. * Suggested circuit:
  9. * https://github.com/markszabo/IRremoteESP8266/wiki#ir-sending
  10. *
  11. * Common mistakes & tips:
  12. * * Don't just connect the IR LED directly to the pin, it won't
  13. * have enough current to drive the IR LED effectively.
  14. * * Make sure you have the IR LED polarity correct.
  15. * See: https://learn.sparkfun.com/tutorials/polarity/diode-and-led-polarity
  16. * * Typical digital camera/phones can be used to see if the IR LED is flashed.
  17. * Replace the IR LED with a normal LED if you don't have a digital camera
  18. * when debugging.
  19. * * Avoid using the following pins unless you really know what you are doing:
  20. * * Pin 0/D3: Can interfere with the boot/program mode & support circuits.
  21. * * Pin 1/TX/TXD0: Any serial transmissions from the ESP8266 will interfere.
  22. * * Pin 3/RX/RXD0: Any serial transmissions to the ESP8266 will interfere.
  23. * * ESP-01 modules are tricky. We suggest you use a module with more GPIOs
  24. * for your first time. e.g. ESP-12 etc.
  25. */
  26. #ifndef UNIT_TEST
  27. #include <Arduino.h>
  28. #endif
  29. #include <IRremoteESP8266.h>
  30. #include <IRsend.h>
  31. #include <ir_Daikin.h>
  32. const uint16_t kIrLed = 4; // ESP8266 GPIO pin to use. Recommended: 4 (D2).
  33. IRDaikinESP ac(kIrLed); // Set the GPIO to be used to sending the message
  34. void setup() {
  35. ac.begin();
  36. Serial.begin(115200);
  37. }
  38. void loop() {
  39. Serial.println("Sending...");
  40. // Set up what we want to send. See ir_Daikin.cpp for all the options.
  41. ac.on();
  42. ac.setFan(1);
  43. ac.setMode(kDaikinCool);
  44. ac.setTemp(25);
  45. ac.setSwingVertical(false);
  46. ac.setSwingHorizontal(false);
  47. // Set the current time to 1:33PM (13:33)
  48. // Time works in minutes past midnight
  49. ac.setCurrentTime(13 * 60 + 33);
  50. // Turn off about 1 hour later at 2:30PM (14:30)
  51. ac.enableOffTimer(14 * 60 + 30);
  52. // Display what we are going to send.
  53. Serial.println(ac.toString());
  54. // Now send the IR signal.
  55. #if SEND_DAIKIN
  56. ac.send();
  57. #endif // SEND_DAIKIN
  58. delay(15000);
  59. }