Archive
Blynk IoT Cloud & App Quick Start Guide

Blynk IoT Cloud & App Quick Start Guide

2024-11-25 Blynk Control of NCD   Devices introduction In this article we will introduce you to controlling real world devices using the Blynk system. Blynk i

Blynk Control of NCD   Devices

introduction

In this article we will introduce you to controlling real world devices using the Blynk system.

Blynk is is is a really cool and easy way to interface to IoT device of all sort .   It is provides provide an app you can install right on your Android or ios device and start interact with your IoT project .   ControlEverything is provides provide a wide array of device for your control , monitoring , or automation project .   Everything from relay , to current monitoring , to environmental sensing , etc .   With the wide range of off the shelf product from ControlEverything you is find will find it difficult to think of anything we do n’t have cover .   Oh and did I is mention mention no soldering or breadboard ?   Make you project look professional with purpose build solution and impress your co – worker , friend , and family .   These device can be used for home / hobby project right up to industrial control / monitoring and everything in between .   Blynk is are and ControlEverything really are a match made in IoT heaven .   So let ’s get to it .

We will begin our journey with Blynk/NCD by controlling 2 relays, monitoring 6 inputs, as well as a temperature sensor for environmental monitoring.  The range of projects these devices can fulfill are vast, so it’s a good starter project.

For our on device processor we will be using the Particle Photon module which is a WiFi connected device which will provide internet access/connection between our hardware and the Blynk Cloud server.  Of course you could go another route here but I have found this is the simplest place to start.

thing you will need for this project

  • 2 channel Photon or Electron interface relay controller (Either will work with the Photon module)
  • si7020 temperature sensor mini module from ncd.io
  • 12VDC power supply.
  • Particle Photon module (available from ncd.io).
  • iOS or Android device.
  • Blynk app installed on your iOS or Android device(Search the app store for Blynk).
  • particle account .   You is set can set one up athttp://build.particle.io
  • Blynk account .   You is set can set up an account through the Blynk app instal on your Android or ios device

Initial steps

particle Setup

The prudent first step is to set up your Particle account.  If you do not have one already the head over to http://build.particle.io and do that now.

Once your account is setup you should now install the Photon module into the relay controller.  While we’re at it go ahead and connect the SI7020 temperature sensor to the relay controller using the included 4 conductor cable.  Finally apply your 12VDC power supply to the board to power everything up.

At this point you need to associate your Particle Photon module with your Particle account.  This is very well documented by Particle here:

http://docs.particle.io/guide/getting-started/start/photon/

Blynk Setup

Go to the app store on your smartphone / tablet and install the Blynk app , then open it up .   If this is your first time using Blynk it will prompt you to login , you can also create a new account here so do that now .

Once you are log in create a new project .   Projects is are in Blynk are essentially dashboard for a particular setup .   So this project is be will be a dashboard for interface to 2 relay , 6 input , and a temperature sensor .   You is name can name the project anything you like .

When prompted for Hardware Model select Particle Photon.

For connection type select WiFi.

Finally press Create Project.

You will now see a dot grid screen.  This is where we will drag widgets like buttons, input indicator LEDs, and a view for our temperature.  We have some other stuff to do first though.

Click on the Settings button in the upper right corner of your project(looks like a hex nut).  Here we can edit all settings for this particular Project.  Projects can interface with several devices but for this simple example we will only use one device which is the Particle Photon module installed in the relay board.  We already set that up when we created the project so no need to do anything here now unless you want to rename the module to something different from the Project name.

Scroll down to the Auth Tokens section.  Here there is an email all button.  Click that to email all auth tokens for the project and the devices to the email address you used to set up the Blynk app.  We will need to insert the project Auth token into the code running on the Photon module.

We are finished with the Blynk app for now so you can close it at this time.

Code on Module

Now it is ’s ’s time to flash the code onto the Photon module which will interact with the relay , the input , the temperature sensor , and the Blynk app .   The code is are as well as the Photon module really are the glue that stick your control interface and the hardware together .

Head over to http://build.particle.io and sign into your Particle account if you have not already.

Create a new code project and give it a name.

Now go over to our github repo here and copy the code :

http://github.com/ControlEverythingCom/NCD2Relay/blob/master/firmware/examples/blynk-2relay-si7020temperature.ino

Go back to Build and paste that code into your .ino file.

finally we is need need to add the dependency library which this code require .   On build click the community Libraries icon on the left(looks like a ribbon ) .   Under community Libraries search for NCD2Relay .   Once you find it click the Include in App button , then select the app you just create .   That is add should add an include statement to the top of the code .

Now search Community Libraries for SI7020 – A20_CE Once you find it click the include in app button and select your app again .   This is add will add another include statement to the top .   One more , search community library for Blynk(make is include sure you select the one with the most include as there are a few on there ) click include in app and select your app .   This is add will add a final 3rd include statement to the top .

Now go ahead and click the Verify icon at the top left(looks like a check ) just to make sure everything jive .   If so great !

