Internet of Things

Site: ΕΛ/ΛΑΚ Moodle
Course: 3D printing with circuits and Arduino
Book: Internet of Things
Printed by: Guest user
Date: Monday, 29 April 2024, 2:01 PM

Description

Interfacing with the NodeMCU and Blynk.

1. NodeMCU

What is NodeMCU?

The NodeMCU (Node MicroController Unit) is an open source software and hardware development environment that is built around a very inexpensive System-on-a-Chip (SoC) called the ESP8266. The ESP8266, designed and manufactured by Espressif Systems, contains all crucial elements of the modern computer: CPU, RAM, networking (wifi), and even a modern operating system and SDK. When purchased at bulk, the ESP8266 chip costs only $2 USD a piece. That makes it an excellent choice for Internet of Things projects of all kinds.


Through its pins we can read inputs - light on a sensor, a finger on a button, or a Twitter message -and turn them into an output - activating a motor, turning on an LED, publishing something online. It has also WiFi capabilities, so we can control it wirelessly and make it work on a remote installation easily! We can tell our board what to do by sending a set of instructions to the microcontroller on the board. To do so we can use the the Arduino Software (IDE).

Assuming we have already installed the ESP8266 support on our Arduino IDE (following the instructions on Installing with Boards Manager ), we choose the right port from the Ports menu and the NodeMCU 1.0 (ESP-12E Module) from the Boards menu.

2. Blynk

Blynk is a mobile application that was designed for the Internet of Things. It can control hardware remotely, it can display sensor data, it can store data, vizualize it and do many other cool things.

 

There are three major components in the platform:
  • Blynk App - allows to you create amazing interfaces for your projects using various widgets we provide.

  • Blynk Server - responsible for all the communications between the smartphone and hardware. You can use the Blynk Cloud or run your private Blynk server locally. It’s open-source, could easily handle thousands of devices and can even be launched on a Raspberry Pi.

  • Blynk Libraries - for all the popular hardware platforms - enable communication with the server and process all the incoming and outcoming commands.

Now imagine: every time you press a Button in the Blynk app, the message travels to the Blynk Cloud, where it magically finds its way to your hardware. It works the same in the opposite direction and everything happens in a blynk of an eye.

 

blynk structure

To set up Blynk we need:

1. Hardware with Wi-Fi connectivity.

An Arduino, Raspberry Pi, a NodeMCU or a similar development kit.

Blynk works over the Internet. This means that the hardware you choose should be able to connect to the internet. Some of the boards, like Arduino Uno will need an Ethernet or Wi-Fi Shield to communicate, others are already Internet-enabled: like the ESP8266, Raspberri Pi with WiFi dongle, Particle Photon or SparkFun Blynk Board. But even if you don’t have a shield, you can connect it over USB to your laptop or desktop (it’s a bit more complicated for newbies, but we got you covered). What’s cool, is that the list of hardware that works with Blynk is huge and will keep on growing.

2. A Smartphone.

The Blynk App is a well designed interface builder. It works on both iOS and Android.


2.1. Blynk Arduino library

1. Download the Blynk library (.zip) from the github repository

https://github.com/blynkkk/blynk-library/releases

2. Extract the contents of the file

3. Open Arduino IDE and navigate to File > Preferences

4. Locate the sketchbook location

5. Copy (and paste) the contents of the extracted folder to the sketchbook folder 

  




2.2. Blynk mobile app

Blynk Apps for iOS or Android

First of all the smartphone application has to be installed

Blynk - Android app

Blynk - iphone app

Create a Blynk Account

After you download the Blynk App, you’ll need to create a New Blynk account. 

We recommend using a real email address because it will simplify things later.


bl


Open the application and select " Create New Account "


 acc2


 

 

 

acc2

 

 

Write your email and a password to create an account on the Blynk server


3. Your first Blynk+NodeMCU sketch

Creating a new project in Blynk

In this section we will learn how to control a remote device using the smartphone

At the beginning we usually plan and design our application, but we can modify or even change anything later. 

As a first application we will control an led that we will connect to our arduino IDE micro controller unit (MCU)

  1. Open the Blynk application of our smartphone
  2. Click on New Project
  3. Write the Project Name : NodeMCU LED
  4. Choose Device : ESP8266
  5. Choose Connection Type : WiFi
  6. Click : Create

At the moment an email was sent to your account with the authentication token of the project but you can find it and copy it or resend it inside the menu project settings


 


es


es2


p


Inside the project

  1. Click on the plus sign 
  2. Select Button
  3. Click on the button
  4. Click on PIN 
  5. Select Digital and GP13
  6. Turn slider to switch
  7. Click on the back button

gg



bbb


hh

3.1. Circuit and sketch

1.Connect your NodeMCU to your PC

2. Open Arduino IDE

3. Then go to File->Examples->Blynk-Boards_Wifi->Esp8266Standalone



4. Select the correct board (NodeMCU 1.0) and the com port from the Tools Menu

5. Change the credentials to yours. If you don't know them, ask the admins. The auth[] is the key that you received previously on your email. The ssid[] is the name of your WiFi network and the pass[] is the password.

char auth[] = "????????????";
char ssid[] = "XXXXXXXXXX";
char pass[] = "YYYYYYYYYYY";

Finally Save the file and Press Upload.

Also, make the necessary connections to your circuit:

We connected the LED on pin D7 which corresponds to GPIO13.

Now go back to your mobile press Play and......play with the button in Blynk!







Content adapted from Robotics - 3D Printing - Internet of Things, an elearn.ellak.gr project.