title: ESP32 Hardware Serial - only write 1 byte at a time
body: <p>I'm using </p>
  
  <pre><code>Serial2.begin(9600, SERIAL_8N1, 15, 14,true);
  Serial2.write(b,100);
  </code></pre>
  
  <p>To write a buffer to serial from the esp32</p>
  
  <p><strong>But for some reason it doesn't transmit the full buffer ?</strong>
  Instead it transmit one byte at a time.</p>
  
  <p><a href="https://i.stack.imgur.com/6KS5K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6KS5K.png" alt="data recived"></a></p>
  
  <p>Any one have an advise on how I can transmit the full buffer, instead of 1 byte at a time ?</p>
  
  <p>Code example:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;HardwareSerial.h&gt;
  
  void setup() {
      Serial.begin(9600);
      Serial2.begin(9600, SERIAL_8N1, 15, 14,true); 
  }
  
  uint8_t buf[1000];
  
  uint8_t* genBuffer(const char* txt, int* bufSZ)
  {
      int index = 0;
      int i = 0;
  
      buf[index++] = 0x00;
      buf[index++] = 0x00;
      buf[index++] = 0x00;
      buf[index++] = 0x00;
      buf[index++] = 0x00;
      buf[index++] = 0x01;
      buf[index++] = 0x46;
      buf[index++] = 0x46;
      buf[index++] = 0x30;
      buf[index++] = 0x30;
      buf[index++] = 0x02;
      buf[index++] = 0x41;
      buf[index++] = 0x41;
      buf[index++] = 0x43;
      buf[index++] = 0x32;
  
      for (i = 0; txt[i]; i++) {
          buf[index++] = txt[i];
      }
  
      *bufSZ = index;
  
      return buf;
  }
  
  void loop()
  {
      int sz = 0;
      uint8_t* b = genBuffer("test", &amp;sz);     
      Serial.println(sz); 
      Serial2.write(b,sz);
  
      for (int i = 0; i &lt; sz; i++) {  
          Serial.print(" ");
          Serial.print(b[i], HEX);
      }
      Serial.println();
      delay(5000);
      // put your main code here, to run repeatedly:
  }
  </code></pre>