I tried a lot with Blynk timer but it is unable to read from the module. But, still this code is able to run for 10 seconds without Blynk timer. Can someone plz help.
As I have already stated… there is a Blynk heartbeat of about 10 seconds… in which your code can sit there and work, not work, twiddle it’s itty bity bytes or flat out do notheng… but if if after those 10 seconds, Blynk can not get on with it’s required housekeeping, then your wholes sketch stops.
So please stop using the blocking while() loop and focus on learning how to use timers instead of while() to get the job done
Dude as you told me to change the while loop i tried to modify by using if loop. On using it without Blynk it gives the right response but when i use it with Blynk, it gives nothing.
I am not even getting output for 10 seconds as i was getting using while statement using Blynk. Can you please tell where i am wrong.
void loop()
{
Blynk.run();
if (ss.available() )
{
if (gps.encode(ss.read()))
{ if (gps.location.isValid())
{
Serial.print(F("Latitude: "));
Serial.print(gps.location.lat(), 6);
Serial.print(F(" Longitude: "));
Serial.println(gps.location.lng(), 6);
}
} }
}
I studied about interrupts and timers and about blynk timer. I never used Simple timer before so i am new to it. Can you please tell if my timer code is technically correct. Secondly, can you please tell me where i should use which time interval. I am not clear about that .
And what does it really mean in GPS problem. Does this has anything to do with my problem:
I don’t have any of those GPS devices to test, but probably something like this in a timed loop…
In your case, set for every 1000ms (1 second) or whatever works best for you.
timer.setInterval(1000L, myTimerEvent); // This goes in the void setup() and runs the function every 1 second
void myTimerEvent()
{
if (gps.encode(ss.read())) // I don't know why you need an if condition here?
{
if (gps.location.isValid())
{
Serial.print(F("Latitude: "));
Serial.print(gps.location.lat(), 6);
Serial.print(F(" Longitude: "));
Serial.println(gps.location.lng(), 6);
}
}
}
I am unable to find any gps codes linked to Blynk. Bro, i have very less time left to finish my project so plz i need to solve it quick. Btw, thanks for all ur help.
Blynk is a IoT GUI interface… so it has uses in multiple fields, not just GPS, of which there are many, many differing ways to process that data… but the particular method you seem to need might be a little too demanding in it’s own timing needs.
I suppose you could try to reintroduce the while() but add in another Blynk.run(); command after every data dump (e.g. coordinate printout and Blynk.virtualWrite() - if used) as that will allow Blynk to keep up with it’s own timing needs for housekeeping and communication.
Then tweak your timer until you get a smooth data flow without causing flooding from too much data flow to the App or disconnections from not enough Blynk housekeeping.
As I said, I have nothing to test or compare with (and my own projects to work on), so while I can throw out a few ideas, you need to keep reading and trying things on your own as well… a lot of the flooding and disconnection reasons and solutions have already been documented and discussed in this forum.
@costas i read the article. Unable to run with my setup. I have error in ESP.wdtFeed(); Maybe its because i am using a {arduino + esp8266} and not esp8266 shield.
Can you please provide me with the final fixed code you got. Its very urgent. Ineed to finish soon. I tried everything but nothing is working.
@Abhinav_Thakur don’t mess up the site with duplicate posts.
Have you actually tested your Arduino + ESP with anything simpler than GPS?
I happen to know that you use ISP’s that are quite different to what most Blynkers use. It could be something as simple as that. If you haven’t already tested the basic Blynk examples forget GPS and work through them with as much Serial Monitor data as you can get.
Don’t forget that Arduino’s weren’t designed to work with ESP’s and you will get much better results using ESP’s in standalone mode.
@Costas i’m new to this platform but i did try some things before. Btw i am unable to do it on blynk that’s why i am asking for help. This platform is different and there are not much examples to look into.
Dude dont try to mock me but i have done those things before. I am asking for help.Plus i have wasted too much time here. If you can, its cool and if you don’t then plz don’t