D0 on esp8266 always 1

Hey guys! I have this home automation project, which i control relays, control AC and TV by IR LED and have a temperatura sensor. Yesterday I had everything running smoothly, all relays ok, sending the IR signals. However, today, after using the same board (NodeMCU) to test a gas sensor, D0, whick I use to send IR codes, is always sending 1 and my IR leds are always on. I dont know what might be causing it. I havent changed anything on the pinouts or code, and I have used another NodeMCU and it has the same issue.

All relays and sensors work fine, only the IR LEDs connected to D0 are always on, when they were supposed to turn on only by my push buttons. There’s no events running on Eventor or anything that could have changed this. This is the Blynk interface to activate the TV IR leds

I use NodeMCU esp8266
Blynk on Android
IR leds on push button by virtual pins

This is the code:

#define BLYNK_PRINT Serial   
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <TimeLib.h>
#include <DHT.h>
#include <SPI.h>
#include <WidgetRTC.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>

#define DHTPIN D7          
#define DHTTYPE DHT11    
#define relay1 D8
#define relay2 D1
#define relay3 D2
#define button1 D3
#define button2 D4
#define button3 D5
#define IR_LED D0
#define RAWBUF 400

uint16_t ac24[] = {9060,  4564, 548,  1724, 548,  1724, 548,  596, 552,  604, 548,  596, 548,  596, 548,  596, 552,  1732, 548,  596, 548,  1724, 548,  1720, 548,  608, 548,  596, 548,  600, 544,  600, 548,  604, 548,  1724, 548,  1724, 548,  596, 548,  604, 548,  596, 552,  596, 548,  596, 548,  604, 552,  596, 548,  1720, 552,  596, 548,  604, 548,  596, 552,  1720, 548,  1724, 548,  608, 548,  596, 548,  596, 548,  596, 548,  608, 548,  596, 548,  596, 548,  596, 552,  604, 548,  596, 548,  600, 548,  596, 548,  604, 548,  600, 548,  596, 548,  596, 548,  604, 548,  8076, 548,  600, 548,  600, 548,  600, 544,  600, 548,  600, 548,  600, 544,  604, 544,  600, 548,  600, 548,  600, 544,  600, 548,  600, 548,  600, 544,  604, 544,  600, 548,  600, 544,  604, 548,  600, 544,  600, 548,  600, 548,  600, 544,  600, 548,  600, 544,  604, 548,  600, 544,  600, 548,  600, 548,  600, 548,  600, 544,  600, 548,  600, 548,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  600, 548,  600, 548,  600, 544,  604, 544,  600, 548,  600, 544,  604, 544,  600, 548,  600, 548,  600, 544,  604, 544,  600, 548,  600, 548,  600, 544,  604, 544,  600, 548,  600, 544,  604, 544,  660, 544,  1728, 544,  600, 544,  600, 548,  608, 544,  600, 548,  1724, 544,  1724, 548,  604, 544};
uint16_t ac23[] = {9060, 4568, 552, 1724, 548, 1724, 544, 600, 548, 608, 548, 596, 548, 596, 548, 600, 548, 1732, 544, 600, 548, 1724, 548, 1724, 548, 608, 548, 600, 544, 600, 548, 596, 548, 608, 548, 1724, 548, 1724, 548, 596, 548, 608, 548, 596, 548, 596, 548, 600, 548, 604, 548, 596, 552, 1720, 552, 596, 548, 604, 552, 1724, 548, 596, 548, 1724, 548, 604, 552, 596, 544, 600, 548, 600, 548, 604, 548, 596, 552, 596, 548, 596, 548, 608, 548, 596, 548, 596, 548, 600, 548, 604, 548, 600, 548, 596, 548, 596, 548, 604, 548, 8080, 548, 600, 548, 600, 548, 600, 548, 600, 548, 596, 552, 596, 548, 600, 548, 600, 548, 600, 548, 596, 548, 600, 552, 596, 548, 600, 548, 600, 548, 600, 548, 600, 548, 600, 548, 596, 548, 600, 552, 596, 548, 600, 544, 604, 548, 600, 548, 596, 552, 596, 548, 600, 548, 600, 548, 600, 548, 600, 548, 596, 552, 596, 552,596, 548, 600, 548, 600, 548, 600, 548, 596, 552, 596, 548, 600, 548, 600, 548, 600, 548, 600, 548, 600, 548, 596, 548, 600, 548, 600, 548, 600, 548, 600, 548, 600, 548, 596, 552, 596, 548, 600, 548, 600, 548, 596, 552, 600, 548, 596, 552, 656, 548, 1724, 548, 596, 548, 596, 552, 604, 548, 1724, 548, 596, 552, 1720, 552, 600, 548}; 
uint16_t ac22[] = {9060, 4564, 548, 1724, 544, 1728, 544, 600, 544, 608, 548, 596, 548, 600, 544, 600, 544, 1736, 544, 600, 544, 1728, 544, 1728, 544, 608, 544, 600, 548, 600, 544, 600, 544, 608, 548, 1724, 544, 1728, 544, 600, 544, 608, 548, 600, 544, 600, 544, 600, 544, 612, 544, 600, 544, 1724, 548, 600, 544, 608, 544, 604, 544, 600, 544, 1728, 544, 608, 544, 600, 544, 600, 548, 600, 544, 608, 544, 600, 548, 600, 544,600, 544, 608, 548, 600, 544, 600, 544, 600, 544, 612, 544, 600, 544, 600, 544, 600, 544, 608, 544, 8080, 544, 604, 544, 604, 544, 600, 548, 600, 544, 604, 544, 600, 548, 600, 544, 604, 544, 604, 544, 600, 544, 604, 544, 604, 544, 600, 544, 604, 544, 604, 544, 600, 544, 604, 544, 604, 544, 600, 544, 604, 544, 604, 544, 600, 544, 604, 544, 604, 544, 600, 544, 604, 544, 604, 544, 600, 548, 600, 544, 604, 544, 604, 544, 600, 544, 604, 544, 604, 544, 600, 548, 600, 544, 604, 544, 600, 548, 600, 548, 600, 544, 604, 544, 600, 544, 604, 544, 600, 548, 600, 544, 604, 544, 604, 544, 600, 544, 604, 544, 604, 544, 600, 544, 604, 544, 604, 544, 600, 548, 600, 544, 660, 544, 1728, 544, 600, 544, 604, 544, 608, 544, 600, 544, 604, 544, 1724, 544, 604, 548};
uint16_t  onac22[] = {9012,  4592, 524,  1752, 520,  1748, 520,  628, 520,  632, 520,  624, 520,  628, 520,  624, 520,  1760, 520,  624, 520,  1752, 520,  1752, 520,  636, 520,  624, 520,  624, 520,  628, 516,  636, 520,  1752, 520,  1752, 520,  1752, 520,  632, 520,  628, 520,  624, 520,  624, 520,  636, 520,  624, 520,  1752, 520,  624, 520,  636, 520,  624, 520,  624, 520,  1752, 520,  632, 524,  624, 520,  624, 520,  624, 520,  636, 520,  624, 520,  624, 520,  628, 516,  636, 520,  624, 520,  628, 516,  628, 520,  632, 520,  624, 520,  628, 520,  624, 520,  632, 516,  8108, 520,  628, 520,  628, 520,  628, 520,  624, 524,  624, 520,  628, 520,  628, 520,  624, 520,  628, 520,  628, 520,  628, 520,  628, 520,  624, 520,  628, 520,  628, 520,  628, 520,  624, 520,  628, 520,  628, 520,  628, 520,  628, 516,  628, 520,  628, 520,  628, 520,  628, 520,  628, 520,  624, 520,  628, 520,  628, 520,  628, 520,  624, 520,  628, 520,  628, 520,  628, 520,  628, 520,  624, 520,  628, 520,  628, 520,  628, 520,  624, 520,  628, 520,  628, 520,  628, 520,  628, 520,  628, 516,  628, 520,  628, 520,  628, 520,  624, 520,  628, 520,  628, 520,  628, 520,  628, 520,  624, 520,  632, 516,  688, 516,  1752, 520,  628, 520,  1752, 520,  632, 520,  624, 520,  628, 520,  1752, 520,  628, 520};
uint16_t onac24[] = {9040,  4564, 548,  1724, 548,  1724, 548,  596, 548,  608, 548,  596, 548,  596, 548,  600, 548,  1732, 548,  596, 548,  1724, 548,  1724, 548,  608, 544,  600, 548,  596, 548,  596, 548,  608, 548,  1720, 552,  1724, 544,  1724, 548,  608, 548,  596, 548,  600, 544,  600, 548,  604, 548,  596, 548,  1724, 548,  600, 548,  604, 548,  596, 548,  1724, 548,  1724, 548,  608, 544,  600, 548,  596, 548,  596, 548,  608, 548,  596, 548,  596, 548,  596, 548,  608, 548,  596, 548,  596, 548,  600, 548,  604, 548,  596, 548,  600, 548,  596, 548,  600, 548,  8080, 548,  600, 548,  600, 544,  600, 548,  600, 548,  600, 548,  596, 552,  596, 548,  600, 548,  596, 552,  596, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  596, 552,  596, 548,  600, 548,  600, 548,  600, 544,  600, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  600, 544,  600, 548,  600, 548,  600, 548,  656, 548,  1724, 548,  596, 548,  1724, 548,  608, 548,  596, 548,  1724, 548,  1724, 548,  600, 548};
uint16_t timer24[]= {9044,  4568, 544,  1728, 544,  1724, 548,  600, 544,  608, 544,  604, 544,  600, 544,  600, 544,  1736, 544,  600, 544,  1728, 544,  1728, 544,  608, 548,  600, 544,  600, 544,  600, 548,  608, 544,  1724, 548,  1724, 548,  596, 548,  608, 544,  600, 548,  600, 544,  600, 544,  608, 548,  600, 544,  1728, 544,  600, 544,  1736, 544,  600, 544,  1728, 544,  1728, 544,  608, 548,  1724, 544,  604, 544,  1724, 548,  608, 544,  600, 548,  600, 544,  600, 544,  608, 544,  604, 544,  600, 548,  596, 544,  608, 548,  600, 544,  600, 544,  600, 548,  604, 544,  8080, 548,  600, 544,  604, 544,  604, 544,  604, 544,  600, 544,  604, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  604, 544,  600, 548,  600, 548,  600, 544,  604, 544,  600, 548,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  604, 544,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  604, 544,  660, 544,  600, 544,  600, 548,  1724, 544,  1736, 548,  600, 544,  1724, 548,  1724, 548,  604, 544};
uint16_t timer23[]= {9064,  4564, 548,  1724, 548,  1724, 544,  604, 544,  608, 544,  600, 548,  596, 548,  600, 544,  1736, 544,  600, 544,  1728, 544,  1728, 544,  608, 544,  600, 548,  596, 548,  600, 544,  608, 544,  1728, 544,  1728, 544,  600, 544,  608, 548,  600, 544,  600, 544,  600, 548,  608, 544,  600, 544,  1728, 544,  600, 544,  1736, 544,  1728, 544,  604, 544,  1724, 548,  608, 544,  1728, 544,  600, 544,  1728, 544,  608, 548,  600, 544,  600, 544,  600, 544,  612, 544,  600, 544,  600, 544,  600, 548,  608, 544,  600, 544,  600, 544,  604, 544,  604, 544,  8080, 548,  600, 548,  600, 544,  604, 544,  604, 544,  600, 544,  604, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  604, 544,  604, 544,  600, 548,  600, 544,  660, 548,  600, 544,  600, 544,  1728, 544,  1736, 544,  1728, 544,  600, 544,  1728, 544,  604, 548};
uint16_t timer22[]= {9064,  4564, 548,  1724, 548,  1724, 548,  596, 548,  608, 548,  596, 548,  596, 548,  600, 548,  1732, 548,  596, 548,  1724, 548,  1724, 548,  604, 548,  596, 552,  596, 548,  596, 548,  604, 552,  1724, 544,  1724, 552,  596, 548,  604, 548,  596, 552,  596, 548,  596, 552,  600, 548,  600, 548,  1724, 544,  600, 548,  1732, 548,  596, 548,  596, 548,  1724, 548,  608, 544,  1724, 548,  596, 552,  1724, 544,  608, 548,  596, 548,  596, 548,  600, 548,  604, 548,  596, 548,  600, 548,  596, 548,  604, 548,  596, 548,  600, 548,  596, 548,  600, 548,  8080, 548,  600, 548,  596, 552,  596, 548,  600, 548,  600, 548,  600, 544,  600, 548,  600, 548,  600, 548,  596, 552,  596, 548,  600, 548,  600, 548,  600, 544,  600, 548,  600, 548,  600, 544,  600, 548,  600, 548,  600, 548,  600, 544,  600, 548,  600, 548,  596, 552,  596, 548,  600, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  600, 544,  600, 548,  600, 548,  600, 548,  600, 548,  600, 544,  600, 548,  600, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  600, 548,  596, 548,  600, 548,  600, 548,  600, 548,  600, 544,  600, 548,  660, 548,  596, 548,  596, 548,  1724, 548,  1732, 548,  600, 548,  596, 548,  1724, 548,  600, 548};
int khz = 38;

