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:
- 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
- Make sure that you correctly add the IP address with the following line:
Blynk.begin(auth, IPaddress(192.168.1.4), 8080);
- Press Ctrl + O, followed by Enter, followed by Ctrl + X.
- Build the project with the following command:
pi@raspberrypi:~/blynk-library/linux $ ./build.sh raspberry
- Run the project with the auth token associated with your Blynk app project:
pi@raspberrypi:~/blynk-library/linux $sudo ./blynk --token=e6d7cfa77b9e4dce9ca15bd7bfdf27e6
- You will get the following output on the console:
Blynk application is up and running