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();
}