Hello everyone! I have an arduino uno and sim900 gsm shield with things mobile sim card. It almost takes a whole megabyte a single day. For example, i have a relay that i control with blynk and when i press go on my app the relay almost clicks immediately and it would not have to… it could wait till a minute.
Would there be a way to slow the process down so that it would not take so much data?
Im wondering if you re-established communication every minute just to update the pin, if it would end up being the same amount of traffic. Im running some traces right now on my nodemcu to see how much data it uses with each type of config.
Just so i can share my results pertinent to you faster, are you running just a basic blynk starter sketch, where you are using the app to change the Dpin or something with some Vpins in it and more than one pin being called?
Blynk needs to talk to the server constantly to check for any changes resulting from widget operations in the app. I think it maybe does this each time Blynk.run executes.
You could do a Blynk.disconnect, then have a timer do a Blynk.connect every minute. It would probably need to be followed by a Blynk.syncVirtual(vPin) then another Blynk.disconnect.
The disadvantage is that the device would show as offline in the app most (if not all) of the time.
What does your sketch with the 1 minute Blynk disconnect look like?
Any comments I make about what may and may not work are just speculation - I haven’t tried this approach and don’t have the hardware that you’re using, so it’s really down to see what works - I’m just trying to feed you ideas.
Other may have tried what you’re attempting and have some insight as a result - if so then I’m sure they’ll chip-in.
I ran just a connectivity script. No PIN data was sent back and forth. My client and my phone app stayed connected for 1.5 hours.
It showed 100K or traffic. 66.6K sent by the client 33.3K sent by the server.
Resulting in :
1.5 hours X 8 = 24 hours
100K X 8 = 1.5MB
In one full 24 hour day, 1.5MB would be sent/recieved.
I’ll run another study after supper where i disconnect and reconnect again every minute. (i have to write it first)
Heres the code i ran, notice i did add a virtual write in there… just a tiny one. to make sure i had real life scenario connectivity. I wasnt sure if the write would always be successful before the disconnect. It turns out it was always successful, but if i were you i would still put an extra check before the disconnect. Im on my local lan, so my connectivity would be optimal compared to gsm.
Thank you for taking the time to help me! I’ll do more work on that but im installing this operation tomorrow so times kinda up! It just will cost around 50$ max a month. It only gets used a couple month’s a year. I will also be installing more. I emailed blynk and this is what they said
In case of the local server - check the logs (in the trace mode) so you can see how many times hardware reconnects during the day. It may happen that the main issue is due to often connections drop;
How exactly do you use the app? During this testing day what functions do you use? Do you have some timers, eventors, SYNCs?
It sounds like it’s too late to come-up with a workable solution at this stage in the game, but there’s obviously a need to have something better in future, so here’s my thoughts on what’s been said so far…
With @lvennard’s test code, I don’t know if there’s any benefit in doing a Blynk.begin in void setup, followed by blynk.connect and blynk.disconnect in the void runME() function?
If you were going down the webhooks route then you don’t need any Blynk code at all, so the Blynk heartbeat settings are irrelevant.
You’d need to create an HTTP client object and make GET calls to check on the button state. The Blynk API allows GET to be used as PUT, so GET can be used for inbound and outbound API calls - if there any need to upload data as well as look for “instructions” in the form of button widget changes.
I rejected the idea of using webhooks when @danhoo first outlined his problem, as the amount of data that needs to be sent to make the API call is quite large. There might be a better way to make the call that uses less data - it’s not something I’ve ever tried.
Webhooks are great when you want a device to wake-up, connect to the network and quickly exchange some data then go back to sleep. Speed is good, but I think the quantity of data exchanged is probably fairly high.
I think the best option might be a different type of SIM contract, which maybe allows data bundles to be purchased at a lower cost than if you’re just paying by the megabyte.