IoT – Deep Focus https://fazals.ddns.net/ Embrace it! Mon, 17 Aug 2020 07:28:43 +0000 en-US hourly 1 https://wordpress.org/?v=5.6.1 https://fazals.ddns.net/wp-content/uploads/2020/08/react-native-300-150x150.png IoT – Deep Focus https://fazals.ddns.net/ 32 32 173186184 What is Blynk and how to use it? https://fazals.ddns.net/what-is-blynk-and-how-to-use-it/ Wed, 08 Jul 2020 04:30:51 +0000 https://fazals.ddns.net/?p=2233 What is Blynk and how to use it? Read More »

]]>
I am sure that you all have heard the buzz word “IoT” an abbreviation for internet of things. Or you might have seen people controlling their home and work appliances from their mobile phones. You might have seen garage doors, the gates automatically open, when a car reaches them. Yeah, that’s basically what IoT is.

It’s an interconnected network of things or stuffs you use in your daily life. For example, imagine your light bulb, your fan and almost everything electronic connected to the internet. They can be controlled wirelessly from any corner in the world, yes, the world, you will need an internet connection though.

So, is Blynk another app to control stuffs using the internet?

Well, the answer to that is both yes and a no, you’ll see why, Just go on reading.

Blynk is a complete platform for the IoT. They have app to control things, they have servers that relays the signals and commands to and fro the edge device and the mobile devices as well. They provide us with APIs, another abbreviation which stands for Application Programming Interface. They provide us with different protocols like HTTP, MQTT, HTTPS which is more secure and many more. Making the Blynk platform accessible from many devices which support many different programming languages.

You could use Python, C, C++, Java, Kotlin, Ruby, and many more to control.

And most importantly, Blynk is Open Source. Open Source software have an amazing community support, just like Linux and android. Their source codes are available on GitHub, and so does their documentation as well. Indeed it simple to follow.

]]>
2233
Blynk OTA on NodeMCU, ESP8266, ESP32 and more | PlatformIO | Blynk OTA simplified. https://fazals.ddns.net/blynk-ota-arduino-nodemcu-esps/ Sat, 20 Jun 2020 08:53:41 +0000 https://fazals.ddns.net/?p=2217 Blynk OTA on NodeMCU, ESP8266, ESP32 and more | PlatformIO | Blynk OTA simplified. Read More »

]]>
We all know that the Blynk app together with tiny micro controllers is an amazing combination for IoT. NodeMCU, ESP8266, ESP32 and many other Arduino boards are compatible with the Blynk platform. With such large support, Blynk OTA would be a over whelming feature. The code uploading and testing of the device is simple when in the prototype stage. But, when you have a completed the design and development and have no access to the serial port over the USB, you can no longer upload new codes and updates to the devices without breaking them apart.

But is it possible to have the Blynk code updated the over the air (OTA)?

Well officially, the Blynk Platform doesn’t support the OTA updates. They do have it, but with “0” compatibility, making it of no use. They might develop it in the future, but the wait is never over.

Don’t have Arduino IDE, download Arduino IDE from their official website.

The solution for Blynk OTA over WiFi

Do you know that the Arduino OTA library, helps in uploading the code to any device over the network. Well if you don’t. Yeah, it does, using the TCP/IP protocol.

The Arduino OTA code

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

#ifndef STASSID
#define STASSID "your-ssid"    //put your WiFi SSID (Name)
#define STAPSK  "your-password"    //Set your WiFi Password
#endif

const char* ssid = STASSID;
const char* password = STAPSK;

void yourSetup(){
  //put your code that need to run once
}

void yourLoop(){
  //put the code that needs to run continuously
}

