BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Sensor data to super chart in blynk

#1

Friends., I’m new to this subject , I did research a bit and made some plans for my project. One plan was to obtain the current value using current sensor Acs712 , and simulated it well using proteus simulation software using virtual LCD and arduino UNO . I realized the same could be done practically without using LCD by introducing blynk app .

Board: ARDUINO UNO
Shield : hc 05 Bluetooth module
Blynk app widget : super chart

I used the online blynk coder site for getting code for “PUSH” data to virtual pin . And I did get a code for serial printing current value on serial monitor without using blynk . I tried to combine both !
My logic - (without blynk) Arduino reads A0 and does some calculation and serial prints current value I required . Variable “ecurrent” is the one giving the result .
I wish to send the " ecurrent " to virtual pin V0 which then comes to super chart , (this is the part I’m kind of confused about , since I don’t know where I should interlink variable "ecurrent " to Pin V0 . Below program code lacks that part .

Also ecurrent is only one variable , like wise 2 more ecurrent will be calculated . So what is the thing missing in my code ??

#define BLYNK_PRINT Serial 

#include <SoftwareSerial.h> 

SoftwareSerial SwSerial(10, 11); //RX, TX 

#include <BlynkSimpleSerialBLE.h>

#include <SoftwareSerial.h> 

char auth[] = "YourAuthToken"; 
SoftwareSerial SerialBLE(10, 11); // RX, TX 

#define PIN_UPTIME V0 

BLYNK_READ(PIN_UPTIME)

 { 
 
   Blynk.virtualWrite(PIN_UPTIME, millis() / 1000); 
    
    } 
            
//Measuring Current Using ACS712
 
const int analogchannel = 0; //Connect current sensor with A0 of Arduino

int sensitivity = 66; 
float adcvalue= 0;
int offsetvoltage = 2500; 
double Voltage = 0; //voltage measuring
double ecurrent = 0;// Current measuring
 
void setup() {
 //baud rate
 Serial.begin(9600);//baud rate at which arduino communicates with Laptop/PC
    
SerialBLE.begin(9600);
    
Blynk.begin(SerialBLE, auth);
    
Serial.println("Waiting for connections..."); 
 
}
 
void loop() 
{
 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 = "); // shows the current  measured 
 
 Blynk.run(); 
 
}

0 Likes

#2

I don’t think you can currently send sensor data to the Blynk server when connecting your device via Bluetooth. Even if it did work, the data would only be sent when your phone was within Bluetooth range of your Arduino board.

If you want to use Blynk for this type of project then I’d suggest using a board that can connect to Wi-Fi. You should read this topic about choosing a board:

Pete.

0 Likes

#3

Thanks for your suggestion, but I’m planning to use hc05 since it’s just for a demonstration and phone will be in near proximity to Bluetooth module !

See I’m really fussed with programming code . I don’t know whether I should put the sensor algorithm inside void loop or not … like that … plz help

0 Likes

#4

Help Center to the rescue :smiley:

Etc.

I don’t think that will work for the Super Chart … as I believe that requires a direct to server link like WiFi.

But test it and see.

0 Likes

#5

If it wasn’t meant for Bluetooth, widget option should have been blocked to pick in app … there was no issues!

0 Likes

#6

BT/BLE was part of Blynk at the beginning (when Arduino was the king)… and is still considered in Beta. And surpassed with WiFi based ESP, of which all the new data collecting widgets tend to be designed to use. But I don’t think the developers are too concerned about childproofing the old “cupboards” as they are busy working on a new “house” :stuck_out_tongue:

0 Likes

#7

Sir , plz check my code … suggest some correction … I think you might have got my idea !
My concerns are about void loop and such things …

0 Likes

#8

Sorry, no. I have my own to work on. We are volunteers and try to educate people on how to use and learn Blynk, not work as code monkeys or troubleshooters on request (unless we fancy some particular project… but that is up to the individual to decide how and when)

Click on and read through those links I posted… All the suggestions are already in the Docs & Help files… along with many Examples, etc. More links are at the top of this page.

0 Likes

#9

Sorry to bother you !
I would like to test things my own . But it will be greatful if some sample programs on sensor data was available .

0 Likes

#10

Did you search this forum??

And don’t be afraid to click on all those links (in green and the larger “windows”) in the posts I already provided…

1 Like

#11

Thanks for the guidance sir !
Btw I got to know that Bluetooth is in Beta mode !
Unfortunately I purchased hc05 module !
Will there be any issue in transmitting the data over virtual pins to blynk app via Hc05 . Did blynk official provide that functionality in communication through Bluetooth module ?

0 Likes

#12

Sorry for interrupting , I’ll delete this post after I get an answer that is urgently needed for my project!

When I checked help centre , it was posted that Bluetooth connectivity won’t workout for history chart widget ! But history chart got replaced with super charts with some fixes . Does that fix include Bluetooth connectivity ?? And latest version in store is 2.27.5 ! (Hc 05 module)

Will it work ??

0 Likes

#13

I’ve moved your new topic into this one, as it’s about the same issue.
Please don’t create multiple concurrentl topics about the same subject.

Pete.

1 Like

#14

Most everything works with BT/BLE just fine. Basic Virtual Pins, etc. But the Phone must be on and generally the App forefront and active for them to work. Reconnections are iffy, and you must (at this time) be running the beta version of the App for proper functionality.

It is most direct from device-to-server related Widget items that don’t work at this time… email, SuperChart? reports, bridge, vPin sync… I don’t use BT/BLE mutch so I don’t really know all the limitations

I started off with Arduino and the USB link (which is a full server connection option, in case you want to try it out) and later added an ESP-01 as WiFi shield to that for a WiFi link… mainly because that is what someone gave me.

Eventually I got a Wemos, etc… but BT/BLE was always my least enjoyable linking method, so not one I recommend.

So unless you are in the same boat as I was… and still am :frowning: … the minimal cost of a Wemos D1 Mini or NodeMCU is well worth the efforts moving to that once you are done being frustrated with the BT/BLE limitations.

0 Likes

#15

Yea … Bluetooth module carries some drawbacks … but I bought it … omg :persevere:
I hope it goes well with superchart …(new updates )

0 Likes

#16

Guys , I tried to modify my coding . Does it look normal and logical ?? (I’m a beginner … sorry)

Algorithm :
Arduino checks digital pin input 12 and if it’s high , arduino Drives 5v relay in digital pin 13 and serial prints “Phase fault”
Along with it monitors phase current and prints it .

//Measuring Current Using ACS712
 
const int analogchannel = 0; 
int sensitivity = 66;
float adcvalue= 0;
int offsetvoltage = 2500; 
double Voltage = 0; 
double ecurrent = 0;
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 

 if(digitalRead(pin)==HIGH)
    {
        digitalWrite(relay,HIGH);
        serial.Println("R phase fault); 
        Blynk.virtualWrite(V0, "R phase fault");
    }
    
 Blynk.virtualWrite(V1, ecurrent);

}

void setup()
{
  Serial.begin(9600);
  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);

  Serial.println("Waiting for connections...");

  // Setup a function to be called every second
  timer.setInterval(1600L, myTimerEvent);
    pinMode(relay,OUTPUT);
    pinMode(pin,INPUT);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

0 Likes