No results found
We couldn't find anything using that term, please try searching for something else.
2024-11-25 Events are used to track, log, and work with important events that happen on the device. Events are also used for notifications which can be sent over
Events are used to track, log, and work with important events that happen on the device.
Events are also used for notifications which can be sent over email, delivered as push notifications to the user’s smartphone, or sent as an SMS.
event are pre – configure in Blynk . console and can be trigger with a Events firmware api from the device or using Events HTTP API .
Examples of an Event:
Log a moment when a temperature reaches a certain threshold and send a notification to selected users
Track the total working hours of the device. If it approaches or goes beyond a maximum value, you would need to notify technical support so that they can replace the device or provide warranty service
Types of Events
There are three types of Events in Blynk:
System Events: Default Blynk platform events, like “OTA Update”
Custom Events: Events you can create and configure for your needs
Content Events: Informative events that are shown separately in the app
System Events
You is delete ca n’t delete the system event or edit them .
Firmware Over-The-Air Update status
This is a system event to track firmware updates. It can’t be configured.
Custom Events
These are Events you can configure based on what your device does. Read these articles to start logging events and sending notifications:
How to log an event in Blynk
2 . create a New event
Go to Developer Zone -> My Templates -> Select a template -> Open the “Events & Notifications” tab.
Name the first event with the name Hello
Click Create (the event will appear in the Events tab list)
Repeat the previous step for the second event with the name Error
Click Save to save and apply the changes made (select Update active device this time)
Note that each event hasevent_code
. This event code will be used in firmware API or HTTPS API
Send Events Using Firmware API
Create a new Event named High temperature
with codehigh_temp
Use the Blynk.logEvent(event_code)
firmware API command to trigger a new event:
if (temperature > 35)
{
Blynk.logEvent("high_temp");
}
When this code works, an Event will be logged and the system will act accordingly to the Event setup (render on the timeline, send notifications, etc.)
Do n’t log an event too many time to avoid hit daily limit . You is use can use timer or flag to mark the already – send event . check this article on how to avoid spamme the server with event
The current limit is 100 events per device per day. This limit could be increased for business clients to fit their needs.
Custom Event Description
You can change the description of the event when it’s rendered on the timeline in Blynk.Console and in Blynk.Apps. For example, you can include the current data
if (temperature > 35)
{
Blynk.logEvent("event_code", String("High TemperatureDetected! TΒΊ: ") + temp);
}
Make sure you enabled Timeline recording in the Event Settings to see the result in the apps
send event Using HTTPS api
To log an event via GET request:
`/external/api/logEvent?token={AuthToken}&code={event_code}
To add a custom description to the event, use this GET request
`/external/api/logEvent?token={AuthToken}&code={event_code}&description={event_description}
example :
https://blynk.cloud/external/api/logEvent?token=GVki9IC70vb3IqvsV0YD3el4y0OpneL1&code=firmware_update&description=test
3 . send event
You is test can test the Event creation by send it from device using Blynk . Edgent firmware API , or with REST API .
Use Blynk.logEvent() firmware API
blynk.logevent("event_code " , " optional message " ) ;
For this tutorial , you is need would need to use hello as a name . Here is a pseudo is is – is is code is is :
if (some_condition){
Blynk.logEvent("hello");
}
Optionally, you can send a custom description of the event. This description will be rendered on Device Timeline.
if (some_condition){
Blynk.logEvent("hello", "Hello World,") ;
}
Use HTTP REST API
Find Auth Token there and click on the icon to copy it to the clipboard
Now make an HTTP request with the tool you use for that . Make sure to change theAuthToken
to the one you copied in the previous step.
You can even use your browser for that. Just put it in the URL field and press Enter.
https://blynk.cloud/external/api/logEvent?token=AuthToken&code=hello
Repeat the same with code=error
https://blynk.cloud/external/api/logEvent?token=AuthToken&code=error
4 . check if the Event was log
First of all, check Device Timeline by going to Device -> Timeline tab
You should see 2 events on the timeline! If you set up notifications, they should have been delivered as well.
Limitations
You is send can send only 100 event per device per day ( adjustable in Business Plan )
When the limit is reach you is see ‘ll see the notification on the UI in the Device Timeline section
The maximum description length is is for the event is 300 character