void setup() {
  Serial.begin(115200);
  Serial.println("Booting");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
  }

  // Port defaults to 8266
  // ArduinoOTA.setPort(8266);

  // Hostname defaults to esp8266-[ChipID]
  // ArduinoOTA.setHostname("myesp8266");

  // No authentication by default
  // ArduinoOTA.setPassword("admin");

  // Password can be set with it's md5 value as well
  // MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
  // ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");

  ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH) {
      type = "sketch";
    } else { // U_FS
      type = "filesystem";
    }

    // NOTE: if updating FS this would be the place to unmount FS using FS.end()
    Serial.println("Start updating " + type);
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) {
      Serial.println("Auth Failed");
    } else if (error == OTA_BEGIN_ERROR) {
      Serial.println("Begin Failed");
    } else if (error == OTA_CONNECT_ERROR) {
      Serial.println("Connect Failed");
    } else if (error == OTA_RECEIVE_ERROR) {
      Serial.println("Receive Failed");
    } else if (error == OTA_END_ERROR) {
      Serial.println("End Failed");
    }
  });
  ArduinoOTA.begin();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  yourSetup();
}

void loop() {
  ArduinoOTA.handle();
  yourLoop();
}

The code is exactly same as provided in the examples in the Arduino IDE with slight modification, it’s simple and easy to understand. Once uploaded to your NodeMCU or any ESP, your device’s network port will show up in the Arduino IDE as below.

Network port on Arduino IDE

What’s next? Adding Blynk code to the OTA code.

You can see there are 2 functions at the starting of the code. This is where your main program code will be. The functions void yourSetup() and void yourLoop() will word just like the void loop() and the void setup() functions.

void yourSetup(){
  //put your code that need to run once
}

void yourLoop(){
  //put the code that needs to run continuously
}

Now we need to add the Blynk code. First we need to import the Blynk header file, then add the credentials, and then copy paste the Blynk setup and loop’s code into our setup and loop. The complete code is given below.

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

#include <BlynkSimpleEsp8266.h>
char auth[] = "Your_auth_token_here";

#ifndef STASSID
#define STASSID "Your_WiFi_SSID_here"
#define STAPSK "Your_WiFi_Password_here"
#endif

const char *ssid = STASSID;
const char *password = STAPSK;

void yourSetup()
{
  Blynk.begin(auth, ssid, password);
}

void yourLoop()
{
  Blynk.run();
}

void setup()
{
  Serial.begin(115200);
  Serial.println("Booting");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED)
  {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
  }

  ArduinoOTA.setHostname("NodeMCU");

  ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH)
    {
      type = "sketch";
    }
    else
    { // U_FS
      type = "filesystem";
    }

    // NOTE: if updating FS this would be the place to unmount FS using FS.end()
    Serial.println("Start updating " + type);
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR)
    {
      Serial.println("Auth Failed");
    }
    else if (error == OTA_BEGIN_ERROR)
    {
      Serial.println("Begin Failed");
    }
    else if (error == OTA_CONNECT_ERROR)
    {
      Serial.println("Connect Failed");
    }
    else if (error == OTA_RECEIVE_ERROR)
    {
      Serial.println("Receive Failed");
    }
    else if (error == OTA_END_ERROR)
    {
      Serial.println("End Failed");
    }
  });
  ArduinoOTA.begin();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  yourSetup();
}

void loop()
{
  ArduinoOTA.handle();
  yourLoop();
}

That’s it, you now have your Blynk code running on your edge device with OTA – Over The Air updates capability. Add or remove or manipulate the code in the yourSetup and the yourLoop part, you will have your OTA capability.

Having problem uploading the code? check out the FAQs

My network port is not showing up on the Arduino IDE

The Arduino IDE does have a problem detecting and working with the network ports. If your code is uploaded and the device is connected to WiFi and the network port is not being shown, restart your IDE.

If the port is not being shown even after restarting, I suggest you to shift over to PlatformIO on Visual Studio Code for micro controller programming. It has a lot better coding and debugging experience. Or check out this post if you want to setup your own custom Blynk server.

Blynk OTA

The most simple, easy to use and 100% working OTA code for Blynk with NodeMCU, ESP8266, ESP32 and so on.

Operating System: Windows 10, Linux, Mac OS, OSX

