Hi,
I am working with a mini project, which requires Sensing the data from the sensor & turning on/off the relay.
I am using Ardunio serial usb to connect to blynk.
The problem I am facing is turning on the relays, i have 4 relays to turn ON/OFF, but unble to do it, it’s no responding.
But when i try it without any sensing part, it’s working fine.
Kindly help me out.
CODE:
#include <SoftwareSerial.h> SoftwareSerial DebugSerial(2, 3); // RX, TX
#define BLYNK_PRINT DebugSerial #include <BlynkSimpleStream.h>
// You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "xxxxxxxxxxxxxxxx";
int LDR = 9; int WL = 8; int LDRState,WLState; const int analogInPin1 = A1; int sensorValue = 0; // value read from the temp int sensorValue1 = 0; // value read from the Hum const int RPin1 = 2; const int RPin2 = 3; const int RPin3 = 7; const int RPin4 = 5; int LEDonoff;
void setup() { // Debug console DebugSerial.begin(9600);
// Blynk will work through Serial Serial.begin(9600); Blynk.begin(auth, Serial); pinMode(LDR, INPUT); pinMode(WL, INPUT); pinMode(RPin1, OUTPUT); pinMode(RPin2, OUTPUT); pinMode(RPin3, OUTPUT); pinMode(RPin4, OUTPUT); while (Blynk.connect() == false) { // Wait until connected } digitalWrite(RPin1, LOW); digitalWrite(RPin2, LOW); digitalWrite(RPin3, LOW); digitalWrite(RPin4, LOW);
}
void loop() { unsigned char value; unsigned int v; float val,hum; int sensorValue = analogRead(A0);
Blynk.run(); float volt = (sensorValue/1024.0) * 5; int tempC = (volt - 0.5) * 100; tempC= tempC+50; Blynk.virtualWrite(2, tempC); sensorValue1 = analogRead(analogInPin1); hum = sensorValue1; hum = (hum*5.0)/1024; // voltage conversion hum=hum*10; Blynk.virtualWrite(1, hum); LDRState = digitalRead(LDR); LDRState = digitalRead(LDR); if (LDRState ==1) { Blynk.virtualWrite(0, "LOW"); } else { Blynk.virtualWrite(0,"HIGH"); }
WLState = digitalRead(WL); if (WLState ==1) { Blynk.virtualWrite(3, "HIGH"); } else { Blynk.virtualWrite(3, "LOW"); }
}
I am able to read the data, but to able to send the data, i have used buttons for the same