Reading accelerometer data

Now you're ready to write a code on your Raspberry Pi to read the accelerometer on your smartphone. The code will output accelerometer values on the x, y, and z axes of the smartphone or tablet in m/s2:

  1. Modify the main.cc file with the source code listed in Listing 6.1:
Listing 6.1: Reading the accelerometer on the smartphone
  1. Then, save the file and exit the nano text editor by pressing 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. Then, run the program with the auth token associated with your Blynk project:
pi@raspberrypi:~/blynk-library/linux $sudo ./blynk --token=ca7bed1c92214503a65de8e20164994f ...

Get Hands-On Internet of Things with Blynk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.