-1

I use esp32 devkit v1 . I code follwing this picture. enter image description here

const int vavle = 1;
int d = 1;

void setup()
{
  Serial.begin(115200);
  delay(2000);
  while (!Serial);
  Serial.println();
  pinMode(vavle,OUTPUT);
  Serial.println(d);
}

void loop()
{
  Serial.print("Open Vavle");
  digitalWrite(vavle,HIGH);
  delay(3000);
  digitalWrite(vavle,LOW);
  delay(1000);
  Serial.print("Close Vavle");
}

but serial monitor has error when use serial monitor it show me square . I confirm select true board rate. you can solve this problem .

2
  • 3
    first thing to remember when posting here is never post a picture of text unless absolutely necessary ... please copy your code and paste into your question ... also copy and paste the entire content of the serial monitor
    – jsotola
    Oct 30, 2023 at 17:25
  • Side note: You probably want to open or close a valve.
    – PMF
    Oct 31, 2023 at 9:16

1 Answer 1

1

The GPIO1 pin you are trying to use with const int vavle = 1; ... pinMode(vavle, OUTPUT); is the same pin that carries serial data to the PC.

From the pinout:

DOIT ESP32 DEVKIT V1 PINOUT with TX0/GPIO1/U0TXD pin highlighted.

Their schematic link is broken, but if you find schematic for pretty much any similar board using this module you'll see GPIO1/U0TXD connected to a serial transceiver chip which is then connected to the USB port.

You need choose some other pin. There are pin guides and official documentation containing the same details that you can use to figure out which GPIO to use. GPIO numbers 16 through 33 inclusive are all output-capable and seem to have no special requirements, so they make sense to choose from.

1
  • Thank you ,I can solve this problem
    – poom
    Oct 30, 2023 at 21:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.