title: Atoi() function not working Arduino
body: <p>The Arduino <code>atoi()</code> function is not working as expected. The original is 656649, but when converted to a string, it prints 1289. What could be happening? Thanks!</p>
  
  <pre><code>void setup() {
    Serial.begin(9600);
  }
  
  void loop() {
    String BT1 = "656649"
    Serial.print(" String BT1: ");
    Serial.print(BT1); // OUTPUT: 656649
    char charBuf[50];
    BT1.toCharArray(charBuf, 50) ;
    Serial.print("Char buff: "); // OUTPUT: 656649
    Serial.print(charBuf);
    intBT1 = atoi(charBuf);
    Serial.print(" intBT1: "); //OUTPUT: 1289
    Serial.print(intBT1);
  }
  </code></pre>