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

[Solved]Local blynk server is not send status to app

I’ve created a local blynk server with arduino simulator . When i run this code, it just count from 1 to 9, but when i click the button from app, i can control the led, but the data is only transmited stably from app.
Please help me!

#include <BlynkSimpleStream.h>// Pin Assignments
char auth[] = "hqtvjnGRwocO94PgDi-y8QssjyDORoiQ";
int nRainVal;
void setup()
{
  //Set the three LED pins as output
  Serial.begin(9600);
  pinMode(3,OUTPUT);
  Blynk.begin(auth, Serial);
}
void loop() {
  Blynk.run();
  static int i=0;
  Blynk.virtualWrite(3, ++i); 
  i = i%100;
}

@bach1608 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:
```

Pete.

Thank for your suggestion.
Please help me, i need it for my school project.

What exactly does this mean?

Pete.

void loop()
 { 
     Blynk.run(); 
     static int i=0; 
     Blynk.virtualWrite(3, ++i); 
     i = i%100;
 }

Can you explain this logic? Setting “i” to zero hundreds or thousands of times a second?

Also check out your virtual write syntax. Should be something like Blynk.virtualWrite(V3, i); So basically this will send the 0 you just defined to the virtual pin three (gauge?) then set “i” to %100 then immediately set it to 0 and repeat.

Or am I missing something.

If i click the button or any command from app, the hardware on proteus will work.
The gauge should have counted from 1 to 99, but from begin, it’s count from 1 to 9, then my phone received nothing, just only command from app is working.

Ye its just counts from 1 to 99. I has try it on server blynk-cloud.com, it work stabely. I think i got in trouble at my server

Sounds like a flooding issue. It is sending more than 10 writes a second. If you search “keep your void loop clean” there will be a suggestion to move the code into a timer that is called 10 times a second and see if that works.

Edit: umm you said local server sorry getting late over here. Time for bed. :zzz:

Thank u and good night :">

I don’t understand how you’re achieving any of the results you’re describing with the code you’ve posted here.

Pete.

This code is just for testing, i want to read data from sensor and sent to app

It works on my local server so I learn new syntax :+1:t3: You want to be a teacher instead of a student? Explain why it doesn’t redefine every loop?

You might explain the functionality :wink: because I’m a curious person…

I say it works but every once in a while it pauses displaying for a second or two and when it resumes it is a bigger number. Obviously the board keeps incrementing in the background.

It’s the Static declaration that’s confusing.
Static variables are local to a function and not destroyed when the function exits. The variable isn’t being reset to zero each time because the variable is only initialised the first time the function (void loop in this case) is called. After that, because setting it to zero is actually part of the declaration on this case, it’s ignored on future void loop cycles.

Very messy coding that isn’t going to win any prizes.

Pete.

Yes. The board keeps incrementing in the background. I think the problem is only with my server. Does my project run on your server?