BlynkTimer timer;
DHT dht(DHTPIN, DHTTYPE);
WidgetRTC rtc;
WidgetLED led1(V20);  
WidgetLED led2(V21); 
WidgetLED led3(V22);
WidgetTerminal terminal(V0);
IRsend irsend(IR_LED); 

char auth[] = "xxx";

char ssid[] = "xx";  
char pass[] = "lxxx";  

//---------------------------------------------------

int relayVButton1 = 0;
int relayVButton2 = 0;
int relayVButton3 = 0;
int isFirstConnect = true;

boolean relayState1 = 1;
boolean relayState2 = 1;
boolean relayState3 = 1;
boolean buttonState1 = 1;
boolean buttonState2 = 1;
boolean buttonState3 = 1;

//------------------msgs conectado e disc-----------
BLYNK_CONNECTED() {
  if (isFirstConnect) {
    Blynk.syncAll();
    isFirstConnect = false;
  }

  Serial.println("\n\n\n\n\n");
  Serial.println("------------------");
  Serial.println("AUTOMACAO 1 - CONECTADO");
  Serial.println("------------------");

  terminal.println("\n\n\n\n\n");
  terminal.println("------------------");
  terminal.println("AUTOMACAO 1 - CONECTADO");
  terminal.println("------------------");
  terminal.flush();
  rtc.begin();
}
  
