Interrupt conflict?

I am controlling the activation and brightness of a AC lamp automatically with the use of a PIR sensor, and a TRIAC with zero detector circuit. I'm using the RBDimmer.h library to implement this. Basically, the interrupt pin configured in the RBDimmer library is pin 2. Thus, whenever the arduino detects the zerocrossing on pin 2, it sets the firing angle for the triac based on the value it received from the outVal. The library has a function called dimmer.setPower() to help me set the brightness. I also have a dht11 sensor. Right now, I'm facing a problem between my AC lamp and the dht sensor. During data acquisition from the dht11 sensor, it is required for interrupts to be disabled. I have used the noInterrputs(); and interrupts(); codes during data acquisition as such:

void temperatureRead()
{
  pinMode(data_pin, OUTPUT);
  digitalWrite(data_pin, LOW);
  delay(18);
  digitalWrite(data_pin, HIGH);
  pinMode(data_pin, INPUT_PULLUP);

  noInterrupts();
  //read 41 bits of signal
  for (int i = 0; i <= 40; i++)
  {
    result[i] = (pulseIn(data_pin, HIGH) > 40);
  }
  interrupts();
  //Extract Temperature (from Byte 3)
  temp = 0;
  for (int i = 17; i <= 24; i++)
  {
    temp = temp << 1;
    if (result[i]) temp |= 1;
  }
  BTSerial.print(String(temp) + "#");
  Serial.print(String(temp) + "*");
}

However, this is causing flickering of my AC Lamp and the temperature reading is wrong for every 3-4 values. Whenever there is a wrong value in the serial terminal, a flickering is observed on my AC lamp.
I believe this has to do with interrput handling. Is there any way my AC Lamp's brightness be fixed once the firing angle is set so that it does not flicker until the next change in firing angle is received?

Following is my full code:

#include <RBDdimmer.h>                  //Dimmer Library
#include <AltSoftSerial.h>

AltSoftSerial BTSerial(8, 9); // RX, TX
/*****************INPUTS AND OUTPUTS************************/
#define zerocross  2 // for boards with CHANGEBLE input pins
#define PIR_Sensor 3
#define Light  6
#define LDR_Sensor A0                                       // Assign LDR sensor to Pin A0.
/************************************************************/
dimmerLamp dimmer1(Light); //initialase port for dimmer for MEGA, Leonardo, UNO, Arduino M0, Arduino Zero
/************************VARIABLES****************************/
int data_pin = 7;
int Receiver = 0;
int LDR_sensorVal = 0;                    // Set a variable to store all the values coming from the LDR sensor.
int interval1 = 2000;// Initialize Receiver value as 0.
unsigned char outVal = 0;
unsigned long millis_1 = 0;
boolean result[41]; //holds the result
unsigned int temp; //in celcius
unsigned char receiver;
unsigned long currentMillis;
boolean Auto = false;
boolean PIR_State = false;

float nVPP;   // Voltage measured across resistor
float nCurrThruResistorPP; // Peak Current Measured Through Resistor
float nCurrThruResistorRMS; // RMS current through Resistor
float nCurrentThruWire;     // Actual RMS current in Wire
/*************************************************************/
void setup()
{
  BTSerial.begin(9600);
  Serial.begin(9600);
  dimmer1.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE)
  dimmer1.setState(OFF);
  pinMode(PIR_Sensor, INPUT);
  pinMode(LDR_Sensor, INPUT);
 
}

void loop()
{
  currentMillis = millis();
  if (currentMillis - millis_1 >= interval1)
    {
      millis_1 = currentMillis;
      temperatureRead();
    }
  if (digitalRead(PIR_Sensor) == HIGH)
  {
    PIR_State = true;
  }
  else if (digitalRead(PIR_Sensor) == LOW)
  {
    PIR_State = false;
  }
  Automatic();
  if (BTSerial.available() > 0)
  {
    receiver = BTSerial.read();
    if (receiver == 'A')
    {
      Auto = true;
    }
    else
    {
      Auto = false;
    }
  }
}

void Automatic ()
{
  if (Auto == true)
  {
    if (PIR_State == true)
    {
      int value = analogRead(LDR_Sensor);
      outVal = map(value, 1000, 10, 3, 79);
      if (outVal >= 30)
      {
        dimmer1.setState(ON);
        dimmer1.setPower(outVal); // name.setPower(0%-100%)
      }
      else
      {
        dimmer1.setState(OFF);
      }
    }
  }
}

void temperatureRead()
{
  pinMode(data_pin, OUTPUT);
  digitalWrite(data_pin, LOW);
  delay(18);
  digitalWrite(data_pin, HIGH);
  pinMode(data_pin, INPUT_PULLUP);

  noInterrupts();
  //read 41 bits of signal
  for (int i = 0; i <= 40; i++)
  {
    result[i] = (pulseIn(data_pin, HIGH) > 40);
  }
  interrupts();
  //Extract Temperature (from Byte 3)
  temp = 0;
  for (int i = 17; i <= 24; i++)
  {
    temp = temp << 1;
    if (result[i]) temp |= 1;
  }
  BTSerial.print(String(temp) + "#");
  Serial.print(String(temp) + "*");
}

The temperature sensor's reading is shown in the image attached.

As far as I can see, your sketch does not use an DHT. What am I missing?

I'm not using the dht library. Instead, i'm using a function called temperatureRead to extract the bytes from the temperature sensor. The results far worst when using the dht library functions as it doesnt display any temperature. Only NAN NAN... I have done some search online and I think it's a problem with the interrupt service routine. My pulseIndata in the temperatureRead function requires interrputs to be disabled while i'm acquiring the data from the dht. My supply frequency is 50Hz. Thus, half cycle is 10ms. However, 18ms is spent in the temperatureRead function to read the bytes on the data pin and then interrputs are disabled to pulseIndata and then enabled once it's complete.

I found the solution! I read the dimmer.h library and tried using the TOGGLE_ON instead. The TOGGLE_ON mode uses Hardware timer which solved the problem. Although there is still a very tiny bit of flickering that can be observed which i believe is due to the interrupt again. If u have any suggestions to resolve that flickering please do share.Thanks for the help!

If you need interrupts disabled for timing accuracy, and you want to do AC-dimming, you should really just use 2 boards. But why are you using a swSerial ?AltSoftSerial BTSerial(8, 9); // RX, TXSure altSoftSerial is less demanding than normal swSerial, but it still turns off interrupts at times. Just use hwSerial only.

I'm using those as i want to avoid the plugging in and plugging out of the jumper wire during upload of the program onto the arduino.