Serial.readBytesUntil() lee los caracteres del buffer serie en una matriz. La función termina si:

  • Se detecta el carácter terminador,
  • La longitud determinada ha sido leído,
  • O el tiempo de espera se ha alcanzado (ver Serial.setTimeout()).

Serial.readBytesUntil() devuelve el número de caracteres leídos en el buffer. Un 0 significa que no se encontraron datos válidos.

Serial.readBytesUntil() hereda de la clase Stream.


Serial.readBytesUntil(character, buffer, length)


  • character: el caracter a buscar(char)
  • buffer: el buffer para almacenar los bytes (char[] o byte[])
  • length: tel número de bytes a leer (int)


  • Byte


const int BUFFER_SIZE = 100; char buf[BUFFER_SIZE]; void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps } void loop() { // check if data is available if (Serial.available() > 0) { // read the incoming bytes: int rlen = Serial.readBytesUntil('\n', buf, BUFFER_SIZE); // prints the received data Serial.print("I received: "); for(int i = 0; i < rlen; i++) Serial.print(buf[i]); } }
  • Select Newline at the ending selection of Serial Monitor
  • Type "HELLO" on Serial Monitor
  • Click Send button:
  • COM6
    Autoscroll Show timestamp
    Clear output
    9600 baud  
  • The result on Serial Monitor:
  • COM6
    I received: HELLO
    Autoscroll Show timestamp
    Clear output
    9600 baud  

※ Nota:

Serial functions are not only used for the communication between an Arduino board and Serial Monitor of Arduino IDE but also used for the communication between:

  • An Arduino board and other Arduino board
  • An Arduino board and other sensors/devices
  • An Arduino board and computer (any Serial software on computer)

Ver También


Arduino UNO R3
Arduino Starter Kit
Please note: These are affiliate links. If you buy the components through these links, We may get a commission at no extra cost to you. We appreciate it.


  • We are AVAILABLE for HIRE. See how to hire us to build your project
  • Any suggestion, correction, and translation? please email us at, We appreciate it
  • We mainly keep improving the references in English. See English version of this page for the latest update.