Keyestudio ESP32 Manual

Smart robot arm kit
Hide thumbs Also See for ESP32:

Advertisement

Quick Links

keyestudio WiKi
keyestudio WiKi
Jun 28, 2024

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Keyestudio ESP32

  • Page 1 WiKi keyestudio WiKi Jun 28, 2024...
  • Page 3: Table Of Contents

    FKS0003 KEYESTUDIO SMART ROBOT ARM KIT WITH JOYSTICK FOR ESP32 1 1. Kit List 2 2. Description 3 3. Parameters 4 4. Features 5 5. KEYESTUDIO ESP32 Main Board 5.1 Introduction ..........
  • Page 4 8.15 8.15 Wiring ..........113 9 9.
  • Page 5 Copyright The Keyestudio trademark and logo are the copyright of KEYES DIY ROBOT co.,LTD. All products under Keyestu- dio brand can’t be copied, sold or resold without authorization by anyone or any company.
  • Page 6 WiKi FKS0003 KEYESTUDIO SMART ROBOT ARM KIT WITH JOYSTICK FOR ESP32...
  • Page 7: 1. Kit List

    1. KIT LIST Please check the list to ensure that all parts are intact. If you find missing ones, please contact our sales staff immediately. NAME Keyestudio ESP32 servo drive board keyestudio ESP32 Core board Keyestudio Joystick Module 3D PS2 joystick cap...
  • Page 8 WiKi Table 1 – continued from previous page NAME MG90S 14G 180° servo metal gear Keyestudio 9G 180° servo DC 6-slot AA battery holder 15CM connector 2 18650 battery packs (recommended to use pointed 18650 batteries) F-F 50CM/10P DuPont wire...
  • Page 9 WiKi Table 1 – continued from previous page NAME M2+M3 wrench F693ZZ motor classInner: 3MM; Outer: 8MM; Thickness: 4MM AXK 3-plate flat bearingInner: 20MM; Outer: 35MM, Thickness: 4MM 2 bearing covers 4 acrylic board M3 nut M2 nut M3 self-locking nut...
  • Page 10 WiKi Table 1 – continued from previous page NAME M2.5 nut M3*6MM round head screw M2*10MM round head screw M3*8MM round head screw M1.2*5MM self-tapping screw 2.54MM M3*10MM round head screw M3*12MM round head screw M3*6MM round head nylon screw...
  • Page 11 WiKi Table 1 – continued from previous page NAME M2.5*25+6MM single-pass copper pillar M2.5*6MM round head screw M1.4*6MM self-tapping screw M3*6+6MM single-pass copper pillar M3*14MM flat head screw...
  • Page 12 WiKi Chapter 1. 1. Kit List...
  • Page 13: 2. Description

    2. DESCRIPTION Based on ESP32 development board, we utilize various servos to build up a programmable robot arm, which is able to wave, grasp and lift objects. It can be controlled by WiFi and Bluetooth to communicate with other devices.
  • Page 14 WiKi Chapter 2. 2. Description...
  • Page 15: 3. Parameters

    CHAPTER THREE 3. PARAMETERS Operating voltage: 3.3~5V DC input voltage: 7~12V Battery holder: 6-slot AA battery holder / 2-slot 18650 battery holder DOF: 4 degree of freedom...
  • Page 16 WiKi Chapter 3. 3. Parameters...
  • Page 17: 4. Features

    Flexibility: With 4 degrees of freedom, the robot arm is able to move and rotate in multiple directions to perform complex actions and tasks. Convenient Control: The ESP32 microcontroller is used as the control core, and its rich interface are convenient for communication and control with other devices or systems.
  • Page 18 WiKi Chapter 4. 4. Features...
  • Page 19: 5. Keyestudio Esp32 Main Board

    5.1 5.1 Introduction Based on ESP-WROOM-32, the keyestudio ESP32 Core board is a mini development board, whose I/O pins are reserved a space of 2.54mm on both sides, so that it can be connected to peripherals according to needs. In addition, these pins also make your operation more concise and convenient when using and debugging.
  • Page 20: Pin-Out

    Although ESP32 board boasts fewer pins than commonly used processors, you will not encounter any problems when you reuse multiple functions on pins (pins IO36, IO35, IO34, IO39 only inputs signals). ATTENTION: The voltage of ESP32 pins is 3.3V. If it works with other devices with an operating voltage of 5V, a level converter is required.
  • Page 21 WiKi GND: 3 GND pins. Enable pin(EN): used to enable or disable modules. The pin enables module at high and disables at low. I/O pin(GPIO): 32 GPIO pins, used to communicate with LED, switches, and other input/output devices. These pins can be pulled up or down.
  • Page 22: Main Parts

    WiKi 5.4 5.4 Main Parts Chapter 5. 5. KEYESTUDIO ESP32 Main Board...
  • Page 23: 6. Esp32 Servo Drive Board

    6.1 6.1 Description The KEYESTUDIO ESP32 servo drive board has 6 servo drive ports (5V), 9 IO ports (3.3V), and two IIC interfaces (3.3V). The servo drive uses two LM2596S-5.0V 3A high current power ICs to provide working voltage to the servo.
  • Page 24: Pin-Out

    WiKi 6.3 6.3 Pin-out 6.4 6.4 Schematic Diagram Schematic Diagram.PDF Chapter 6. 6. ESP32 Servo Drive Board...
  • Page 25: 7. Arduino Ide Basic Tutorial

    For Windows, there is an easier way to install the ESP32, click the link to download esp32_package_2.0. 12_arduinome.exe. Click to enable the automatic installation. After that, open Arduino IDE and you will see ESP32: esp32_package_2.0.12_arduinome.exe download link:...
  • Page 26 WiKi Chapter 7. 7. Arduino IDE Basic Tutorial...
  • Page 27: 8. Assembly

    CHAPTER EIGHT 8. ASSEMBLY 8.1 8.1 Battery Holder 8.1.1 8.1.1 Mount Battery Holder 8.1.1.1 Six-slot AA Battery Holder Required parts: Steps:...
  • Page 28 WiKi Chapter 8. 8. Assembly...
  • Page 29 WiKi 8.1.1.2 Two-slot 18650 Battery Holder Required parts: Steps: 8.1. 8.1 Battery Holder...
  • Page 30 WiKi Chapter 8. 8. Assembly...
  • Page 31: Demount Battery Holder

    WiKi 8.1.2 8.1.2 Demount Battery Holder 8.1. 8.1 Battery Holder...
  • Page 32 WiKi 8.1.2.1 Six-slot AA Battery Holder Chapter 8. 8. Assembly...
  • Page 33 WiKi 8.1. 8.1 Battery Holder...
  • Page 34 WiKi Chapter 8. 8. Assembly...
  • Page 35 WiKi 8.1. 8.1 Battery Holder...
  • Page 36 WiKi Chapter 8. 8. Assembly...
  • Page 37 WiKi 8.1. 8.1 Battery Holder...
  • Page 38 WiKi 8.1.2.2 Two-slot 18650 Battery Holder Chapter 8. 8. Assembly...
  • Page 39 WiKi 8.1. 8.1 Battery Holder...
  • Page 40 WiKi Chapter 8. 8. Assembly...
  • Page 41 WiKi 8.1. 8.1 Battery Holder...
  • Page 42 WiKi Chapter 8. 8. Assembly...
  • Page 43: Expansion Board And Esp32 Development Board

    WiKi 8.2 8.2 Expansion Board and ESP32 Development Board Required parts: 8.2. 8.2 Expansion Board and ESP32 Development Board...
  • Page 44 WiKi Steps: Chapter 8. 8. Assembly...
  • Page 45 WiKi 8.2. 8.2 Expansion Board and ESP32 Development Board...
  • Page 46 WiKi Chapter 8. 8. Assembly...
  • Page 47 WiKi 8.2. 8.2 Expansion Board and ESP32 Development Board...
  • Page 48 WiKi Chapter 8. 8. Assembly...
  • Page 49 WiKi 8.2. 8.2 Expansion Board and ESP32 Development Board...
  • Page 50: Base For Servo

    WiKi 8.3 8.3 Base for Servo Required parts: Chapter 8. 8. Assembly...
  • Page 51 WiKi Steps: 8.3. 8.3 Base for Servo...
  • Page 52 WiKi Chapter 8. 8. Assembly...
  • Page 53: Base For Arm/Bearing And Base Servo

    WiKi 8.4 8.4 Base for Arm/Bearing and Base Servo Required parts: 8.4. 8.4 Base for Arm/Bearing and Base Servo...
  • Page 54 WiKi Steps: Chapter 8. 8. Assembly...
  • Page 55 WiKi 8.4. 8.4 Base for Arm/Bearing and Base Servo...
  • Page 56 WiKi Chapter 8. 8. Assembly...
  • Page 57 WiKi 8.4. 8.4 Base for Arm/Bearing and Base Servo...
  • Page 58: Joint Of Arm And Base Part

    WiKi 8.5 8.5 Joint of Arm and Base Part Required parts: Chapter 8. 8. Assembly...
  • Page 59 WiKi Steps: 8.5. 8.5 Joint of Arm and Base Part...
  • Page 60 WiKi Chapter 8. 8. Assembly...
  • Page 61: Right-Side Upper Arm And Its Servo

    WiKi 8.6 8.6 Right-side Upper Arm and Its Servo Required parts: 8.6. 8.6 Right-side Upper Arm and Its Servo...
  • Page 62 WiKi Steps: Chapter 8. 8. Assembly...
  • Page 63 WiKi 8.6. 8.6 Right-side Upper Arm and Its Servo...
  • Page 64 WiKi Wiring: Servo drive board Servo IO17(yellow) S(yellow) 5V(red) V(red) GND(black) G(brown) Chapter 8. 8. Assembly...
  • Page 65 WiKi Test code: Download codes: Codes Download and unzip the file. Open the corresponding code file. Code file for Chapter 8.6 is named 8-6. 8.6. 8.6 Right-side Upper Arm and Its Servo...
  • Page 66 WiKi Keyestudio ESP32 Robot Arm 8-6 Servo Configuration Function: set servo at pin IO17 to the angle of 90° http://www.keyestudio.com #include <ESP32Servo.h> // create a servo objects Customizable name Servo servo; servoPin //Connect servo to pin IO17 void setup() servo.attach(servoPin);...
  • Page 67 WiKi 8.6. 8.6 Right-side Upper Arm and Its Servo...
  • Page 68: Right-Side Forearm

    WiKi 8.7 8.7 Right-side Forearm Required parts: Chapter 8. 8. Assembly...
  • Page 69 WiKi Steps: 8.7. 8.7 Right-side Forearm...
  • Page 70 WiKi Chapter 8. 8. Assembly...
  • Page 71 WiKi 8.7. 8.7 Right-side Forearm...
  • Page 72 WiKi Chapter 8. 8. Assembly...
  • Page 73: Left-Side Forearm/Upper Arm And Forearm Servo

    WiKi 8.8 8.8 Left-side Forearm/Upper Arm and Forearm Servo Required parts: 8.8. 8.8 Left-side Forearm/Upper Arm and Forearm Servo...
  • Page 74 WiKi Steps: Chapter 8. 8. Assembly...
  • Page 75 WiKi 8.8. 8.8 Left-side Forearm/Upper Arm and Forearm Servo...
  • Page 76 WiKi Chapter 8. 8. Assembly...
  • Page 77 WiKi 8.8. 8.8 Left-side Forearm/Upper Arm and Forearm Servo...
  • Page 78 WiKi Wiring: Servo drive board Servo IO2(yellow) S(yellow) 5V(red) V(red) GND(black) G(brown) Chapter 8. 8. Assembly...
  • Page 79 WiKi Test code: Download codes: Codes Download and unzip the file. Open the corresponding code file. Code file for Chapter 8.8 is named 8-8. 8.8. 8.8 Left-side Forearm/Upper Arm and Forearm Servo...
  • Page 80 WiKi Keyestudio ESP32 Robot Arm 8-8 Servo Configuration Function: Set servo at pin IO2 to the angle of 90° http://www.keyestudio.com #include <ESP32Servo.h> // create a servo objects Customizable name Servo servo; servoPin //Connect servo to pin IO2 void setup() servo.attach(servoPin);...
  • Page 81 WiKi 8.8. 8.8 Left-side Forearm/Upper Arm and Forearm Servo...
  • Page 82: Base For Claw And Its Servo

    WiKi 8.9 8.9 Base for Claw and Its Servo Required parts: Chapter 8. 8. Assembly...
  • Page 83 WiKi Steps: 8.9. 8.9 Base for Claw and Its Servo...
  • Page 84 WiKi Chapter 8. 8. Assembly...
  • Page 85: Claw

    WiKi 8.10 8.10 Claw Required parts: 8.10. 8.10 Claw...
  • Page 86 WiKi Steps: Chapter 8. 8. Assembly...
  • Page 87 WiKi 8.10. 8.10 Claw...
  • Page 88 WiKi Wiring: Servo drive board Servo IO4(yellow) S(yellow) 5V(red) V(red) GND(black) G(brown) Chapter 8. 8. Assembly...
  • Page 89 WiKi Test code: Download codes: Codes Download and unzip the file. Open the corresponding code file. Code file for Chapter 8.10 is named 8-10. 8.10. 8.10 Claw...
  • Page 90 WiKi Keyestudio ESP32 Robot Arm 8-10 Servo Configuration Function: Set servo at pin IO4 to the angle of 90° http://www.keyestudio.com #include <ESP32Servo.h> // create a servo objects Customizable name Servo servo; servoPin //Connect servo to pin IO4 void setup() servo.attach(servoPin);...
  • Page 91 WiKi 8.10. 8.10 Claw...
  • Page 92 WiKi Chapter 8. 8. Assembly...
  • Page 93 WiKi 8.10. 8.10 Claw...
  • Page 94: Middle Part

    WiKi 8.11 8.11 Middle Part Required parts: Chapter 8. 8. Assembly...
  • Page 95 WiKi Steps: 8.11. 8.11 Middle Part...
  • Page 96 WiKi Chapter 8. 8. Assembly...
  • Page 97 WiKi 8.11. 8.11 Middle Part...
  • Page 98 WiKi Chapter 8. 8. Assembly...
  • Page 99: Base And Bearing

    WiKi 8.12 8.12 Base and Bearing Required parts: 8.12. 8.12 Base and Bearing...
  • Page 100 WiKi Chapter 8. 8. Assembly...
  • Page 101 WiKi Steps: 8.12. 8.12 Base and Bearing...
  • Page 102 WiKi Chapter 8. 8. Assembly...
  • Page 103 WiKi 8.12. 8.12 Base and Bearing...
  • Page 104 WiKi Chapter 8. 8. Assembly...
  • Page 105 WiKi 8.12. 8.12 Base and Bearing...
  • Page 106 WiKi Wiring: Servo drive board Servo IO16(yellow) S(yellow) 5V(red) V(red) GND(black) G(brown) Chapter 8. 8. Assembly...
  • Page 107 WiKi Test code: Download codes: Codes Download and unzip the file. Open the corresponding code file. Code file for Chapter 8.12 is named 8-12. 8.12. 8.12 Base and Bearing...
  • Page 108 WiKi Keyestudio ESP32 Robot Arm 8-12 Servo Configuaration Function: set servo at pin IO16 to the angle of 90° http://www.keyestudio.com #include <ESP32Servo.h> // create a servo objects Customizable name Servo servo; servoPin //Connect servo to pin IO16 void setup() servo.attach(servoPin);...
  • Page 109 WiKi 8.12. 8.12 Base and Bearing...
  • Page 110 WiKi Chapter 8. 8. Assembly...
  • Page 111: Connect Board And Arm

    WiKi 8.13 8.13 Connect Board and Arm 8.13. 8.13 Connect Board and Arm...
  • Page 112: Joystick

    WiKi 8.14 8.14 Joystick Required parts: Chapter 8. 8. Assembly...
  • Page 113 WiKi Steps: 8.14. 8.14 Joystick...
  • Page 114 WiKi Chapter 8. 8. Assembly...
  • Page 115 WiKi 8.14. 8.14 Joystick...
  • Page 116 WiKi Chapter 8. 8. Assembly...
  • Page 117: Wiring

    WiKi 8.15 8.15 Wiring Servo wiring: Connect the corresponding servo motor to the corresponding IO port according to the schematic diagram of the im- ageThe wiring is consistent with the angle settings of each servo motor 8.15. 8.15 Wiring...
  • Page 118 WiKi Chapter 8. 8. Assembly...
  • Page 119 WiKi 8.15. 8.15 Wiring...
  • Page 120 WiKi Arm wiring: Servo drive board Left joystick module 5V(red) GND(black) IO12(yellow) IO13(yellow) IO15(yellow) Servo drive board Right joystick module 5V(red) GND(black) IO25(yellow) IO33(yellow) IO32(yellow) Chapter 8. 8. Assembly...
  • Page 121 WiKi 8.15. 8.15 Wiring...
  • Page 122 WiKi Chapter 8. 8. Assembly...
  • Page 123: 9. Robot Arm Projects

    CHAPTER NINE 9. ROBOT ARM PROJECTS 9.1 9.1 Control Servo 9.1.1 9.1.1 Introduction Servo is a position driver, which is mainly composed of a shell, a circuit board, a non-core motor, a gear and a position detector. When a receiver or an MCU sends a signal to the steering gear, its built-in reference circuit generates a reference signal with a period of 20ms and a width of 1.5ms.
  • Page 124: Principle

    WiKi 9.1.3 9.1.3 Principle The rotation angle of the servo can be controlled by adjusting the duty cycle of the PWM (pulse width modulation) signal. The period of the standard PWM (pulse width modulation) signal is fixed at 20ms (50Hz). Theoretically, pulse width should be within 1ms ~ 2ms, but in fact, the range is 0.5ms ~ 2.5ms, corresponding to the rotation angle of 0°...
  • Page 125: Wiring Diagram

    WiKi 9.1.4 9.1.4 Wiring Diagram 9.1.5 9.1.5 Test Code Download codes: Codes Download and unzip the file. Open the corresponding code file. Code file for Chapter 9.1.5is named 9-1-5. 9.1. 9.1 Control Servo...
  • Page 126 WiKi Keyestudio ESP32 Robot Arm 9-1-5 tutorial code Function: control the servo to rotate to 0°, 90°, 180° http://www.keyestudio.com #include <ESP32Servo.h> // create a servo objects Customizable name Servo servo; servoPin //Connect servo to pin IO16 void setup() servo.attach(servoPin);...
  • Page 127: Test Result

    Download codes: Codes Download and unzip the file. Open the corresponding code file. Code file for Chapter 9.1.7.1 is named 9-1-7-1. Keyestudio ESP32 Robot Arm 9-1-7-1 tutorial code Function: servo slowly rotates from 0° to 180°, and then slowly back to 0°...
  • Page 128: Read Analog Value Of Joystick

    9.2.3 9.2.3 Principle Axis X and Y are actually two potentiometers. As shown below, the analog value of the X(Y) axis ranges from 0 ~ 4095 (the analog value of ESP32 is 0 ~ 4095). Chapter 9. 9. Robot Arm Projects...
  • Page 129 WiKi The analog value will decrease in the Y-axis upward because the resistance of the output pin to the ground is decreasing, and the resistance will be increasing in the downward direction. So does it in the X-axis (direction: right and left).
  • Page 130: Wiring Diagram

    WiKi 9.2.4 9.2.4 Wiring Diagram Chapter 9. 9. Robot Arm Projects...
  • Page 131: Test Code

    Download codes: Codes Download and unzip the file. Open the corresponding code file. Code file for Chapter 9.2.5 is named 9-2-5. Keyestudio ESP32 Robot Arm 9-2-5 tutorial code Function: read the value of the joystick in axis X Y Z http://www.keyestudio.com...
  • Page 132: Read The Remote Lever Value Of The Handle

    WiKi 9.2.7 9.2.7 Read the remote lever value of the handle Connect two remote rod sensors to the ESP32 servo drive board, then read the values and print them through the serial port. Chapter 9. 9. Robot Arm Projects...
  • Page 133 WiKi 9.2.7.1Wiring Diagram 9.2. 9.2 Read Analog Value of Joystick...
  • Page 134 WiKi 9.2.7.2 Code Download codes: Codes Download and unzip the file. Open the corresponding code file. Code file for Chapter 9.2.7.2is named 9-2-7-2. Keyestudio ESP32 Robot Arm 9-2-7-2 tutorial code Function: http://www.keyestudio.com //Define the left remote rod pin #define left_B 12...
  • Page 135: Joystick Control Robot Arm

    9.3.1 9.3.1 Introduction We connect the ESP32 development board and the joystick module to the servo drive board, and then the development board reads the value of the axis X/Y of the module to determine the rotation angle, so that the arm is controlled by the module.
  • Page 136 WiKi Chapter 9. 9. Robot Arm Projects...
  • Page 137: Flow

    WiKi 9.3.2 9.3.2 Flow 9.3. 9.3 Joystick Control Robot Arm...
  • Page 138: Test Code

    WiKi 9.3.3 9.3.3 Test Code Download codes: Codes Download and unzip the file. Open the corresponding code file. Code file for Chapter 9.3.3 is named 9-3-3. Keyestudio ESP32 Robot Arm 9-3-3 tutorial code Function: joystick control the robot arm http://www.keyestudio.com #include "ESP32Servo.h"...
  • Page 139 WiKi (continued from previous page) gripper.attach(gripperPin); base.write(baseAngle); arm.write(armAngle); forearm.write(forearmAngle); gripper.write(gripperAngle); void loop() { // put your main code here, to run repeatedly: left_B_data digitalRead(left_B); left_X_data analogRead(left_X); left_Y_data analogRead(left_Y); right_B_data digitalRead(right_B); right_X_data analogRead(right_X); right_Y_data analogRead(right_Y); baseControl(); armControl(); forearmControl(); gripperControl(); //control base...
  • Page 140 WiKi (continued from previous page) (armAngle <= 80) armAngle delay(10); //control forearm void forearmControl() { (right_Y_data < 20) { while (analogRead(right_Y) < 20) { forearm.write(forearmAngle++); (forearmAngle >= 120) forearmAngle 120; delay(10); else if (right_Y_data > 3000) { while (analogRead(right_Y) >...
  • Page 141: Test Result

    WiKi 9.3.4 9.3.4 Test Result After uploading the code, rotate joysticks to control the arm. For the left joystick, axis X controls the entire rotation of the robot arm (X < 20: turn right; X > 3000: turn left); its axis Y raises and lowers the upper arm (Y <...
  • Page 142 WiKi Chapter 9. 9. Robot Arm Projects...
  • Page 143 WiKi 9.3.5.1 Flow 9.3. 9.3 Joystick Control Robot Arm...
  • Page 144 Download codes: Codes Download and unzip the file. Open the corresponding code file. Code file for Chapter 9.3.5.2 is named 9-3-5-2. Keyestudio ESP32 Robot Arm 9-3-5-2 tutorial code Function: joystick controls arm, axis z stores the rotation angle and re-plays the␣...
  • Page 145 WiKi (continued from previous page) pinMode(left_Y, INPUT); pinMode(right_B, INPUT); pinMode(right_X, INPUT); pinMode(right_Y, INPUT); Serial.begin(9600); base.attach(basePin); // attaches the servo on pin 16 to the servo object arm.attach(armPin); forearm.attach(forearmPin); gripper.attach(gripperPin); base.write(90); arm.write(90); forearm.write(90); gripper.write(90); void loop() { // put your main code here, to run repeatedly: left_B_data digitalRead(left_B);...
  • Page 146 WiKi (continued from previous page) (left_Y_data > 3000) { while (analogRead(left_Y) > 3000) { arm.write(armAngle++); (armAngle >= 180) armAngle 180; delay(10); else if (left_Y_data < 20) { while (analogRead(left_Y) < 20) { arm.write(armAngle--); (armAngle <= 80) armAngle delay(10); //forearm control...
  • Page 147 WiKi (continued from previous page) (right_B_data 1) { delay(10); //eliminate button jitters (right_B_data 1) { attitude_data[base_attitude][data_start_bit] base.read(); delay(100); attitude_data[arm_attitude][data_start_bit] arm.read(); delay(100); attitude_data[forearm_attitude][data_start_bit] forearm.read(); delay(100); attitude_data[gripper_attitude][data_start_bit] gripper.read(); delay(100); data_start_bit++; data_end_bit data_start_bit; (data_start_bit > 10) data_start_bit (left_B_data 1) { delay(10); (left_B_data...
  • Page 148 WiKi (continued from previous page) //forearm (forearmAngle < attitude_data[forearm_attitude][i]) { while (forearmAngle < attitude_data[forearm_attitude][i]) { forearm.write(forearmAngle); delay(10); forearmAngle++; else while (forearmAngle > attitude_data[forearm_attitude][i]) { forearm.write(forearmAngle); delay(10); forearmAngle--; //claw (gripperAngle < attitude_data[gripper_attitude][i]) { while (gripperAngle < attitude_data[gripper_attitude][i]) { gripper.write(gripperAngle); delay(10);...
  • Page 149: Wifi Control Robot Arm

    In the previous project, we learned how to control the robot arm via joysticks. In this experiment, we will control the arm through WiFi. We just need to connect a mobile phone/pad and ESP32 board to one wifi frequency of 2.4GHz (ESP32 only connect to 2.4GHz frequency wifi). After uploading code, we can control the arm by wifi.
  • Page 150 Download and unzip the file. Open the corresponding code file. Code file for Chapter 9.4.2 is named 9-4-2-1. (because there are two codes in this section, add -1 and -2 after 9-4-2 to distinguish) Ensure the ESP32 correctly connects to Wi-Fi first. You may refer to the following code: Keyestudio ESP32 Robot Arm...
  • Page 151 WiKi (continued from previous page) Serial.begin(9600); //initialize Wifi WiFi.begin(ssid, password); //search wifi. while loop: if no wifi is connected, keep searching; state: connecting while (WiFi.status() WL_CONNECTED) { delay(500); Serial.print("."); Serial.println(""); Serial.println("WiFi connected."); //wifi connected: print the IP address Serial.println("Connected to WiFi");...
  • Page 152 WiKi Once Wi-Fi is connected, ESP32’s Web server will serve up web pages. In the following example, we will create a simple web page that says “Hello, World!” : Keyestudio ESP32 Robot Arm 9-4-2-2 tutorial code Function: Conenct to WiFi and print esp32 IP address, set up a web page saying “Hello␣...
  • Page 153 “Hello, World!”. When PC, mobile device and ESP32 board connect to the same network, you can visit that page on two devices simultaneously. Here will be your IP address of ESP32.
  • Page 154: Wifi Control Robot Arm

    WiKi 9.4.3 9.4.3 WiFi Control Robot Arm Chapter 9. 9. Robot Arm Projects...
  • Page 155 WiKi 9.4.3.1 Flow 9.4. 9.4 WiFi Control Robot Arm...
  • Page 156 "your_SSID"; const char *PASS "your_PASSWORD"; Code: Keyestudio ESP32 Robot Arm 9-4-3-2 tutorial code Function: connect ESP32 to wifi to check IP address. Visit the address to enter a␣ control panel to control the arm wirelessly http://www.keyestudio.com #include <WiFi.h> #include <WebServer.h>...
  • Page 157 WiKi (continued from previous page) slider4Value // Default position void setup() { Serial.begin(9600); base.attach(basePin); // Connect base to pin 2 arm.attach(armPin); // Connect arm to pin 4 forearm.attach(forearmPin); // Connect forearm to pin 5 gripper.attach(gripperPin); // Connect gripper to pin 18 delay(100);...
  • Page 158 8, pos4 11).toInt(); gripperControl(val4); // HTML Page String webPage "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta␣ name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>ESP32 Servo␣ Control</title>\ <style>body {font-family: Arial, sans-serif;background-color: #f5f5f5;margin: 0;padding:␣ 0;}\ .container {max-width: 100%;margin: 20px auto;padding: 20px;background-color: #fff; (continues on next page) Chapter 9. 9. Robot Arm Projects...
  • Page 159 10px;border-radius: 5px;background-color: #ddd;outline: none;margin-top:␣ 10px;margin-bottom: 20px;}\ input[type=\"range\"]::-webkit-slider-thumb {-webkit-appearance: none;appearance: none; width: 20px;height: 20px;border-radius: 50%;background-color: #007bff;cursor: pointer;} </style></head><body>\ <div class=\"container\"><h1>ESP32 Servo Control</h1>\ <div class=\"gauge-container\"><div class=\"gauge-label\">Base Servo</div><div class=\ "gauge\"><div id=\"needle1\" class=\"needle\" style=\"transform: rotate(0deg);\"></div> <div id=\"value1\" class=\"value\">90</div></div></div>\ <input type=\"range\" min=\"0\" max=\"180\" value=\"90\" onchange=\"update(this.value, )\">\ <div class=\"gauge-container\"><div class=\"gauge-label\">Arm Servo</div><div class=\...
  • Page 160 WiKi (continued from previous page) client.println("HTTP/1.1 200 OK"); //Sends an HTTP response header to␣ indicate that the server successfully processed the request client.println("Content-Type: text/html"); //Set the type of the response content to␣ HTML client.println("Connection: close"); //Disconnect to the client when the␣...
  • Page 161 WiKi (continued from previous page) else if (angleVal < armAngle) { while (angleVal < armAngle) { arm.write(armAngle--); (armAngle <= 80) armAngle delay(10); // forearm control void forearmControl(int angle) { angleVal map(angle, 0, 180, 30, 150); (angleVal > forearmAngle) {...
  • Page 162 After uploading code, open Arduino IDE and set baud rate to 9600. After the wifi is connected, the serial monitor prints the IP address of ESP32: Open the browser and visit the IP address in the URL bar, such as “192.168.135.7” here. Enter the web page as shown below: Chapter 9.
  • Page 163 WiKi 9.4. 9.4 WiFi Control Robot Arm...
  • Page 164 WiKi Page comments: Drag or click the slider to control the rotation of servo. Chapter 9. 9. Robot Arm Projects...
  • Page 165: Faq

    3. When “— —..— —..— —..” appears and the uploading is exited with an error, please click the “upload” button on IDE and then press the Boot button on ESP32:...
  • Page 166 DC power (being powered ON). When the current of the computer USB port cannot meet the working needs of the robot arm, the ESP32 cannot work normally, so then the connection is unstable. Chapter 10. FAQ...
  • Page 167: Q: Servo Cannot Rotate

    2. Please check whether the WiFi name and passwords are correct. 3. Please check what the frequency of wifi is. The esp32 only connects wifi at a frequency of 2.4GHz. 10.5 Q: Sensors respond slowly when remote control via web.

Table of Contents