Android widget "Reading Rate" update interval value does not save

I have a Particle Photon running this Blynk library (which by the way needs heavy modification to actually work on Particle devices since they do not allow directory tree structured libraries, but I posted that issue on the github) to transmit my weather station data, and the Blynk Android app. Everything’s working nicely, I can see my weather station data in the Blynk app, and on the widgets.

The problem is I can’t figure out how to set the update interval for the widgets, the “Reading Rate”. In the app itself, I have them set to “PUSH”, and my code pushes the data to Blynk once every 20 seconds.

And this is the relevant code in the void loop section on the Photon set to update once per 20 seconds:

if (timer1 < 1) { //Update sensor data every 20 seconds
              Blynk.virtualWrite(V0, tempavg);
              Blynk.virtualWrite(V1, humavg);
              Blynk.virtualWrite(V2, presavg);
              Blynk.virtualWrite(V3, abshum1);
            timer1 = 20;
          }
		  timer -= 1;
        Blynk.run();

But the Android widgets, is where things get confusing. Actually, doubly confusing since you guys call the little icons in your OWN app “widgets”, but I’m referring to the Android widget that I place on the Android home screen, next to all my app icons. This is the screen I get when I tap on a widget:

Under “Reading rate”, there is no setting for “PUSH”, only time intervals. And I’m not sure why it even needs a setting for reading rate, since I would have assumed it would just copy the reading rate from the app screen. And if I try to set it to 20 seconds, first it will give me a warning about battery usage, then I hit the back button, and it doesn’t work, I have no idea what interval it is updating at but it isn’t 20 seconds. And if I go back into the widget properties by tapping on it, it still says 15 minutes. It isn’t saving the value I’ve selected.

VirtualWrites in the loop, a huge no no.

Please study the documentation and especially the PushData example as this is what you want to start from and modify.

You need to use a SimpleTimer to create the 20sec updating timer.
The Reading Rate in the widget settings is void when using this method… so just set everything to PUSH.

I mean, it would be a huge no-no if I was flooding the server every loop with VirtualWrites, but I’m not, I’ve coded my own timer. I should add there’s another millis() check in there that I forgot to include in the relevant code (which is exactly how SimpleTimer works as well, by the way), this is all inside of this:

  if (millis() - lastmillis >= 1000){ 
        lastmillis = millis();
 //Do all this stuff once per second, including subtracting my timer1 from 20 to 0 once per second
} 

Sorry, I forgot to include that in my post here, that’s my bad, and just looking at the code I included in my previous comment alone, it would be pretty bad as it would be updating to Blynk hundreds of times per second. I coded my own timer because I already know how, I’m already using this code to update to Ubidots once every 20 seconds, it works the exact same way as SimpleTimer, and I didn’t want to have to port another Arduino code to Photon.

Ah okay, but while the in-app widgets are updating once every 20 seconds every time my code pushes an update, the Android widgets don’t appear to be. If I open up the Android app and stare at the widgets, I can watch them update once exactly every 20 seconds. But if I go back to my Android home screen and stare at those widgets, they don’t. They appear to have fresh data every time I unlock my phone but I have no idea when they’re updating since I can never see it update before my eyes. Maybe it’s an Android issue and not a Blynk issue? Maybe it’s set to only update every time the screen unlocks?

Photon’s have their own timers, you don’t need to port any.

Right no I know, I’m referring to the “SimpleTimer” library. I had already written code to update once every 20 seconds to Ubidots, and I figured I’d just throw the Blynk stuff in there too, rather than figure out how to get the SimpleTimer library working on the Photon. It works fine, it isn’t flooding Blynk with virtualwrite pushes hundreds of times per second or anything like that, but I did forget to paste the relevant millis() check in my “relevant code” sample here which probably freaked out Jamin.

1 Like

I’m just saying Photon’s have their own, ready made version of SimpleTimer. Worth repeating, so I have.

Ah okay, thanks, but I guess I already wrote all this 20 second interval code stuff when I was writing for Ubidots, and I do it using millis() checks, and it works fine so why change what works?

As for the Android widgets, they appear to be updating once every 15 minutes, like their settings indicate, or when I open the main app. While the main app may be getting virtualwrite pushes once every 20 seconds, the homescreen widgets themselves appear to only be checking the main app or cloud for new values once every 15 minutes. But also they will update themselves instantly if I open the main app. It would be nice if I could change that interval like the settings indicate but I can’t because it doesn’t save.

I’m surprised your Photon version of Blynk is so different to a regular version of Blynk.

Have you tried deleting the widget and starting again?

It’s not that different, I just decided to use my own existing timer instead of using their suggested SimpleTimer.

Well I tried deleting the homescreen widget and adding it again. Kinda wishing I hadn’t though, because it cost me 100 energy credits which, unlike the in-app widgets, do not get refunded when you delete the homescreen widget. So each time you delete and readd a homescreen widget, you lose an additional 100 credits.

And it didn’t fix it. It’s still only updating once every 15 minutes, and it still won’t allow me to change that “reading rate” value in the widget properties. Or rather, it appears to allow me to change it, but doesn’t actually save the value and reverts to 15 minutes when you next check the widget properties.

Blynk’s suggested SimpletTmer is “suggested” because it is fully compatible with the background workings (timings) of Blynk.

I have tried mucking around with my own timing solution that worked great outside of Blynk, but not with Blynk, until I realised that fact for myself :blush:

Thus, if you are having timing issues, I also would “suggest” you use the SimpleTimer.

But not for the Photon as I keep saying.

A good example of the required timer for Photon’s (SparkCorePolledTimer replacing SimpleTimer for Arduino /ESP’s) can be seen in the Photon Garage Door Controller.

Wouldn’t recommend anyone uses their own timers with Blynk when ready made libraries already exist.

I was just reiterating what you said :slight_smile: But didn’t think I needed to re-specify the Photon ver of SimpleTimer… my bad :blush:

1 Like

Back to the real context of the thread.

@moeburn I must apologise, despite your clear references to ANDROID WIDGETS I wrongly thought you were referring to BLYNK WIDGETS. That said, when I last used the Blynk Homescreen ANDROID widget I did receive a warning that Energy is not refunded. This is because the widget is outside of Blynk’s control.

Just tried to check the update interval on my Android but unfortunately it doesn’t work for me at all.

@Dmitriy on your cloud server (not available on local servers) when I try to use the Homebutton widget I receive the following error message.

Your profile is empty, please use Blynk to create a project.

The process continues but neither buttons nor Labelled values can be selected.
Not sure if this is because I have too many projects rather than no projects.

@Costas where this error comes from? It is on home widget click?

@Dmitriy yes when I select home widget and it takes me to my “many” projects to select a button or a value display.