BLYNK_APP_CONNECTED() {
  Serial.println("App aberto.");
  terminal.println("App aberto.");
  terminal.flush();
}
//----------------------------------------------------

//-------------------------------SETUP---------------------------------------------------
void setup(){
 Serial.begin(9600); 
 Blynk.begin(auth, ssid, pass); 
 dht.begin();
 
 timer.setInterval(12000L, sendSensor);    // SENSOR DHT
 timer.setInterval(10000L, clockDisplay);  // CLOCK
 timer.setInterval(300L, somefunction);   // FUNÇAO RELAY

while (Blynk.connect() == false) {
 buttonState1 = digitalRead (button1);
  if (buttonState1 > 0){
    relayState1 = !relayState1;
      } 
      digitalWrite(relay1, relayState1);
       buttonState2 = digitalRead (button2);
  if (buttonState2 > 0){
    relayState2 = !relayState2;
      } 
      digitalWrite(relay2, relayState2);
  if (buttonState3 > 0){
    relayState3 = !relayState3;
      } 
      digitalWrite(relay3, relayState3);
  }
  
pinMode(relay1, OUTPUT);
pinMode(button1,INPUT_PULLUP);
pinMode(relay2, OUTPUT);
pinMode(button2,INPUT_PULLUP);
pinMode(relay3, OUTPUT);
pinMode(button3,INPUT_PULLUP);
}
//-----------------------------------------------------------------------------------------