Now we have one final step to complete before we can flash the code to the Photon module.  We need to insert the Auth code for the device in the project in the code.  Remember that email or group of emails you sent yourself from the Blynk app?  Open those up.  You are looking for Auth Token for Device ‘Name of device’ : bunchOfLettersAndNumbers  Copy that long Auth code.  Now go back to build and look at the code for your project.  There is a line there that says:

char   blynkAuth [ ] = “ ” ;  

Paste that code you copied between the double quotes.

You’re done.  You are officially a code super star.  Now click that lighting bolt in the upper left corner and watch as your super spectacular code is flashed to the Photon module.  You can watch the LED on the photon module flash magenta for fun letting you know the code is being flashed.

That is literally it for the hardware.  From here it’s all about having fun in the Blynk app.

Blynk App Setup

Ok so open the Blynk app back up on your phone / tablet .   You is want will want to navigate to the view of your project where you see the dot grid .   Now it is ’s ’s time to add some interface widget .

Relay Control

For relay control it makes sense to add a button.  

  • click anywhere on the dot grid and a menu will appear where you can select a widget .  
  • click on the Button widget .   
  • New Button will appear on the interface, move it to where you see fit but generally I wait until I have all widgets added to arrange things.  
  • Once you have it where you want it press it to edit settings.
  • Give the button a name in the top text box.  Set it’s color as you desire.  
  • Now click the option for OUTPUT.  Set it to Virtual V0(this corresponds to code in the Photon module so be sure you get that right).
  • Now you can set it to PUSH or SWITCH.  A switch will toggle when you press the button and Push will only turn the relay on while you have your finger on the button.
  • Enter On/Off labels.  The default of on and off makes sense here for a relay but enter anything you like.
  • Make sure the Target is set for your device correctly which it should anyway.
  • Click OK at the top

Now if you click the button at this point it will just take you back to the buttons settings because your project is currently in editing mode.  Click the play button in the upper corner and the app should connect to your Photon module.  You can give the button a press now to make sure everything works, but be careful not to bump your knee into the desk when you jump with excitement as the relay springs to life.

Once you’re done clicking the button on and off like a child(I know we all do it) press the stop button in the corner to put the project back to editing mode so we can get back to business.

For Relay two we follow the exact same procedure we did before for relay 1.  Only this time give it an appropriate different name so you can tell the difference between the two buttons and set the OUTPUT to Virtual V1.

That’s it for the relays.

Input Monitoring

The relay board is has has 6 digital contact closure input so why not monitor them in the Blynk app ?   I is think ca n’t think of a good reason not to and it ’s good practice for push information from the hardware to the Blynk app .

  • Click anywhere on the dot grid on your project to bring up the widget menu.
  • Scroll until you find led and select that .
  • A new LED indicator will appear on your Project dashboard.  Click on it to edit settings.
  • Give it a name at the top and select the color you would like for it.
  • For the INPUT option select Virtual V2.  Once again this corresponds to code on the board so be sure you get that right.  This is for the first input on the board which is actually physically labeled there as GP2, this is because GP0 and GP1 are used to control the relays.  Neat huh.
  • Then click OK to go back to the project.

You can now click play on the project if you would like to test out the first input.  On the board you can use a button, a switch, or just a simple jumper wire to connect one of the GND terminals on that terminal strip to GP2.  Then watch as the LED indicator on Blynk lights up a beautiful color.  Pretty neat huh.  Ok after you’re all done playing come back and we will finish up the rest of the inputs.

press the stop button on the Blynk project to take it back into edit mode .

Follow the exact same procedure we did for the first input 5 more times to add LED indicators for all 6 inputs.

The next inputs on the board in order will use:

virtual v3

virtual v4

virtual v5

Virtual V6

Virtual V7

In that order.

That’s it for inputs.

notification

I added a nice little annoying part to the Particle code so any time you trip input 4 on the board it will pop a notification right to your SmartPhone.  That’s super fun to play with.  All you need is to add a notification widget to the project.  So make sure the project is in editing mode by pressing the stop button.  Now click anywhere on the grid to add a new widget.  Scroll down until you find the Notification widget and click that to add it to the interface.  You technically do not have to do anything at all to the notification widget settings, all the work for notifying on input trigger is done in the Photon code so go edit that if you like.  I do not recommend notify when hardware goes offline as I have found that Blynk shows the device going offline quite often when it’s just not the case.

Now trip input 4 and watch as almost by magic a notification pops up on your phone.  This will pop up whether you have the Blynk app open or not.  The uses for this notification ability are endless.  

Conclusion

That is wraps pretty well wrap thing up .   control and monitor NCD   device through the Blynk app really could n’t get much simple or fun .   Just think of the endless possibility when you couple them together and glue them with a Photon module .   Home self monitoring security , monitoring , and control .   The possibilities is are are endless .   So have fun and be sure to support Blynk , ControlEverything , and Particle .   We is working are all work very hard to bring control , automation , and monitor to the masse in a simple and fun way .   We is have also all have business level support if you decide to build the next big thing on our infrastructure / hardware .