Hi,
We have built up Sensors for low power batt communication.
Main parts are ESP32 and a Simcom7080g unit.
Here specialy a Rain Sensor. We send once a day all data to blynk via the https api with a batch update:
https://docs.blynk.io/en/blynk.cloud/update-multiple-datastreams-api
The main time the ESP is in a deep sleep and only starts if there comes a rain interrupt or at midnight for sending.
So our main problem is to update the online state. All Sensors show offline.
Is there a possibility to change this via the https api?
I have try to do this with an event (Send/Log An Event - Blynk Documentation) and as code=ONLINE. But this won´t work. Are there other options?
I wanted to do it in such a way that the online status is triggered online every 24 hours and resets to offline after 24 hours.
I think without this option the HTTPS Api isnt usable for low power devices…
The Blynk cloud servers don’t treat tge device as being online when an HTTP(S) API call takes place, so unless you do a regular Blynk.begin() connection, the device will always appear offline.
You could use the data invalidation settings in the datastream advanced settings to alert you to the fact that the datastream hasn’t been updated for >24 hours.
Pete.
The problem is, the enduser always get an ofline state in the app, so an alert isnt an option!
For the first tests we have use a datastream bool with a 24h reset to 0.
Furter we can not start a connection all the time only for the online state.
We want to increase the devices and go a few month with 50users. At the moment the show stopper is the Online state.
In the Https Api description (Send/Log An Event - Blynk Documentation) is described, that it is possible to trigger a Sytem event (Events - Blynk Documentation) including the online and offline state. Why can´t i easily send an trigger (/external/api/logEvent?token={token}&code=ONLINE) and set the Offline ignore time to 24h??
I don’t really understand this comment. When I said:
I wasn’t referring to notifications, I was talking about the data being invalidated.
Because that not how it currently works.
If you created a connection via Blynk.begin() rather than the HTTP(S) API then disconnected afterwards then you could use the “Offline Ignore Period” in the template settings to work around the up issue, but as far as I’m aware this doesn5 work when using the HTTP(S) API.
Pete.
This means, the user get all the time an offline state in the App. I understand that there is a way to inform the user that there is something wrong, with an notification. Sorry for the bad sentence. But i want to set the offline state to an online state.
So without this future i think the https api isn´t an option for a low power device connection.
Because that not how it currently works.
If you created a connection via Blynk.begin() rather than the HTTP(S) API then disconnected afterwards then you could use the “Offline Ignore Period” in the template settings to work around the up issue, but as far as I’m aware this doesn5 work when using t!
But it is describe like that in the docs.=>
_docs.blynk.io/en/blynk.cloud/trigger-events-api
_docs.blynk.io/en/getting-started/events-tutorial#system-events
Blynk recommends the https api for low power devices. But whats the point of the state when i cannot use it?
=>
“Traffic optimization is usually required for cellular connections. Using realtime streaming protocols like Blynk or MQTT has benefits of interactive device updates, but it also requires device to stay “always connected”, which significantly increases the traffic. Blynk recommends using https API for reporting telemetry and fetching DataStream
values periodically in such scenarios. It will also help saving the battery.”
I think i get many phone calls when i sell a device where the enduser always gets “offline”…
You can use it, you just have to acknowledge that the online status reflects reality - the device does not have an active keep-alive connection to the Blynk server.
The device is asleep 99.9% of the time and therefore not online.
Blynk have provided a workaround to this if you create then disconnect a keep-alive connection then use the “Offline Ignore Period” to ignore the fact that the device is offline, but an update or query from the HTTP(S) API has never been regarded as an online event.
Whether Blynk will change this at some point I don’t know, but in the meantime the solution is to create the keep-alive connection, perform the data update, then drop the connection (or simply put the device into light or deep sleep, which will do the same thing.
In reality, because Blynk.begin is a blocking function, you’d be better manually creating the WiFi connection then using Blynk.config and Blynk.connect to create the keep-alive connection.
This way, if the connection to either WiFi or the Blynk server can’t be established for whatever reason, the device can actually make it to the point where the light/deep sleep command is executed and the device won’t drain its battery by staying awake constantly.
Pete.
I cannot use this, because I didn’t have a WiFi connection. The WiFi is only in use in ap mode for an update. I use only the HTTPS API over the sim7080 (LTE NB). I use 10mb SIM cards for the connection. At the actual state I reach a battery lifetime of round about 3 until 3.5 years. Because of that I cannot perform such thinks.
You are right with the online state, but a normal enduser think: online: all fine, offline: something went wrong…
Okay, I used the term WiFi because I assumed that was your connection method. Now you’ve clarified that you are using a SIM card, then why not use GPRS for your Blynk connection?
Then it’s up to you to explain this in your documentation - it is actually a reflection of the real state of the device.
Pete.
I have try the Blynk GPRS connection but it needs a much higher Energie consumption so it isn´t a way.
I think it is not an option to explain it in a Manual. When you need to reed a Manual for an app, it isn´t an good app…
So, if you buy a Sensor with an App and there is shown all the time offline, what do you think??
I think it isnt a way to go ahead without the online state. For me two solution; Blynk change it in the https api or we proceed with another Service. But it is very troublesome to communicate with Blynk. We have put a lot of work in it, so it is very sad that it failed because of such a small thing…
Have you written your code so that it makes a connection, uploads your data then immediately disconnects?
I’ve done tests in the past comparing a Blynk connection versus an API call to Blynk and the data usage differences are very small.
Pete.
HTTP Api call Batch update:
runtime 3,4s with round about 135mA average => 127uAh
Blynk connection:
runtime 9,1s with round about 127mA average=> 321uAh
(runtime=deepsleep to deepsleep)
Same Hardware configuration with 100 go through for each configuration
possible that there is something to optimize, but that is approximate three times higher
With the HTTPS api I can fire the data and go back to deepsleep.
Do you want to share your Blynk connection code?
Pete.
Sorry, no, because there is many own code inside. At base i have used TinyGSM…
You broke my heart. I was so hoping to change the status of the device using the API.
Have you checked Connection Lifecycle feature?