5

I'm playing around with this udp-example. Both this and the blink-example work perfectly. Now I would like to use the LED to indicate what the ESP is currently doing, as well as reading some data over Serial. My code looks like this:

void setup(){
  Serial.begin(115200);
  Serial.setTimeout(500);
  while(Serial.available()==0){
  }
  String password = Serial.readStringUntil('.');
  Serial.println(password);
  WiFi.begin(ssid.c_str(), password.c_str());
  //pinMode(LED_BUILTIN, OUTPUT);
  while (WiFi.status() != WL_CONNECTED){
    //digitalWrite(LED_BUILTIN, LOW); 
    delay(250);
    //digitalWrite(LED_BUILTIN, HIGH); 
    delay (250);
  }
  Serial.println("connected");
  Udp.begin(localUdpPort);
}

It works fine, but if I uncomment the led-lines the serial communication doesn't seem to work anymore. All the stuff that is printed on the Serial Monitor is now messed up (missing characters, ...). Is there a problem with my code or what else could be possible going wrong here?

EDIT: I recently tried the same code again, but used an additional power supply (3.3V, 500mA) for the chip. However, this didn't resolve the problem.

  • 2
    Turn the baud rate down to 9600 and see if that helps. Also not sure about the setTimeout call. – Code Gorilla Aug 15 '17 at 12:57
  • 1
    Setting the baud rate to 9600 has no effect when the led stuff is commented out, but if it's not commented I cant see anything on SerialMonitor at all ( setTimeout is also commented out) – user2224350 Aug 15 '17 at 14:58
  • 1
    Do you have a drivers to the LEDs or are they directly attached to the ESP-01? And have you a extra capacitor as power stabilizer over Vcc and GND? – MatsK Aug 18 '17 at 19:49
  • 1
    It is the built in led on the esp I am using. I just connected VCC to VCC of my usb/ftdi- chip (which is plugged in on my notebook). – user2224350 Aug 18 '17 at 19:53
  • 1
    I'm using this chip from AzDelivery FTDI Adapter FT232RL – user2224350 Aug 18 '17 at 19:55
6
+50

I would bet that the built-in LED pin is also the TX pin for the serial interface.

Check here, LED Pin section: http://www.esp8266.com/wiki/doku.php?id=esp8266_gpio_pin_allocations

LED Pin

GPIO1, which is also TX, is wired to the blue LED on many devices. Note that the LED is active low (connected to Vcc and sinks through the chip to ground) so setting a logical value of 0 will light it up. Since GPIO1 is also the TX pin, you won't be able to blink the LED and perform Serial communications at thew same time unless you switch TX/RX pins.

This would be confirmed if the LED blinks when serial communication is active.

If this is the case you would have to add your own LED on a different pin, or switch the RX/TX pins.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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