How to control anything with Blynk app
Turn your things On / Off or send any data from Blynk app to hardware
This documentation is for the LEGACY version of Blynk platform which is no longer supported and will be shut down.
You can sign up for the current version of Blynk platform here.
The new mobile apps can be downloaded from App Store and Google Play.
The actual Blynk documentation is here.
Blynk can control any electronics, GPIOs, relays, anything. You just need to know the basics, which are super simple.
☝️ You need Blynk library installed. Here is the guide how to install Blynk Library.
There are two ways of turning things ON and OFF with Blynk:
Simple. Directly controlling Digital I/O pins with no coding;
Advanced, using Virtual Pins and simple code;
In this article we will describe both cases.
Let's try turning on/off LED connected to Digital Pin D3 of your hardware.
Control GPIOs with no extra coding
In Blynk app:
Create a New Project (new Auth Token will be sent to your email);
Add Button Widget;
Go to Widget Settings;
Set PIN to D3 - this where you tell the app that Button will turn ON and OFF something;
Set Mode to Switch;
Preparing the basic code:
Use our Blynk Examples Sketch Builder to create the code for your hardware.
Choose your board;
Choose your Connection (WiFi, Ethernet, Bluetooth, USB, ...);
Browse through examples and choose the one you need;
Sketch Builder will create a code for you;
Copy the whole code and paste it to Arduino IDE;
Input your Auth Token
In the example sketch find the line:
Change it with your own Auth Token (it should be in your email inbox after you created the Project in the Blynk app).
Now this line should look similar to this:
🔥 Flash the example code to your hardware.
Advanced. Using Virtual Pins to turn things ON and OFF
Sometimes, triggering single Digital Pin is not enough. Sometimes you need more flexibility. For example, how to control brightness of 3 LEDs using one Slider Widget, or trigger a a whole set of actions with 1 button?
We've got you covered.
In Blynk app add a Slider Widget and set it to use Virtual Pin V1;
Change this basic sketch to match your hardware and connection type;
🔥 Flash the example code to your hardware;
Let's try to understand the code. Look at this block:
This is where we tell the hardware what to do when there is a WRITING command from Blynk app to Virtual Pin V1.
Our Slider widget sends data to V1:
☝️ BLYNK_WRITE should be placed OUTSIDE of void loop(); The next line is to get the actual incoming value:
Where, is how you define the incoming data type:
If you need other variable type, you can also use:
...and then we just print the slider value to Serial Monitor
This approach gives you endless opportunities on how to use incoming data from the app in a very flexible way. For example, you can create a set of actions in the function that will be triggered by one click of the Button:
---
If you have questions or something is not working, visit our 👥 community page.
Also, full 📗 documentation is here.
Last updated