Esp32 and mit appinventor

Hi, I am making a project with esp32. It is a robotic arm mounted on a car with an esp32cam as a camera. The camera is streaming independently to my app and that is working fine. I created a sta web server using esp32 to receive data from the app. it receives the data fine but forgets it as soon as new data is received.

The code for the car is as follows.

#include <WiFi.h>
#include <WebServer.h>
#include <WiFiManager.h>
#include <ESP32Servo.h>
Servo Gripper;
Servo Shoulder;
Servo Elbow;
Servo Base;
WebServer server(80);
String gripper;
String shoulder;
String elbow;
String base;
String command;      //String to store app command state.
#define ENA 14       // Enable/speed motors Right        GPIO14(D5)
#define ENB 15       // Enable/speed motors Left         GPIO12(D6)
#define IN_1 21      // L298N in1 motors Right           GPIO15(D8)
#define IN_2 17      // L298N in2 motors Right           GPIO13(D7)
#define IN_3 18      // L298N in3 motors Left            GPIO2(D4)
#define IN_4 19      // L298N in4 motors Left            GPIO0(D3)
int speedCar = 800;  // 400 - 1023.
int speed_Coeff = 3;

void setup() {
  Serial.begin(115200);
  Gripper.attach(33);
  Shoulder.attach(27);
  Elbow.attach(26);
  Base.attach(25);

  Gripper.write(90);
  Shoulder.write(90);
  Elbow.write(90);
  Base.write(90);
  pinMode(ENA, OUTPUT);
  pinMode(ENB, OUTPUT);
  pinMode(IN_1, OUTPUT);
  pinMode(IN_2, OUTPUT);
  pinMode(IN_3, OUTPUT);
  pinMode(IN_4, OUTPUT);
  WiFiManager wifiManager;
  IPAddress _ip = IPAddress(192, 168, 1, 4);
  IPAddress _gw = IPAddress(10, 0, 1, 1);
  IPAddress _sn = IPAddress(255, 255, 255, 0);
  //end-block2

  wifiManager.setSTAStaticIPConfig(_ip, _gw, _sn);
  wifiManager.autoConnect("carm", "dsthebest");
  Serial.print(WiFi.localIP());

  server.on("/", handle_OnConnect);
  server.onNotFound(handle_NotFound);

  server.begin();
  Serial.println("HTTP server started");
  delay(2000);
}
void goAhead() {
  Serial.println("forward");
  digitalWrite(IN_1, LOW);
  digitalWrite(IN_2, HIGH);
  analogWrite(ENA, speedCar);

  digitalWrite(IN_3, LOW);
  digitalWrite(IN_4, HIGH);
  analogWrite(ENB, speedCar);
}

void goBack() {

  digitalWrite(IN_1, HIGH);
  digitalWrite(IN_2, LOW);
  analogWrite(ENA, speedCar);

  digitalWrite(IN_3, HIGH);
  digitalWrite(IN_4, LOW);
  analogWrite(ENB, speedCar);
}

void goRight() {

  digitalWrite(IN_1, HIGH);
  digitalWrite(IN_2, LOW);
  analogWrite(ENA, speedCar);

  digitalWrite(IN_3, LOW);
  digitalWrite(IN_4, HIGH);
  analogWrite(ENB, speedCar);
}

void goLeft() {

  digitalWrite(IN_1, LOW);
  digitalWrite(IN_2, HIGH);
  analogWrite(ENA, speedCar);

  digitalWrite(IN_3, HIGH);
  digitalWrite(IN_4, LOW);
  analogWrite(ENB, speedCar);
}

void stopRobot() {

  digitalWrite(IN_1, LOW);
  digitalWrite(IN_2, LOW);
  analogWrite(ENA, speedCar);

  digitalWrite(IN_3, LOW);
  digitalWrite(IN_4, LOW);
  analogWrite(ENB, speedCar);
}
void loop() {
  server.handleClient();
  gripper = server.arg("claw");
  int griper = gripper.toInt();
  Serial.print(griper);
  Gripper.write(griper);
  shoulder = server.arg("shoulder");
  int sholder = shoulder.toInt();
  //Serial.println(sholder);
  //Shoulder.write(sholder);
  elbow = server.arg("elbow");
  int ebow = elbow.toInt();
  // Serial.println(ebow);
  //Elbow.write(ebow);
  base = server.arg("base");
  int bas = base.toInt();
  Serial.println(bas);
  Base.write(bas);
  command = server.arg("State");
  Serial.print(command);
  if (command == "F") goAhead();
  else if (command == "B") goBack();
  else if (command == "L") goLeft();
  else if (command == "R") goRight();
  else if (command == "0") speedCar = 400;
  else if (command == "1") speedCar = 470;
  else if (command == "2") speedCar = 540;
  else if (command == "3") speedCar = 610;
  else if (command == "4") speedCar = 680;
  else if (command == "5") speedCar = 750;
  else if (command == "6") speedCar = 820;
  else if (command == "7") speedCar = 890;
  else if (command == "8") speedCar = 960;
  else if (command == "9") speedCar = 1023;
  else if (command == "S") stopRobot();
}
void handle_OnConnect() {
  server.send(200, "text/html", "welcome");
}
void handle_NotFound() {
  server.send(404, "text/plain", "Not found");
}

im using sliders to send data for the arm. The code to send data is as follows

How many byte are there in on set of data? How many data sets do You need to store/remember?

there are 10 different sets of data
4 for the arm
6 for the car

for the arm, the value can be between 0 to 180 according to the slider in my app

for the car, there are 5 values to make it move forward, backward, right, left and stop. also one value for speed

this is the whole code for the app

maximum values for the sliders 1-4(to control the arm) is 180 and maximum value for slider 5(for speed of car) is 9

Please read the entire reply in #2 and reply to it. Your reply doesn't tell much.

Please read this link: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

Your Christmas tree looking picture...... Use the advice from forum how to post code.

It tells nothing. In programming certain standard data types are used and they occupy different lengths. Tell the format of the byte stream.

i dont know a lot about programming...so I am unable to understand your question about the byte stream

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.