MJRoBot
Published © GPL3+

IoT Made Simple: Servo Control With NodeMCU and Blynk

In this simple tutorial, we will explore how to control a servo motor over the internet, using a smartphone.

BeginnerFull instructions provided6 hours5,916
IoT Made Simple: Servo Control With NodeMCU and Blynk

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
OLED
×1
RobotGeek 180 Degree Robot Servo
RobotGeek 180 Degree Robot Servo
×1
Breadboard Power Supply Module 3.3V/5V
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Story

Read more

Schematics

Electrical Diagram

Code

Code snippet #8

Plain text
void init(); // Initialise the display
void displayOn(void); // Turn the display on
void displayOff(void); // Turn the display offs
void clear(void); // Clear the local pixel buffer
void flipScreenVertically(); // Turn the display upside down

Code snippet #10

C/C++
/*NodeMCU */
#include <ESP8266WiFi.h>

/* OLED */
#include "SSD1306Wire.h"
#include "Wire.h"
const int I2C_DISPLAY_ADDRESS = 0x3c;
const int SDA_PIN = 0;
const int SCL_PIN = 2;
SSD1306Wire     display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN);

void setup () 
{
  Serial.begin(115200); 
  displaySetup();
}

void loop() 
{ 
}

/* Initiate and display setup data on OLED */
void displaySetup()
{
  display.init();         // initialize display
  display.clear();        // Clear display
  display.display();      // Put data on display
  
  Serial.println("Initiating Display Test");
  
  display.setFont(ArialMT_Plain_24);
  display.drawString(30, 0, "OLED");  // (xpos, ypos, "Text")
  display.setFont(ArialMT_Plain_16);
  display.drawString(18, 29, "Test initiated");
  display.setFont(ArialMT_Plain_10);
  display.drawString(10, 52, "Serial BaudRate:");
  display.drawString(90, 52, String(11500));
  display.display();  // Put data on display
  delay (3000);
}

Code snippet #11

C/C++
#include <BlynkSimpleEsp8266.h>
char ssid [] = "YOUR SSID";
char pass [] = "YOUR PASSWORD";
char auth [] = "YOUR AUTH TOKEN"; // Servo Control Project

/* Reads slider in the Blynk app and writes the value to "potReading" variable */
BLYNK_WRITE(V0) 
{
  potReading = param.asInt();
}

/* Display servo position on Blynk app */
BLYNK_READ(V1) 
{
  Blynk.virtualWrite(V1, servo1Angle);
}

void setup () 
{
  Blynk.begin(auth, ssid, pass);
}

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

IoT-Servo-Control GitHub

Depository of all files used on the project

Github file

https://github.com/Mjrovai/IoT-Servo-Control/tree/master/NodeMCU_Servo_Control_Test

Github

https://github.com/squix78/esp8266-oled-ssd1306

Credits

MJRoBot

MJRoBot

33 projects • 570 followers
Engineer, writer and forever student. Passionate to share knowledge of electronics with focus on IoT and robotics.

Comments

Add projectSign up / Login