├── ESP32 Camera Robot Schematic.png ├── README.md ├── esp32_camera_robot └── esp32_camera_robot.ino └── index.html /ESP32 Camera Robot Schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awende/ESP32_Camera_Robot/60dc3c20daee844a6381cd1445bf19cc3268b9b3/ESP32 Camera Robot Schematic.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ESP32 Camera Robot 2 | ============================================ 3 | 4 | ![ESP32 Camera Robot](https://cdn.sparkfun.com/r/500-500/assets/home_page_posts/2/6/4/2/Alexginursday-04.jpg) 5 | 6 | Repository Contents 7 | ------------------- 8 | 9 | * **/esp32_camera_robot** - Arduino code to load on to the ESP32 (.ino) 10 | * **ESP32 Camera Robot Schematic** - Schematic of electrical components of the robot (.png) 11 | * **index** - load this file on to an SD card and plug into the ESP32 Motion Shield (.html) 12 | 13 | License Information 14 | ------------------- 15 | The hardware is released under [Creative Commons Share-alike 3.0](http://creativecommons.org/licenses/by-sa/3.0/). 16 | All other code is open source so please feel free to do anything you want with it; you buy me a beer if you use this and we meet someday ([Beerware license](http://en.wikipedia.org/wiki/Beerware)). -------------------------------------------------------------------------------- /esp32_camera_robot/esp32_camera_robot.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * To use this code, download the ESP32WebServer library from: https://github.com/Pedroalbuquerque/ESP32WebServer 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | const char* ssid = "*************"; 12 | const char* password = "*********"; 13 | 14 | ESP32WebServer server(80); //Default port number 15 | 16 | void handleRoot() { 17 | /* we load the index.html from microSD */ 18 | File myFile = SD.open("/index.html"); 19 | if (myFile) { 20 | /* respond the content of file to client by calling streamFile()*/ 21 | size_t sent = server.streamFile(myFile, "text/html"); 22 | /* close the file */ 23 | myFile.close(); 24 | } else { 25 | Serial.println("error opening index.html"); 26 | } 27 | } 28 | 29 | //XML page to listen for motor commands 30 | void handleMotors() { 31 | String motorState = "OFF"; 32 | String t_state = server.arg("motorState"); //Refer xhttp.open("GET", "setMotors?motorState="+motorData, true); 33 | 34 | Serial.print("D\r\n"); //Disable motors 35 | delay(50); 36 | if(t_state.startsWith("U")) //Drive Forward (UP Arrow) 37 | { 38 | if(t_state == "U1") 39 | { 40 | Serial.print("M0F70\r\n"); 41 | delay(50); 42 | Serial.print("M1F68\r\n"); 43 | delay(50); 44 | Serial.print("E\r\n"); 45 | } 46 | else if(t_state == "U3") 47 | { 48 | Serial.print("M0F70\r\n"); 49 | delay(50); 50 | Serial.print("M1F68\r\n"); 51 | delay(50); 52 | Serial.print("E\r\n"); 53 | delay(100); 54 | Serial.print("D\r\n"); 55 | } 56 | } 57 | else if(t_state.startsWith("D")) //Reverse (DOWN Arrow) 58 | { 59 | if(t_state == "D1") 60 | { 61 | Serial.print("M0R70\r\n"); 62 | delay(50); 63 | Serial.print("M1R68\r\n"); 64 | delay(50); 65 | Serial.print("E\r\n"); 66 | } 67 | else if(t_state == "D3") 68 | { 69 | Serial.print("M0R70\r\n"); 70 | delay(50); 71 | Serial.print("M1R68\r\n"); 72 | delay(50); 73 | Serial.print("E\r\n"); 74 | delay(100); 75 | Serial.print("D\r\n"); 76 | } 77 | } 78 | else if(t_state.startsWith("R")) //Turn Right (Right Arrow) 79 | { 80 | if(t_state == "R1") 81 | { 82 | Serial.print("M0R30\r\n"); 83 | delay(50); 84 | Serial.print("M1F30\r\n"); 85 | delay(50); 86 | Serial.print("E\r\n"); 87 | } 88 | else if(t_state == "R2") 89 | { 90 | Serial.print("M0R50\r\n"); 91 | delay(50); 92 | Serial.print("M1F50\r\n"); 93 | delay(50); 94 | Serial.print("E\r\n"); 95 | delay(200); 96 | Serial.print("D\r\n"); 97 | } 98 | else if(t_state == "R3") 99 | { 100 | Serial.print("M0R50\r\n"); 101 | delay(50); 102 | Serial.print("M1F50\r\n"); 103 | delay(50); 104 | Serial.print("E\r\n"); 105 | delay(100); 106 | Serial.print("D\r\n"); 107 | } 108 | } 109 | else if(t_state.startsWith("L")) //Turn Left (LEFT Arrow) 110 | { 111 | if(t_state == "L1") 112 | { 113 | Serial.print("M0F30\r\n"); 114 | delay(50); 115 | Serial.print("M1R30\r\n"); 116 | delay(50); 117 | Serial.print("E\r\n"); 118 | } 119 | else if(t_state == "L2") 120 | { 121 | Serial.print("M0F50\r\n"); 122 | delay(50); 123 | Serial.print("M1R50\r\n"); 124 | delay(50); 125 | Serial.print("E\r\n"); 126 | delay(200); 127 | Serial.print("D\r\n"); 128 | } 129 | else if(t_state == "L3") 130 | { 131 | Serial.print("M0F50\r\n"); 132 | delay(50); 133 | Serial.print("M1R50\r\n"); 134 | delay(50); 135 | Serial.print("E\r\n"); 136 | delay(100); 137 | Serial.print("D\r\n"); 138 | } 139 | } 140 | 141 | server.send(200, "text/plain", motorState); //Send web page 142 | } 143 | /* cannot handle request so return 404 */ 144 | void handleNotFound(){ 145 | String message = "File Not Found\n\n"; 146 | server.send(404, "text/plain", message); 147 | } 148 | 149 | void setup(void){ 150 | Serial.begin(9600); 151 | WiFi.begin(ssid, password); 152 | 153 | Serial.println(""); 154 | 155 | // Wait for connection 156 | while (WiFi.status() != WL_CONNECTED) { 157 | delay(500); 158 | Serial.print("."); 159 | } 160 | Serial.println(""); 161 | Serial.print("Connected to "); 162 | Serial.println(ssid); 163 | Serial.print("IP address: "); 164 | Serial.println(WiFi.localIP()); 165 | 166 | /* register the callbacks to process client request */ 167 | /* root request we will read the memory card to get 168 | the content of index.html and respond that content to client */ 169 | server.on("/", handleRoot); 170 | server.on("/setMotors", handleMotors); 171 | server.onNotFound(handleNotFound); 172 | server.begin(); 173 | 174 | Serial.println("HTTP server started"); 175 | Serial.print("Initializing SD card..."); 176 | /* initialize microSD */ 177 | if (!SD.begin(33)) { 178 | Serial.println("initialization failed!"); 179 | return; 180 | } 181 | Serial.println("initialization done."); 182 | } 183 | 184 | void loop(void){ 185 | server.handleClient(); 186 | } 187 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 91 | 92 | 93 |

SparkFun ESP32 Thing + WiFi Camera Remote Control

94 | 95 |
96 |

How to Control the Robot

97 |
    98 |
  • Use the arrow keys to control the robot. You can press and hold for continuous movement, or single presses for small movements.
  • 99 |
  • Sometimes the robot doesn't receive a stop command, and will continue to move after the key has been released. Just give a single keyboard click to stop the robot.
  • 100 |
  • Be patient! The robot might go offline periodically due to signal strength, battery changes, or there are too many users connected.
  • 101 |
102 | 103 |

Welcome to SparkFun Engineering

104 |

105 | The robot is in SparkFun's Engineering department, feel free to drive around and pop in and out of people's offices. Alex's office (who made the robot) is in the office with 106 | Han Solo on the door. Barriers are set up to keep the robot in Engineering, please try not to crash into them (or else he'll get stuck until someone frees it). 107 |

108 | 109 | --------------------------------------------------------------------------------