Writing a notification

Let's build a simple project to send a notification to the smartphone or tablet for the button press event. You can use the same hardware setup you built in the previous section:

Listing 5.3 shows the complete code to send the notification from your Raspberry Pi:

Listing 5.3: sending notification for the button press event

The Blynk.notify() function allows you to mention your own message as a notification:

Blynk.notify("Yaaay... button is pressed!");

Refer to the following steps:

  1. Type in the preceding code by opening the main.cpp file. Then, save and exit the nano text editor by pressing Ctrl + O, followed by Enter, followed by Ctrl + X.
  2. After that, build the project by issuing the following command:
pi@raspberrypi:~/blynk-library/linux $ ./build.sh raspberry
  1. Now, you can run the project with the auth token associated with the project:
pi@raspberrypi:~/blynk-library/linux $sudo ./blynk --token=ca7bed1c92214503a65de8e20164994f
  1. To test the application, press and release the push button attached to BCM_GPIO pin 23 of the Raspberry Pi. Immediately, you will get a notification on your smartphone or tablet:
A Blynk notification
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.136.154.103