Interface and Application Programming


Group Assignment

Group Assignment Summary

Arduino Cloud:

  • Brief: A platform for connecting Arduino devices to the cloud for remote monitoring and control.
  • Use Cases: Popular among makers and IoT enthusiasts for prototyping IoT solutions.
  • Workflow: Simple setup process with Arduino hardware and libraries. Limited customization options for the dashboard. Requires stable internet connection.
  • Opinions: Liked for its user-friendly interface and integration with Arduino hardware. Disliked for limited dashboard customization and reliance on internet connectivity.

Processing:

  • Brief: An open-source graphical library and IDE for creating interactive visual applications.
  • Use Cases: Commonly used for interactive art, data visualizations, and simulations.
  • Workflow: Rapid prototyping with intuitive graphical interface design. Limited scalability for complex applications. Utilizes serial communication with Arduino.
  • Opinions: Liked for its intuitive interface and integration with Arduino via serial communication. Disliked for limited scalability and lack of advanced UI components.

Blynk:

  • Brief: A platform for easy development of IoT applications with drag-and-drop widgets.
  • Use Cases: Popular among hobbyists, makers, and professionals for remote monitoring and control of hardware devices.
  • Workflow: Rapid development with drag-and-drop widgets. Limited customization options for widget appearance. Requires internet connectivity for remote control.
  • Opinions: Liked for its user-friendly interface and wide range of pre-built widgets. Disliked for limited customization options and dependency on internet connectivity.

Individual Assignment

How I Controlled a Servo Motor with Blynk

I'm going to walk you through how I set up and controlled a servo motor using the Blynk app and my Seeed Xiao ESP32C3. This was a fun project, and I'm excited to share the steps with you.

Communication Method

The Blynk app communicates with the Seeed Xiao ESP32C3 via the Blynk Cloud over WiFi. The Seeed Xiao ESP32C3 connects to the WiFi network and the Blynk Cloud using the provided credentials. The slider widget in the Blynk app sends data to Virtual Pin V1, which the board reads and uses to adjust the servo motor's angle.

Step 1: Setting Up Blynk

First, I created the project on the Blynk website :

  1. Went to the Blynk website and created a new template.
    • Named the template "servo blynk."
    • Added the ESP32 device.

    Sign up in the website if you do not have one

    Here I have an account and I log in

    I headed to the delevoper zone to add a new template

    Press new template to make your own template

    Here I make my own template and named it also I chose Esp32

  2. Navigated to the Developer Zone.
    • Created a new data stream.
    • Named the data stream V1.
  3. Went to the Web Dashboard.

      Choose the virtual pin

      Choose the the virtual pin that you want but make sure to put it in your code

      Here I edited the virtual pin and make the min and max values from 0 to 180 degrees

    • Added a Slider widget.
    • Linked the Slider to the V1 data stream.
  4. Noted down the authentication is different from project to another.

Then, I opened the Blynk app:

  1. Opened the Blynk app on my smartphone.
  2. Added the template I created on the website to the app.
  3. Verified that the Slider widget to control the servo motor was set up properly.

Step 2: Writing the Arduino Code

Next, I wrote the Arduino code. Here it is:


								#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL6r4x8Bs7A"
#define BLYNK_TEMPLATE_NAME "servo blynk"
#define BLYNK_AUTH_TOKEN "NXKoKmSVbV1up10itjM6LEchbnGhsh0J"

#include 
#include 
#include 
#include  // Use the ESP32Servo library

char auth[] = "NXKoKmSVbV1up10itjM6LEchbnGhsh0J";
char ssid[] = "Redmi Note 10 5G";
char pass[] = "Fnsama19999";

#define SERVO_PIN 2 // Pin to which the servo motor is connected

Servo servoMotor; // Create a servo object

void setup() {
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  servoMotor.attach(SERVO_PIN); // Attach the servo motor to the specified pin
}

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

BLYNK_WRITE(V1) { // This command listens when something is written to V1
  int angle = param.asInt(); // Get the value from the slider widget
  servoMotor.write(angle); // Set the servo motor to the specified angle
  Serial.print("V1 slider value is: "); // Printing value to serial monitor
  Serial.println(angle);
}





							

I updated the WiFi and Blynk credentials:

  • Replaced the auth, ssid, and pass variables with my Blynk authentication token and WiFi credentials.

Step 3: Uploading and Testing

Now for the hardware setup:

  • I connected the servo motor signal wire to pin 2 on the Seeed Xiao ESP32C3.
  • Connected the servo motor's power and ground wires to the appropriate pins on the Seeed Xiao ESP32C3.

Then I uploaded the code:

  1. Connected my Seeed Xiao ESP32C3 to my computer.
  2. Uploaded the code to the Seeed Xiao ESP32C3.

Finally, I tested it with the Blynk app:

  1. Opened the Blynk app and used the Slider widget to adjust the servo motor's angle.
  2. Moved the slider, and voila! The servo motor moved accordingly.

And that's how I got my servo motor up and running with Blynk. It was a straightforward and rewarding process. If you follow these steps, you'll have your servo motor controlled by the Blynk app in no time!

Source code

  • Servo blynk