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