I need help DHT11 sensor stops working

Hi i need help with my project, i have a Arduino Uno and im using Serial_Usb connection and a IOS phone.
My project has two components RGB strip and a DHT11 sensor, well my issue is that whatever i turn on my RGB strip my DHT11 sensor stops working and dont give any data to my Labeled Value widget on my phone.
Regards.

Here is my code:

int r, g, b;
#define BLYNK_PRINT SwSerial
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX

#include <BlynkSimpleStream.h>
#include <DHT.h>

char auth[] = "auth";

#define DHTPIN 12


#define DHTTYPE DHT11


DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;


void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    SwSerial.println("Failed to read from DHT sensor!");
    return;
  }
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}

void setup()
{
  // Debug console
  SwSerial.begin(9600);
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);

}

BLYNK_WRITE (V2) {

  r = param[0].asInt();
  g = param[1].asInt();
  b = param[2].asInt();
  Serial.print("R:");
  Serial.println(r);
  Serial.print("G:");
  Serial.println(r);
  Serial.print("B:");
  Serial.println(r);
  RGBprocess();
}

void RGBprocess()

{
  analogWrite(13, r);
  analogWrite(2, g);
  analogWrite(7, b);

}


void loop()

{
  Blynk.run();
  timer.run();
}


I’m not sure if it’s due to your loop, but maybe you should have to clean it first.

hi i already did it it doesnt work either

so, please show us your new sketch with a clean loop and the enable / disable timer for analog write function.

i did it

1 Like

ok I see, there’s no timer calling Rgbprocess.
so maybe you have an infinite loop that block the dht function.

Can u please write the line of code that i need to put in ??

Mě ten kòd příjde dobrej.
Pošlete zapojení.

@ussa: You use Serial to connect to Blynk

...
Blynk.begin(Serial, auth);
...

… AND to print debug output.

...
Serial.print("R:");
...

Would be supprised to see this working. :grinning:
You have prepared SwSerial. Use that for debug output.

2 Likes

I will try, thanks man sorry im a NOOB im new to Blynk and arduino programming, but every day u learn something.
Regards

@IBK it works thanks alot.
Regards

1 Like