//---------------FUNCAO DHT-----------------------------------------------------------------
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // (true) para Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Falha ao ler sensor DHT11!");
    return;
  }
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);

  Serial.println("\n");
  Serial.print("Temperatura: ");
  Serial.print(t);
  Serial.println("C");

  Serial.print("Umidade: ");
  Serial.print(h);
  Serial.println("%");
}//-------------------------------------------------------------------------------------------

//------------FUNCAO RELAY--------------------------------------------------------------------
void somefunction(){
  buttonState1 = digitalRead (button1);
    if (buttonState1 < 1 || relayVButton1 > 0)    {
    relayState1 = !relayState1;
    } 
    digitalWrite(relay1, relayState1);
     
  buttonState2 = digitalRead (button2);
    if (buttonState2 < 1  || relayVButton2 > 0){
      relayState2 = !relayState2;
    } 
      digitalWrite(relay2, relayState2);
      
  buttonState3 = digitalRead (button3);
    if (buttonState3 < 1  || relayVButton3 > 0){
      relayState3 = !relayState3;
    } 
      digitalWrite(relay3, relayState3);

//----------------button virtual led----------------
  byte inp = digitalRead(relay1);   
  if (inp == HIGH){
   led1.on();
  }
   else
   led1.off();

  byte inp2 = digitalRead(relay2);   
  if (inp2 == HIGH){
   led2.on();
  }
   else
   led2.off();

  byte inp3 = digitalRead(relay3);   
  if (inp3 == HIGH){
   led3.on();
  }
   else
   led3.off();
}
//--------------leitura pino app-------------------- 
BLYNK_WRITE(V10){
  relayVButton1 = param.asInt();   
}

