CREATE YOUR OWN IOT APP WITH BLYNK

To be able to interface with some of your IOT projects might be the end goal. Their are a lot of platforms as a service (PAAS) available that you can use (I for example use Losant as my go-to platform) but most of them are web based and still requires a bit of setup to get started. 

This is where Blynk comes in. Blynk is an IOT platform that is mobile based and makes it easy to connect to any hardware platform in minutes. I tested this with my existing Particle Argon to see how easy it is.

Getting Started

First thing to do is download the Blynk app on your phone from either the Play store on Android or the App Store on IOS. Once downloaded you will need to create a user account for yourself on Blynk. You will need to use a valid email address as this is later used. 

Once you have registered your account you will receive a welcome email

Blynk account registration email

There is allot of useful information in the registration email that you can use to get you on your way.

After registration you are ready to create your first project. In your Blynk app select create new project.

Blynk Create New Project

Once you have selected the create new project option in your app a new screen will open requesting you to provide details on your hardware device, project name, internet connection type and theme mode. As the Particle Argon board is not listed under device types, I have chosen a generic board and WiFi Connection.

Once your project has been created you will receive an email with your authorization token. This token will be used in your hardware or software platform to send data to your blink application. Once your project is created you will be presented with a screen showing your project settings. Here you can make changes for your needs and continue by pressing the OK button in the top right corner.

Blynk Project Settings

The development screen is a blank canvas to add new widgets to the screen you can tap anywhere on the screen. This will open the widgets window.

Blynk Widget Box

From here you can select the display that you would like to use. A quick note here on the Blynk Energy Store. Energy is a credit allocation used for each widget. When starting a new project  you are presented with 2000 energy points for free. To use more you will need to add energy points which will be paid for. 

To add a value display, click on the value display. A new display value is added to your canvas. Click on the newly added widget and the configuration menu will be opened. Settings are provided here to customize your display and set where the display data is obtained form (see common widget display docs). 

Give your widget a name and under inputs link it to a pin. When clicking on the input pin (In above image it shows V0 in green) a new configuration window appears.

There are three different pin types. Analog, Digital and Virtual. Analog and Digital refers to the actual pins of your hardware. Virtual is a virtual pin that allows you display any value created in your sketch that is not directly connected to your hardware but has had some form of manipulation applied to them, such as sensor data. Here it is important to go through the documentation, in this case read about virtual pins. My example makes use of pin V0 and scaling has been switched on. 

I have also selected to push data from the hardware into Blynk under referesh interval. This allows data to be pushed to blynk irrespective of the app being open and allows you to control the data retrieval interval reducing the amount of traffic from your hardware to the cloud.

Next a super chart is added again for pin V0 to display a graph. 

 

The super chart has various settings of which I have left most to default and have only linked V0 as temeprature to the chart. To link V0 click on the equalizer icon next to the data stream (In my case the Temperature data stream) as shown above in the first image. 

Blynk Super Chart Data Stream Configuration

From the above configuration chart display type, color, pin selection and a whole allot of other configurations can be done. Again I have left everything to default and only linked the data stream to input V0.

My canvas now looks as follows (Note my canvas has already been linked to data)

The integration on the hardware side has been made very easy with blynk and they provide a ton of different example integration found here. My hardware has been selected as a generic hardware board and I will make use of a Webhook in particle's console to send data to blynk. To do this I did some googling and came accross a brilliant article in the blynk community describing how to do this. First a Webhook needs to be created in your console by going to Webhooks and selecting new integration as shown below.

After selecting the new integration above, select Webhook as shown below.

Next give your webhook a name. Important this name should be the same as the name used for the data that you are publishing from your hardware to the particle cloud. In my case this is feedback2. Next under URL you need to provide the url in the format: http://blynk-cloud.com/YourToken/update/YourPin. Make sure the request type is get and request format is Query Parameters. Under device link the webhook to your particle device. Finally under custom you need to provide a value key pair for the value that you would like to link to your Blynk pin. In my case that presented by my device to the cloud is already in JSON format and therefore the value is presented in the JSON mustache format. If you have just published a single value to the cloud then you will use the following format instead: {{PARTICLE_EVENT_VALUE}}

 

That's it your done, data should be streaming to your blynk application now. If not you can start debugging by looking at the bottom of your web integration for errors.

Each of the reset sent requests can be opened and you can further drill down to get more information. You can also go to the Blynk API documentation. Here you can go to the console and send a mock message to your blynk app.

Just add your token and pin number into the provided parameter area and press the Get Resource button. You should see that your value on your app is updating. 

Blynk is a powerful and easy to start software platform to get you started though the free version is very limited it will still allow you to get some information of your project visualized easily. Blynk provides great documentation and resources to make your integration as easy as possible and allows a quick and easy way to bring your proof of concept to life.

Leave a comment

All comments are moderated before being published