Application Category: IoT, Arduino

]]>
2217
Create & setup your own Blynk server in 5 mins https://fazals.ddns.net/blynk-server-setup/ https://fazals.ddns.net/blynk-server-setup/#comments Thu, 23 Apr 2020 04:30:00 +0000 https://fazals.ddns.net/?p=698 Create & setup your own Blynk server in 5 mins Read More »

]]>
What is Blynk?

Blynk is an IOT platform which helps you to integrate and control various devices remotely with a mobile application. Not just that, it also supports REST Api, meaning that you can create your own mobile and desktop application using literally any programming language. You can use it to control various edge devices including your Raspberry Pis, Arduino Boards, and many more using internet. In other words, it helps you to quickly build interfaces for controlling and monitoring your hardware using your Android and iOS devices.

All you need to do is download the app from play store or the app store depending on your device. Subsequently create a project dashboard, and add buttons, sliders and other UI elements on to the dashboard and start building your hardware. Also, download the app, click on the links below.

Besides want to jump to Blynk Server Installation?

Get it for Android

Get it for iOS

Once the app is downloaded, you need to start building your hardware. Besides you can go to the Blynk documentation to learn more on how to setup your device. Its simple and easy to use. However, there are limitations on using the default Blynk Server. You are allowd to add limited number of wigets to your project. But, you can over come this by using a private server.

List of supported devices are given below.

Want to setup your own Blynk Server?

You can also setup your own Blynk server you your Windows, Linux or even Mac. Moreover to be able to run the server there are certain minimum software requirements.

Requirements

  • Java 8/11 required (OpenJDK, Oracle)
  • Any OS that can run java (Windows, Linux or Mac)
  • At least 30 MB of RAM (could be less with tuning)
  • Open ports 9443 (for app and hardware with ssl), 8080 (for hardware without ssl)

Select your Operating System
1. Windows
2. Linux

In addition, want to learn to create your own website for free? Click here.
Also, tired of ads on YouTube and other webpages? learn how to remove them here.

How to install Blynk Server on Windows ?

For Windows download Java from here and install.
Get the latest server builds from here.

Unlike linux, just double click the .jar file downloaded, and you should be good to go. No windows or pop-up will open. The server will execute in the background. As a result, you should see two folders appear in the directory where your .jar file is executed from, namely logs and static.

How to install Blynk Server on Unix Systems (Linux)?

Install Java on linux (Ubuntu)

sudo add-apt-repository ppa:openjdk-r/ppa 
sudo apt-get update
sudo apt install openjdk-11-jdk -y

Install Java on Raspberry Pi

sudo apt install openjdk-8-jdk openjdk-8-jre

Check your Java installation

java -version
Output: java version "1.8"

Download the server jar file

wget "https://github.com/blynkkk/blynk-server/releases/download/v0.41.12/server-0.41.12-java8.jar"

Run the server on default ports

java -jar server-0.41.12-java8.jar -dataFolder /home/pi/Blynk

How to setup your Blynk App?

Do absolutely no changes in the server configuration if using the default Blynk server. On the other hand, if you are using a private server, do the following.

To use your own server in your blynk app.
1. Open the blynk app and click on Create New Account.
2. Click on the small icon just above the Sign Up button.
3. Choose CUSTOM on the Server Settings.
4. In the place of Host address enter the IP address of your server. Do not change the port number from 9443.
5. And then click on OK.
6. Enter your Email and Password to Sign Up only for the first time.
Then on, you just need to Log In and not Sign Up. All of your settings will be saved online on the server.

Don’t have a private server but want more energy? in the step 4 above, replace the IP address with fazals.ddns.net.

Now connect your hardware and start blynking🤘.

Just make sure, when you are coding your hardware, you have to change the server preferences to connect to your new private server. To do so, replace the following line of code.

 Blynk.begin(auth, ssid, pass);

with

Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

To connect to the server hosted on this website use the following.

Blynk.begin(auth, ssid, pass, "fazals.ddns.net", 8080);

In this case ssid is your WiFi Name and pass is your WiFi Password.

Thats it! 😎 Care to share? If you face any kind of error, do visit the official documentation here.

]]>
https://fazals.ddns.net/blynk-server-setup/feed/ 1 698