Get Start with Blynk

You will learn how to use Blynk in this project.

In the event that you trigger widgets on Blynk, your Raspberry Pi will print out their values.

Follow the steps below, and note that you must do them in order and not skip any chapters.

1. Configuring the Blynk

  1. Go to the BLYNK and click START FREE.

    ../../_images/sp220607_142551.png
  2. Fill in your email address to register an account.

    ../../_images/sp220607_142807.png
  3. Go to your email address to complete your account registration.

    ../../_images/sp220607_142936.png
  4. Afterwards, Blynk Tour will appear and you can read it to learn the basic information about the Blynk.

    ../../_images/sp220607_143244.png
  5. Next we need to create a template and device, click Cancel.

    ../../_images/sp220607_143608.png
  6. Go to Template from the navigation bar.

    ../../_images/sp220913_170029.png
  7. Create New Template

    ../../_images/sp220913_170206.png
  8. Fill in NAME, feel free to do so; HARDWARE should be Raspberry Pi. Then Done.

    ../../_images/sp220913_170402.png
  9. You will be redirected to the Info page, just click on save in the top right corner.

    ../../_images/sp220913_171202.png
  10. Go to Search page from the navigation bar.

    ../../_images/sp220913_172727.png
  11. Create New Device.

    ../../_images/sp220913_173259.png
  12. From template.

    ../../_images/sp220913_173350.png
  13. Select TEMPLATE as the one you just set, DEVICE NAME can be customized. Then click Create.

    ../../_images/sp220913_173507.png
  14. You should now see a page like this one, which means that your initial Blynk setup is complete.

    ../../_images/sp220913_173950.png

2. Edit Dashboard

  1. Click on the menu icon in the upper right corner and select edit dashboard.

    ../../_images/sp220913_180231.png
  2. Then drag any CONTROL Widgets you want onto the Dashboard. I dragged a Switch and a Slider.

    ../../_images/sp220913_180725.png
  3. Tap the setting icon on the widget.

    ../../_images/sp220913_180806.png
  4. Create Datastream, select Virtual Pin。

    ../../_images/sp220913_180906.png
  5. Complete the datastream setup. Here is the datastream created for Switch, so DATA TYPE select Interger, MIN and MAX set to 0 and 1. Create and then Save.

    ../../_images/sp220913_181113.png
  6. Use the same steps to create a Datastream for the slider widget, and again, modify DATA TYPE, MIN and MAX to what you need.

    ../../_images/sp220913_182042.png
  7. When finished, click Save And Apply at the top right.

    ../../_images/sp220913_182300.png

3. Install the Blynk library

Run the following command to install.

cd /home/pi
git clone https://github.com/vshymanskyy/blynk-library-python.git
cd blynk-library-python
sudo python3 setup.py

4. Download the Example

We have provided some examples, please run the following command to download them.

cd /home/pi
git clone https://github.com/sunfounder/blynk-raspberrypi-python.git

5. Run the Code

  1. Go to Blynk’s Device Info page, you will see some information under FIRMWARE CONFIGURATION, you need to copy BLYNK_AUTH_TOKEN down.

    ../../_images/sp220913_182456.png
  2. Edit the code.

cd /home/pi/blynk-raspberrypi-python
sudo nano blynk_start.py
  1. Find the line below and past your BLYNK_AUTH_TOKEN.

BLYNK_AUTH = 'YourAuthToken'
  1. Run the code.

sudo python3 blynk_start.py
  1. Go to Blynk, and operate the widget on Dashboard.

    ../../_images/sp220913_183529.png
  2. Now you will be able to see your actions on the terminal.

..
   ___  __          __
  / _ )/ /_ _____  / /__
 / _  / / // / _ \/  '_/
/____/_/\_, /_//_/_/\_\
        /___/ for Python v1.0.0 (linux)

Connecting to blynk.cloud:443...
Blynk ready. Ping: 142 ms
V0 value: ['1']
V0 value: ['0']
V1 value: ['3']
V1 value: ['8']
V0 value: ['1']