Writing a simple code to build the connection

To connect the Raspberry Pi hardware to the server running on the same or a different Raspberry Pi, you should have the minimum code to make the connection. To set up the connection, go through the following steps:

  1. Open the main.cpp file and remove all the existing lines. Then, type in the code under Listing 7.1. Use the following commands to open the source file:
pi@raspberrypi:~/blynk-library/linux $ cd blynk-library/linux
pi@raspberrypi:~/blynk-library/linux $sudonano main.cpp
Listing 7.1: Connect with local Blynk server
https://github.com/PacktPublishing/Hands-On-Internet-of-Things-with-Blynk/compare/master...TrushaShriyan:patch-1
  1. Make sure that you correctly add the IP address with the following line:
Blynk.begin(auth, IPaddress(192.168.1.4), 8080);
  1. Press Ctrl + O, followed by Enter, followed by Ctrl + X.
  2. Build the project with the following command:
pi@raspberrypi:~/blynk-library/linux $ ./build.sh raspberry
  1. Run the project with the auth token associated with your Blynk app project:
pi@raspberrypi:~/blynk-library/linux $sudo ./blynk --token=e6d7cfa77b9e4dce9ca15bd7bfdf27e6
  1. You will get the following output on the console:
Blynk application is up and running
..................Content has been hidden....................

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