Alarm & Sound Widget
Available to PLUS and higher subscribers.
The alarm and sound widget creates an alarm in the Blynk.Console. It is triggered by a datastream value other than zero (0).
The alarm and sound widget has the following controls:
- On / Off: Disables (mutes) the alarm, or resets it.
- Alarm Sound: When the ‘Allow end-user to change the sound’ widget option is enabled, the user can select the alarm sound to be played when the alarm is triggered.
Blynk.virtualWrite(V1, HIGH);
or
Blynk.virtualWrite(V1, 1);
Any integer value other than zero (0) will trigger the alarm. The alarm can be disabled by changing the datastream value to zero (0) by using the
Blynk.virtualWrite()
command. You can change certain properties of the widget from your hardware using the command:
Blynk.setProperty(vPin, "widgetProperty", "propertyValue");
Where:
vPin
is: virtual pin number the widget is assigned towidgetProperty
: property you want to changepropertyValue
: value of the property you want to change
Don't put
Blynk.setProperty()
into the void loop()
as it can cause a flood of messages and your hardware will be disconnected. Send such updates only when necessary, or use timers.Blynk.setProperty(V1, "isMuted", "true");
https://{server_address}/external/api/update/property?token={your 32 char token}&pin=V1&isMuted=true
Blynk.setProperty(V1, "label", "AlarmnSoundWidget");
https://{server_address}/external/api/update/property?token={your 32 char token}&pin=V1&label=AlarmnSoundWidget
Get the latest known value from the server. For example, after your hardware went offline and then came online again.
BLYNK_CONNECTED() { // checks if there is a connection to Blynk.Cloud
Blynk.syncVirtual(V1); // get the latest value
}
BLYNK_WRITE(V1) // this command is listening when something is written to V1
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
if (pinValue = 1){
// do something when the sound and alarm widget is triggered.
} else if {
(pinValue = 0)
// do something when the sound and alarm widget is disabled.
}
}
Last modified 4mo ago