BLYNK_WRITE(V11){
  relayVButton2 = param.asInt(); 
}
BLYNK_WRITE(V12){
  relayVButton3 = param.asInt(); 
}
//TV ON-OFF
BLYNK_WRITE(V30){
  if(param.asInt()==1){
    irsend.sendNEC(0x20DF10EF,32); 
    delay(300);
    Blynk.virtualWrite(V30, LOW);
  }
}
//TV V-UP
BLYNK_WRITE(V31){
  if(param.asInt()){
    irsend.sendNEC(0x20DF40BF,32); 
  }
}
//TV V-DOWN
BLYNK_WRITE(V32){
  if(param.asInt()){
    irsend.sendNEC(0x20DFC03F,32); 
  }
}
//TV CH-UP
BLYNK_WRITE(V33){
  if(param.asInt()){
    irsend.sendNEC(0x20DF00FF,32); 
  }
}
//TV CH-DOWN
BLYNK_WRITE(V34){
  if(param.asInt()){
    irsend.sendNEC(0x20DF807F,32); 
  }
}
//TV MUTE
BLYNK_WRITE(V35){
  if(param.asInt()==1){
    irsend.sendNEC(0x20DF906F,32);
    delay(300);
    Blynk.virtualWrite(V35, LOW); 
  }
}
//TV INPUT
BLYNK_WRITE(V36){
  if(param.asInt()){
    irsend.sendNEC(0x20DFD02F,32); 
  }
}
//TV EXIT
BLYNK_WRITE(V37){
  if(param.asInt()){
    irsend.sendNEC(0x20DFDA25,32); 
  }
}
//TV OK
BLYNK_WRITE(V38){
  if(param.asInt()){
    irsend.sendNEC(0x20DF22DD,32); 
  }
}
//AC ON-OFF 22
BLYNK_WRITE(V50){
  if(param.asInt()==1){
    irsend.sendRaw(onac22, sizeof(onac22) / sizeof(onac22[0]), 38);
    delay(300);
    Blynk.virtualWrite(V50, LOW); 
  }
}
//AC ON-OFF 24
BLYNK_WRITE(V51){
  if(param.asInt()){
   irsend.sendRaw(onac24, sizeof(onac24) / sizeof(onac24[0]), khz);
  }
}
//AC 24
BLYNK_WRITE(V54){
  if(param.asInt()){
    irsend.sendRaw(ac24, sizeof(ac24) / sizeof(ac24[0]), khz);
  }
}
//AC 23
BLYNK_WRITE(V53){
  if(param.asInt()){
    irsend.sendRaw(ac23, sizeof(ac23) / sizeof(ac23[0]), khz);
  }
}
//AC 22 
BLYNK_WRITE(V52){
  if(param.asInt()){
    irsend.sendRaw(ac22, sizeof(ac22) / sizeof(ac22[0]), khz);
  }
}
//AC TIMER 24 
BLYNK_WRITE(V55){
  if(param.asInt()){
    irsend.sendRaw(timer24, sizeof(timer24) / sizeof(timer24[0]), khz); 
  }
}
//AC TIMER 23 
BLYNK_WRITE(V56){
  if(param.asInt()){
    irsend.sendRaw(timer23, sizeof(timer23) / sizeof(timer23[0]), khz);  
  }
}
//AC TIMER 22 
BLYNK_WRITE(V57){
  if(param.asInt()){
    irsend.sendRaw(timer22, sizeof(timer22) / sizeof(timer22[0]), khz);  
  }
}

