I know this is not a blynk forum , but I urgently need some help on coding part . I'm very weak in this area !
however I tried to code after making some research for my project.
BOARD : ARDUINO UNO
SHIELD : HC 05 BLUETOOTH MODULE
APP : BLYNK
project concept : comparator sends DIGITAL HIGH to PIN 12 on a fault scenario , and ARDUINO activates a 5v relay connected to PIN 13 .
Along with this , current will be measured using Acs712 sensor .
I actually developed a conventional code for relay activation based on comparator HIGH and current calculation using sensor without using blynk syntax . where i placed all my code within the Void loop () and did the purpose in simulation . Later I realised this code could be modified in such a way, the necessary data could be send to blynk APP using virtual pins .
here's my code look like !
//Measuring Current Using ACS712
const int analogchannel = 0;
int sensitivity = 66;
float adcvalue= 0;
int offsetvoltage = 2500;
double Voltage = 0;
double ecurrent = 0; //all these for current calc
const int relay = 13;//fault check
const int pin = 12; //input digital
#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(0, 1); // RX, TX
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>
char auth[] = "**************";
SoftwareSerial SerialBLE(0, 1); // RX, TX
BlynkTimer timer;
void myTimerEvent()
{
unsigned int temp=0;
float maxpoint = 0;
int i=0;
for(i=0;i<500;i++)
{
if(temp = analogRead(analogchannel),temp>maxpoint)
{
maxpoint = temp;
}
}
adcvalue = maxpoint;
Voltage = (adcvalue / 1024.0) * 5000; // Gets you mV
ecurrent = ((Voltage - offsetvoltage) / sensitivity);
ecurrent = ( ecurrent ) / ( sqrt(2) );
Serial.print("\t ecurrent = ");
Serial.println(ecurrent,3); // this is the current we need
if(digitalRead(pin)==HIGH)
{
digitalWrite(relay,HIGH);
serial.Println("R phase fault);
Blynk.virtualWrite(V0, "R phase fault"); //fault display
}
Blynk.virtualWrite(V1, ecurrent);
}
void setup()
{
Serial.begin(9600);
SerialBLE.begin(9600);
Blynk.begin(SerialBLE, auth);
Serial.println("Waiting for connections...");
timer.setInterval(1600L, myTimerEvent);
pinMode(relay,OUTPUT);
pinMode(pin,INPUT);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}
does this look logical based on my purpose ??