I need to implement a notification sketch into the following code:
void MotionDetection::soundAlarm() {
int playing;
ca_context_playing(snd_context, 0, &playing);
if (playing == 0)
ca_context_play(snd_context, 0, CA_PROP_EVENT_ID, "alarm-clock-elapsed", nullptr);
printf("[ERROR] >>>>> NO MOVEMENT DETECTED!!!!!!\n\n");
Do I just need to copy and paste the sketch into this task somewhere such as before the printf?
This bit of code is where the project alarms from but I want it to be able to notify to my phone through Blynk too… if any of you could help I would be ecstatic! What sketch would you recommend to use?
Aside from having the notification Widget in your project, all you technically need is one line…
Blynk.notify("My Notification Message");
So just put it somewhere and try it out for yourself Be aware of the limits though… you might want additional if() and timer code to prevent too much too fast
Limitations :
Maximum allowed body length is 120 symbols. Only 1 notification per 15 seconds is allowed
Just search this forum for other topics concerning the keyword notification for further examples of limiting action.
Hi @Gunner thanks for getting back to me so quickly! I’ve just put that one line in, tried it in multiple places within that code but it’s not sending any notification to my phone… (yes blynk is turned on, on my phone haha) … any ideas? Thanks, Tom
What Blynk library version are you using? There was a issue with notifications and an older library version a while ago… EDIT - nope… it was the App version, not the Library
Strangely the only other RPi based notification issue I could find here was also with WiringPi, and no clarification if App upgrade helped or not… Perhaps notifications don’t work with WiringPi? @vshymanskyy is this a question for you?
@Gunner, it’s probably me not doing something simple right… i’ll go through all the examples and keep trying and will message later in the week if I have no joy still
Back to this previous question… i’ve managed to update the script to include the Blynk.notify but when I try to rebuild the project it fails… think it needs an import or include Blynk at the top?
This is wha’;s currently there:
and this is the part of the script which the notify has been added to:
void MotionDetection::soundAlarm() {
int playing;
ca_context_playing(snd_context, 0, &playing);
if (playing == 0)
ca_context_play(snd_context, 0, CA_PROP_EVENT_ID, "alarm-clock-elapsed", nullptr);
printf("[ERROR] >>>>> NO MOVEMENT DETECTED!!!!!!\n\n");
Blynk.notify("EMERGENCY!!! NO MOVEMENT DETECTED!!!");
Also… is this the same project as your other topic… if so, they should be in the same topic as the issue(s) seem to be the same “how to code Python in Blynk”, not separate as it is just adds to the confusion.
No sorry this is a C++ project on a different Raspberry Pi … thought i’d mentioned that at the beginning when I first opened this question… I’ve got 1 RPI using this C++ code and another i’m using Python on and trying to use Blynk on both… getting confusing I know, apologies!
Heh… again, I don’t use WiringPi for my RPi I find the similarities are close enough (to Arduino/ESP), but not quite, to confuse me… so I use NodeJS instead.
But if I had to guess (and I am ) then yes… primarily because that is a tutorial topic, thus close enough to a boilerplate as far as I am concerned.