//------------------------------------------------------------------------------------------------

//----------------------------FUNCAO CLOCK---------------------------------------------------------
void clockDisplay()
{  
  String currentTime = String(hour()) + ":" + minute();
  String currentDate = String(day()) + "/" + month() + "/" + year();
 
  Serial.print("-ONLINE: \n");
  Serial.print("  HORA: ");
  Serial.print(currentTime);
  Serial.print("\n");
  Serial.print("\n");

  // Send time to the App
  Blynk.virtualWrite(V15, currentTime);
  // Send date to the App
  Blynk.virtualWrite(V16, currentDate);
}
//--------------------------------------------------------------------------------------------------
//---------------------------------------GERAL-------------------------------------------
BLYNK_WRITE(V1) {
  int estado = param.asInt();
  if (estado == 1) {
    relayState1 = relayState2;
    relayState1 = !relayState1;
    relayState2 = !relayState2;
    relayState3 = relayState2;
  }
  delay(300);
  Blynk.virtualWrite(V1, LOW);
}
BLYNK_WRITE(V100) {
  if (param.asInt() == 1) {
      if(relayState1 == 1){
          relayState1 = !relayState1;
      }
      if(relayState2 == 1){
          relayState2 = !relayState2;
      }
      if(relayState3 == 1){
          relayState3 = !relayState3;
      }      
      delay(300);
      Blynk.virtualWrite(V100, LOW);
  }
}
BLYNK_WRITE(V101) {
  if (param.asInt() == 1) {
      if(relayState1 == 1){
          relayState1 = !relayState1;
      }
      if(relayState2 == 1){
          relayState2 = !relayState2;
      }
      if(relayState3 == 1){
          relayState3 = !relayState3;
      }
      irsend.sendRaw(onac22, sizeof(onac22) / sizeof(onac22[0]), 38);
      irsend.sendNEC(0x20DF10EF,32); 
      delay(300);
      Blynk.virtualWrite(V101, LOW);
  }
  
}

BLYNK_WRITE(V102) {
  if (param.asInt() == 1) {
      if(relayState1 == 1){
          relayState1 = !relayState1;
      }
      if(relayState2 == 1){
          relayState2 = !relayState2;
      }
      if(relayState3 == 1){
          relayState3 = !relayState3;
      }
      irsend.sendNEC(0x20DF10EF,32); 
      delay(300);
      Blynk.virtualWrite(V102, LOW);
  }  
}
//--------------------------------------------------------------------------------------

void loop() {
    Blynk.run(); 
    timer.run();                 
}
1 Like

You should put your pinMode() first in the setup to be sure they are adhered to before running any pin commands.

And I don’t see any pinMode() for IR_LED (D0)

