กลับไปหน้ารวมไฟล์
esp8266-servo-controller-c16b17-en.md

Introduction

In this project we use ESP8266 in its NodeMCU form factor as a webserver and to create a webform to control the current position of the servo motor.

All the data of the webserver are saved on the SPIFFS memory of ESP8266.

What is SPIFFS?

SPIFFS is the original filesystem and is ideal for space and RAM constrained applications that utilize many small files and care about static and dynamic wear levelling and don’t need true directory support. Filesystem overhead on the flash is minimal as well. On the NodeMCU we have 4MB of flash out of which we can the size of the SPIFFS filesystem. In this project all the webserver files including html, css, and javascript are saved on a folder named data which is the folder name required for uploading to ESP8266 with SPIFFS uploader.

I have a detailed tutorial about it in another project. Check it out.

WiFi-To-PWM Actuator Interface

This project transforms an ESP8266 into a high-performance wireless servo driver, allowing for remote pan/tilt or robotic movement via any web browser.

  • Embedded WebSocket Handshake: The ESP8266 hosts a local web server with a specialized WebSocket endpoint. This provides a high-speed, persistent link for sub-20ms control latency, far superior to traditional HTTP requests.
  • Dynamic PWM Resolution: The Arduino (ESP8266 board) uses the analogWrite or specialized Servo library to generate highly stable 50Hz pulses. The firmware includes a "Smoothing Filter" to prevent the servos from jittering during rapid network fluctuations.

Performance

  • Visual Studio Code Optimized: The firmware was developed using the VS Code Arduino Extension, leveraging integrated debugging to optimize the multi-threaded WiFi/Servo handling loop.

Hardware Setup

  • Start by placing the NodeMCU on a breadboard.
  • Place the servo motor and make the connections as shown in the image below.
  • Connections.

3V3V ➡ VCC

GND ➡ GND

SIGNAL ➡ D2

Software Setup

  • Visit my GitHub page and download the necessary files.
  • Install libraries.
  • Install the libraries and Filesystem uploader as shown in the video tutorial below.
  • Compile the code and upload.
  • Go to tools and use ESP8266 Sketch Data Upload tool to upload sketch data.

Changetheselinesofcodeasperyours:

const char *ssid = "REPLACE_WITH_YOUR_SSID";       
const char *password = "REPLACE_WITH_YOUR_PASSWORD";
const uint8_t servoPin = D4;

GitHub Repository link

https://github.com/rahuladitya303/ESP8266_SERVO_CONTROLLER.git

For more details about how to install libraries and filesystem uploader checkout my other project

https://create.arduino.cc/projecthub/rahuladitya303/esp8266-weather-station-with-spiffs-c01037

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
  - "1x Visual Studio Code Extension for Arduino"
author: "rahuladitya303"
category: ""
components:
  - "1x NodeMCU ESP8266 Breakout Board"
  - "1x SG90 Micro-servo motor"
description: "A simple ESP8266 Web Server to control the position of servo motor."
difficulty: "Easy"
documentationLinks: []
downloadableFiles:
  - "https://github.com/rahuladitya303/ESP8266_SERVO_CONTROLLER.git"
encryptedPayload: "U2FsdGVkX199aQGnnqmmJdG7ozbUc8FE4aM5fTHNlOuaJ5Y1jGv1cImcd1ekPQddj8aGAdYz+EkHfJ9ih25K25pi44Ough/B7KLDe8Dfkp7heLb3PaHsi+W1rCDpZh9+ggi/3d6TTP9dMWqT0IkUVaQYo5sAX6EtEtdTefH+VMU="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/esp8266-servo-controller-c16b17_cover.jpg"
lang: "en"
likes: 1
passwordHash: "ced2dc7516b48402fbd629527f604d6a70cae219c5c5d7c47f673981328f19b4"
price: 2450
seoDescription: "Build a simple ESP8266 Web Server to control Servo motor position remotely. Ideal for IoT beginners."
tags:
  - "spiffs"
  - "esp8266"
  - "servo"
title: "ESP8266 Servo Controller"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/poPoHdS-j-w"
views: 24137