I'm at a total loss here. To preface, I am not a programmer in any sense of the word, for me it's just "edit shit and hope it compiles". So basically it was good code until I touched it.
I've got a program that is mostly example code with a small modification, it's set up in an HTPC center. The purpose is for the board's attached IR LED to turn the TV on when the board receives power. That's it. The same exact code is running on both of the units, but one is not running anything when it's first powered on, only when it's reset. It's been working fine for two weeks until now.
/* IRremoteESP8266: IRsendDemo - demonstrates sending IR codes with IRsend.
*
* Version 1.1 January, 2019
* Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009,
* Copyright 2009 Ken Shirriff, http://arcfn.com
*
* An IR LED circuit *MUST* be connected to the ESP8266 on a pin
* as specified by kIrLed below.
*
* TL;DR: The IR LED needs to be driven by a transistor for a good result.
*
* Suggested circuit:
* https://github.com/markszabo/IRremoteESP8266/wiki#ir-sending
*
* 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>
const uint16_t kIrLed = 4; // ESP8266 GPIO pin to use. Recommended: 4 (D2).
IRsend irsend(kIrLed); // Set the GPIO to be used to sending the message.
// Example of data captured by IRrecvDumpV2.ino
uint16_t rawData[71] = {9048, 4470, 602, 560, 574, 560, 574, 562, 570, 562, 582, 554, 580, 554, 580, 556, 576, 1666, 580, 1662, 574, 1642, 604, 1638, 608, 1636, 602, 560, 574, 560, 572, 562, 572, 1672, 576, 560, 574, 562, 572, 1670, 576, 558, 574, 560, 572, 562, 582, 1662, 574, 560, 572, 1670, 576, 1668, 580, 554, 578, 1664, 582, 1662, 574, 1642, 604, 558, 576, 1668, 580, 42020, 9052, 2224, 600}; // NEC 1F122DD
// Example Samsung A/C state captured from IRrecvDumpV2.ino
uint8_t samsungState[kSamsungAcStateLength] = {
0x02, 0x92, 0x0F, 0x00, 0x00, 0x00, 0xF0,
0x01, 0xE2, 0xFE, 0x71, 0x40, 0x11, 0xF0};
bool alreadyRun = false;
void setup() {
irsend.begin();
#if ESP8266
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
#else // ESP8266
Serial.begin(115200, SERIAL_8N1);
#endif // ESP8266
}
void loop() {
while (alreadyRun == false)
{
delay(10000); //First delay is to wait 10 seconds in case the TV is not ready
Serial.println("RCA TV On");
irsend.sendRaw(rawData, 71, 38); // Send a raw data capture at 38kHz.
delay(6000); // no reason fo this delay, it's just there
alreadyRun = true; //set the boolean to true to prevent it from running again and turning off the TVs.
Serial.println("The TV should be on, my job here is done");
}
}
Again I've not the slightest clue about programming apart from those super beginner classes, so I apologize to anyone who has the misfortune of trying to stomach my attempt at any code. Any help is appreciated!
Board is a Sparkfun WiFi IR Blaster ESP8266 board, and it's connected to a generic FTDI USB Adapter.