Thanks for the answer.
In the IR_sendDemo in the library there’s no pinMode. You only use this: #define IR_LED D0
The problem is: i have changed almost nothing, and it was working perfectly yesterday.
Yesterday i could turn the TV and AC on with the IR leds.
About the IR leds, Im driving then with a 2n2222 and a 4.7 resistor. I have tested them on a arduino and they work fine.

This is the Demo

#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include <IRremoteESP8266.h>
#include <IRsend.h>

#define IR_LED 4  // ESP8266 GPIO pin to use. Recommended: 4 (D2).

IRsend irsend(IR_LED);  // Set the GPIO to be used to sending the message.

// Example of data captured by IRrecvDumpV2.ino
uint16_t rawData[67] = {9000, 4500, 650, 550, 650, 1650, 600, 550, 650, 550,
                        600, 1650, 650, 550, 600, 1650, 650, 1650, 650, 1650,
                        600, 550, 650, 1650, 650, 1650, 650, 550, 600, 1650,
                        650, 1650, 650, 550, 650, 550, 650, 1650, 650, 550,
                        650, 550, 650, 550, 600, 550, 650, 550, 650, 550,
                        650, 1650, 600, 550, 650, 1650, 650, 1650, 650, 1650,
                        650, 1650, 650, 1650, 650, 1650, 600};

void setup() {
  irsend.begin();
  Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
}

void loop() {
#if SEND_NEC
  Serial.println("NEC");
  irsend.sendNEC(0x00FFE01FUL, 32);
#endif  // SEND_NEC
  delay(2000);
#if SEND_SONY
  Serial.println("Sony");
  irsend.sendSony(0xa90, 12, 2);
#endif  // SEND_SONY
  delay(2000);
#if SEND_RAW
  Serial.println("a rawData capture from IRrecvDumpV2");
  irsend.sendRaw(rawData, 67, 38);  // Send a raw data capture at 38kHz.
#endif  // SEND_RAW
  delay(2000);
}

Pictures taken a few minutes ago. IR leds always on

So, perhaps the demo is wrong? :stuck_out_tongue_winking_eye:

#define just set a variable name to a pin, it doesn’t set a pinMode()

Almost nothing is still more then nothing :slight_smile: The Blynk library does attempt to set pinMode() (without needing the command) but I find it unreliable.

And how you connected the IR led to the board? Can you show/describe it? Is it possible you just overloaded the pin, which got damaged? This is NOT UNCOMMON!

so i should put pinMode(IR_LED, output)?

Don’t think it is necessary. The library probably took care of this.

something similar to this but R1=4.7 omhs, there’s no R2 and the base goes to D0

I have tested the LEDs on an arduino and they worked, and i have tested the same code in a differente NodeMCU and the same problem happened.

I exploded my head tryin to find the problem and yet i couldnt

1 Like

It happens
The led is connected properly,…

Not reliable as stated, I have ran into this many times… voice of frustrated coding experience speaking here… :stuck_out_tongue:

Yes (and they should be first in the void setup() )

Not guaranteeing it is the final solution… but highly recommended.

1 Like

Sure you might have right, but I assume it was working before, so?

Ok, I suggest you do what @Gunner has written, and if it fails, either check code with another pin, or the same hardware setup flash with most basic ‘blink’ (not Blynk :wink: ) example, but change the blinking output to the one, it led is connected. If you will see it ‘blinking’ - fine- at least hardware is good. If not… Pins mismatch? code error?.. God knows what else.

hahaha tried your suggestion @Gunner and it worked.

so fun how a simple omittion can be a pain in the neck.

but now it’s working…
thanks for the help guys. now i can sleep in peace. love you!

1 Like

And this voice had a right… Again

1 Like

My pain is someone’s gain… makes it worth it :smiley:

1 Like

Just to add, GPIO16 (Pin D0 on the NodeMCU) isn’t a great pin to use as it’s one of those ‘special’ pins.

Pete.

1 Like

You shouldn’t drive a transistor directly from a microprocessor. It’s like adding a LED to the pin without a resistor in between. I’d add at least a 330 ohm resistor.