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

Arduino uno usb connected blynk

My program:

#define BLYNK_PRINT DebugSerial

int val;
float lux=0.00,ADC_value=0.0048828125,LDR_value;


// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#include <BlynkSimpleStream.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "lENO2Pj-R5EbUCf-eqD1bNiqhmS1UmCI";


void setup()
{
  // Debug console
  DebugSerial.begin(115600);
   pinMode(A0,INPUT);
    pinMode(A1,INPUT);
  
  
  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(115600);
  
  Blynk.begin(Serial, auth);

}

void loop()
{
  val = analogRead(A0);
  float mv = ( val/1024.0)*5000;
  float cel = mv/10;
  float farh = (cel*9)/5 + 32;
  Blynk.virtualWrite(V0,cel);
  Blynk.virtualWrite(V1,farh);
  Serial.print("TEMPRATURE = ");
  Serial.print(cel);
  Serial.print("*C");
  Serial.println();
   LDR_value=analogRead(A1);

  lux=(250.000000/(ADC_value*LDR_value))-50.000000;

  Serial.println(lux);
   Blynk.virtualWrite(V2,lux);

  Blynk.run();
}

My serial connection:
Connecting device at COM6 to blynk-cloud.com:80
OpenC0C("\.\COM6", baud=115600, data=8, parity=no, stop=1) - OK
Connect(“blynk-cloud.com”, “80”) - OK
InOut() START
DSR is OFF

Arduino Uno connected to my pc
pc connected to same network of mobile

Problem:Reading in Blynk app get updated only once(If the reading was 95 at starting it keeps on the same its not updating over time.)

@Ben_Asir please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste these characters if you can’t find the correct character on your keyboard.

Pete.

done

Your code breaks the golden rule of Blynk. You have virtual writes in your void loop, which will flood the server. Read this:

Pete.

but i need to get data from sensor all time

In that case, Blynk is the wrong platform for you.

Pete.

But can we use a local server insted of blynk server

You still can’t have the virtual writes in the void loop, regardless f whether you use local or cloud server.

Did you bother to read the document I linked to?

Pete.

i read it . My program is working fine now( though i have plenty of content in loop)
But
my problem was
i used USB connected arduino uno @ band width 9600 (which is too low)
When i changed it to 1000000 the communication was fine in the usb and the blynk app updates it every second.
Morover i use local server which is programed to accept 50 request per second

Thank You
PeteKnight
and
Rajasingh

Happy Blynking

sir how to change this topic to solved topic

I guess it depends on how reliable you want your system to be. Those people who have used Blynk for many years will recognise how foolish your approach is.

I’m afraid that this makes no sense to me.

The problem with this approach is that you have no control over the timing of your void loop. The frequency is simply a function of the clock speed of the CPU and how long it takes for the void loop to execute.

Done.

Pete.