14. Networking and communications

Assignments

group assignment:

  • Send a message between two projects.

individual assignment:

  • Design, build, and connect wired or wireless node(s) with network or bus addresses.

X. Group Assignment


Link to group session page.

X. Individual Assignment


1. Overview


At my final project, I plan to use Blynk app. to send GPS data from smartphone to the PCB that I make. So this week, the work flow is;

  • Understand how Blynk works
  • Make a PCB with WiFi receiver chip
  • Prepare the Blynk setting to send GPS data of the smartphone and the program to have the PCB receive GPS data
  • Read the program to PCB and show GPS data on the Serial Monitor

2. How does Blynk work?


Before I use Blynk app., I need to understand how Blynk system work. So I checked Website of Blynk community.

First, Blynk is the application for the Internet of Things which control hardware remotely. What I impressed is that Blynk is for free! You can easily experience IoT with hardware like some development kit and your smartphone.

To operate Blynk system, three components are needed:

  • Blynk App.
    provides the interface using various widgets like Button, Slider, Timer and so on. You can download it from like App. store.

  • Blynk Server
    responsible for all the communications between the smartphone and hardware. Those communications are demonstrated each other by identifying Auth Token which is sent by e-mail.

  • Blynk Libraries
    enable communication with the server and process all the incoming and outcoming commands.

↓ Various Widgets

So in this week, I tried communicating Barduino-based PCB board as hardware with my smartphone by using Blynk platform.

3. Make a PCB with WiFi receiver chip


It needs the WiFi module to receive GPS data from Blynk. So I made the modified Barduino board.

EPS-32 chip was used as the GPS receiver and only FTDI pins on PCB were used to input the power and transfer data to PC.

The difference from the original Barduino is adding the connectors and optimizing their positions. Scheme of the modified Barduino board is shown below;

4 Blynk setting to send GPS data of the smartphone


So first I prepared Blynk setting which send GPS data from the smartphone.

Created New Project and chose Device: ESP32 Dev Board and Connection type: WiFi at Device Settings.
When you create a new project, Auth Token is sent to the e-mail address you registered. Auth Token is used later to put it in the program. You can check it in Device Settings page(= Prpject Settings page).

After created the Project, tapped somewhere on the screen to open Widget Box page and chose GPS Stream.

You can tap the button at the top of the right to be able to send GPS data online although no changes are occurred on the screen.

5 Program to have the PCB receive GPS data

First, I downloaded Blynk Library to use the sample code which runs wiht Blynk.
Opened Arduino IDE and click the tool bar: Sketch -> Include Library -> Manage Libraries.

And then search for Blynk library in Library Manager and in the version selection choose the latest version to date.

In the Blynk library, based on the sample code: ESP32_WiFi (File -> Examples -> Blynk -> Boards_WiFi -> ESP32_WiFi), I added some codes from the reference code: GPS Streaming for receiving and showing GPS data.

In the below program, put the AUTH TOKEN in char auth[] and the SSID of my WiFi router in char ssid[] and its password in char pass[].

Code1 - Send GPS data to Arduino with my PC

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  This example runs directly on ESP32 chip.

  Note: This requires ESP32 support package:
    https://github.com/espressif/arduino-esp32

  Please be sure to select the right ESP32 module
  in the Tools -> Board menu!

  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxx";
char pass[] = "xxxx";

WidgetTerminal terminal(V1);

BLYNK_WRITE(V1) {
  GpsParam gps(param);

  // Print 6 decimal places for Lat, Lon
  Serial.print("Lat: ");
  Serial.println(gps.getLat(), 7);

  Serial.print("Lon: ");
  Serial.println(gps.getLon(), 7);

  // Print 2 decimal places for Alt, Speed
  Serial.print("Altitute: ");
  Serial.println(gps.getAltitude(), 2);

  Serial.print("Speed: ");
  Serial.println(gps.getSpeed(), 2);

  Serial.println();
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);
}

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

Read the program to PCB and show GPS data on the Serial Monitor


Connected Barduino with my PC and opened the Arduino IDE.
Please make sure if you choose the correct Board and Port at Toolbar -> tools.
If you cannot find the board: ESP32, you can install the ESP32 board from the Boards Manager.

Wrote the code1 (above code) to the board.

Note

When you write the code to Barduino, IO 0 pin must be set to the ground.
For Barduino board, when you write the code to Barduino, IO 0 pin (25 pin) must be set to the ground by sliding the switch, and then you push the button by setting the Reset pin (3 pin) to the ground to start writing the code.

Note

After finished writing the code, I0 pin must be set to the open
For Barduino board, when you finished writing the code to Barduino, IO 0 pin (25 pin) must be set to the open by sliding the switch, and then you push the button by setting the Reset pin (3 pin) to the ground to implement the code.

Finished!!

X. Conclusions


Submission