A New Software Serial Library for Arduino

News: NewSoftSerial is in the core!  Starting with Arduino 1.0 (December, 2011), NewSoftSerial has replaced the old SoftwareSerial library as the officially supported software serial library.  This means that if you have 1.0 or later, you should not download this library.  To port your code to 1.0, simply change all NewSoftSerial references to SoftwareSerial.

NewSoftSerial is the latest of three Arduino libraries providing “soft” serial port support. It’s the direct descendant of ladyada’s AFSoftSerial, which introduced interrupt-driven receives – a dramatic improvement over the polling required by the native SoftwareSerial.

Without interrupts, your program’s design is considerably restricted, as it must continually poll the serial port at very short, regular intervals. This makes it nearly impossible, for example, to use SoftwareSerial to receive GPS data and parse it into a usable form. Your program is too busy trying to keep up with NMEA characters as they arrive to actually spend time assembling them into something meaningful. This is where AFSoftSerial’s (and NewSoftSerial‘s) interrupt architecture is a godsend. Using interrupt-driven RX, your program fills its buffer behind the scenes while processing previously received data.


NewSoftSerial offers a number of improvements over SoftwareSerial:

  1. It inherits from built-in class Print, eliminating some 4-600 bytes of duplicate code
  2. It implements circular buffering scheme to make RX processing more efficient
  3. It extends support to all Arduino pins 0-19 (0-21 on Arduino Mini), not just 0-13
  4. It supports multiple simultaneous soft serial devices.*
  5. It supports a much wider range of baud rates.**
  6. It provides a boolean overflow() method to detect buffer overflow.
  7. Higher baud rates have been tuned for better accuracy.
  8. It supports the ATMega328 and 168.
  9. It supports 8MHz processors.
  10. It uses direct port I/O for faster and more precise operation.
  11. (New with version 10).  It supports software signal inversion.
  12. (New) It supports 20MHz processors.
  13. (New) It runs on the Teensy and Teensy++.
  14. (New) It supports an end() method as a complement to begin().

*But see below for an important caveat on multiple instances.
**Be circumspect about using 300 and 1200 baud though. The interrupt handler at these rate becomes so lengthy that timer tick interrupts can be starved, causing millis() to stop working during receives.

Using Multiple Instances

There has been considerable support for an library that would allow multiple soft serial devices. However, handling asynchronously received data from two, three, or four or more serial devices turns out to be an extremely difficult, if not intractable problem. Imagine four serial devices connected to an Arduino, each transmitting at 38,400 baud. As bits arrive, Arduino’s poor little processor must sample and process each of 4 incoming bits within 26 microseconds or else lose them forever. Yikes!

It occurred to me, though, that multiple instances could still be possible if the library user were willing to make a small concession. NewSoftSerial is written on the principle that you can have as many devices connected as resource constraints allow, as long as you only use one of them at a time. If you can organize your program code around this constraint, then NewSoftSerial may work for you.

What does this mean, exactly? Well, you have to use your serial devices serially, like this:

#include <NewSoftSerial.h>

// Here's a GPS device connect to pins 3 and 4
NewSoftSerial gps(4,3);

// A serial thermometer connected to 5 and 6
NewSoftSerial therm(6,5);

// An LCD connected to 7 and 8
NewSoftSerial LCD(8,7); // serial LCD

void loop()
  // collect data from the GPS unit for a few seconds
  read_gps_data();  // use gps as active device
  // collect temperature data from thermometer
  read_thermometer_data(); // now use therm
  // LCD becomes the active device here
  LCD.print("Data gathered...");

In this example, we assume that read_gps_data() uses the gps object and read_thermometer_data() uses the therm object. Any time you call the listen() method, it becomes the “active” object, and the previously active object is deactivated and its RX buffer discarded. An important point here is that object.available() always returns 0 unless object is already active. This means that you can’t write code like this:

void loop()
  if (device1.available() > 0)
    int c =;
  if (device2.available() > 0)
    int c =;

This code will never do anything but activate one device after the other.

Signal Inversion

“Normal” TTL serial signaling defines a start bit as a transition from “high” to “low” logic.  Logical 1 is “high”, 0 is “low”.  But some serial devices turn this logic upside down, using what we call “inverted signaling”.  As of version 10, NewSoftSerial supports these devices natively with a third parameter in the constructor.

NewSoftSerial myInvertedConn(7, 5, true); // this device uses inverted signaling
NewSoftSerial myGPS(3, 2); // this one doesn't

Library Version

You can retrieve the version of the NewSoftSerial library by calling the static member library_version().

int ver = NewSoftSerial::library_version();

Resource Consumption

Linking the NewSoftSerial library to your application adds approximately 2000 bytes to its size.


The latest version of NewSoftSerial is available here:  Note: don’t download this if you have Arduino 1.0 or later.  As of 1.0, NewSoftSerial is included in the Arduino core (named SoftwareSerial).

Change Log

  1. initial version
  2. ported to Arduino 0013, included example sketch in package
  3. several important improvements: (a) support for 300, 1200, 14400, and 28800 baud (see caveats), (b) added bool overflow() method to test whether an RX buffer overflow has occurred, and (c) tuned RX and TX for greater accuracy at high baud rates 38.4K, 57.6K, and 115.2K.
  4. minor bug fixes — add .o file and objdump.txt to zip file for diagnostics.
  5. etracer’s inline assembler fix to OSX avr-gcc 4.3.0 interrupt handler bug added.
  6. ladyada’s new example sketch, fix to interrupt name, support for 328p.
  7. etracer’s workaround is now conditionally compiled only when avr-gcc’s version is less than 4.3.2.
  8. 8 MHz support and flush() and enable_timer0()  methods added
  9. digitalread/write scrapped in favor of direct port I/O.  Revised routines now get perfect RX up to 57.6K on 16MHz processors and 31.25K on 8MHz processors.
  10. inverted TTL signalling supported.  20MHz processors supported.  Teensy and Teensy++ supported.  New end() method and destructor added to clean up.
  11. added listen() method to explicitly activate ports.
  12. warn users about 1.0 conflict


Many thanks to David Mellis, who wrote the original SoftwareSerial, and to the multi-talented ladyada, whose work with AFSoftSerial is seminal.  Ladyada also provided the “Goodnight, moon” example sketch, fixed a problem with the interrupt naming (see v6) and tested NSS with the 328p.

Thanks also to rogermm and several other forum users who have tested NewSoftSerial and given useful feedback.

The diligent analysis of forum user etracer yielded the root cause of a tricky problem with NSS on OSX.  A bug in avr-gcc 4.3.0 causes the compiler to fail to generate the proper entry and exit sequences for certain interrupt handlers.  etracer identified the problem and provided an inline workaround.  etracer’s fix is in NSS 5.

User jin contributed a large body of work based on NSS and identified a potential problem that could result in data loss (fixed in NSS 5).  jin also made a variant of NSS that supports 4-pin serial, with the additional pins providing a very nice RTS/CTS flow control.  We may see this in NSS in the near future.

Thanks to Garret Mace, who contributed the delay tables for 20MHz processors and claims that he can send and receive at 115K baud.  Cool!

Thanks to Paul Stoffregen, both for his fine work with Teensy and Teensy++, and for contributing some useful suggestions that help NewSoftSerial run on them without modification.

I appreciate any and all input.

Mikal Hart

Page last updated on July 3, 2013 at 7:37 pm
621 Responses → “NewSoftSerial”

  1. Tyler DeWitt

    3 years ago

    I’ve been out of the Arduino world for a while, sorry if this has been answered. When I try to compile to library I get the following error:

    In file included from NewSoftSerialTest.cpp:2:
    C:\Users\tyler.HQ\Documents\Arduino\libraries\NewSoftSerial/NewSoftSerial.h:71: error: conflicting return type specified for ‘virtual void NewSoftSerial::write(uint8_t)’
    C:\Users\tyler.HQ\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error: overriding ‘virtual size_t Print::write(uint8_t)’

    I took a look at those files, and the names of the function are the same (write), but they are declared in different classes. Is there a fix for that?

    PS-I made a reverse geocaching box years ago and still love playing with it. Thanks for the great idea!

  2. Jason R. Smith

    3 years ago

    This worked like a charm! Great job! I am using it to talk to a CrystalFontz CFA632-NFA-KS LCD display. One thing, though – The board was expecting inverted signal, but it didn’t work when I used the “true” designator when I created the NSS instance. I removed that, and it worked fine. Not sure what to make of that.

  3. Roy

    3 years ago

    Hi, new to your website. Great work.

    I recently downloaded your newsoftserial library and attempted to use it with the latest Ardino l download. I am experiencing compiler errors for
    NSS.write on a UNO target. Compiling worked when using an older version 0022. Any suggestions?? Compile error follows.

    In file included from sketch_dec12b.cpp:1:
    C:\Users\Roy\Documents\Arduino\libraries\NewSoftSerial/NewSoftSerial.h:71: error: conflicting return type specified for ‘virtual void NewSoftSerial::write(uint8_t)’
    C:\arduino-ONE\hardware\arduino\cores\arduino/Print.h:48: error: overriding ‘virtual size_t Print::write(uint8_t)’

  4. Cenek

    3 years ago

    hello, I need 2 stop bits, how should I change the code? thanks

  5. amok

    3 years ago

    after I moved to Arduino IDE 1.0, the NewSoftSerial doesn’t compile anymore. Any trick/tweak on how to get that fixed? Thx!

  6. Mikal

    2 years ago

    Things have changed in Arduino land. I need to build new versions of all my libraries.


  7. Mikal

    2 years ago


    No, unfortunately, both sending and receiving a byte require total control of the processor. You can’t (reliably) receive data while transmitting.

  8. Mikal

    2 years ago


    Gee, I don’t know. 19.2K is not a very fast speed. I’m not sure. Anyone?

  9. Jim

    2 years ago

    Hello Mikal.
    I have two serial displays that I have been using with a Basic Stamp project. I am now converting the entire project over to an Arduino UNO. I am using NewSoftSerial software so I can have two serial ports. However I can not get either display to work. After much diagnosis I have learned that the way the Basic Stamp was talking to them was a serial command of 9600baud 8bit no parity inverted. I had no idea that I was using an inverted command until I dug into the old stamp code. So I added the “,true” statement to the NewSoftSerial but no help. Is it posible there is more I need to do?


  10. Mikal

    2 years ago

    @Justin, yes, unfortunately it does require some careful thought to get it just right.

  11. Mikal

    2 years ago

    @Tyler, if you’re using 1.0 you should use SoftwareSerial, which is really just NewSoftSerial renamed and inserted into the core.

  12. Mikal

    2 years ago


    With Arduino 1.0 you no longer use the external NewSoftSerial library. It has been renamed “SoftwareSerial” (replacing the old SoftwareSerial) and place in the core.

  13. Mikal

    2 years ago


    I would expect that to work with the “true” parameter for inverted logic. Hmm..

  14. Jan Krueger

    2 years ago

    hi out there,

    i have an issue with the serial port of my ArduinoProMini (16MHz), which i hope might be no big deal for someone with more insight than me…

    i am reading serial data from a Spektrum Satellite receiver (16bytes every 22msec), in 115200 baud. to have good accuracy, i used the hardware serial port for this (only RX).

    to monitor the data, i use SoftwareSerial (output) via the FTDI (only TX), with 115200 baud, too – works very well!

    NOW when i change the baud rate of the SoftwareSerial monitor to 38400 baud (which i will later need to control a Pololu-Servo-Interface-board), the data gets corrupted! that is, you can still recognise the pattern, but there are many damaged or missed bytes.

    any idea, comment, help? thanks so much -

    jan from berlin

    ps. here comes the very simple script that doesn’t work (or does work with MonitorSerial.begin (115200) instead of (38400))…

    SoftwareSerial MonitorSerial(5, 6); // serial monitor on Pin 6 (only RX)

    // serial data from Satellite receiver is connected to RX1 on the
    // ArduinoProMini, 5V, 16MHz, ATmega328; Arduino Software 1.0

    int index = 1;
    int val[17];
    int burp = 0;

    void setup()
    MonitorSerial.begin(38400); // to monitor on screen, or later forward
    MonitorSerial.print(“Test”); // processed values to Servo-Interface
    MonitorSerial.println(); // with max. baudrate 38400

    Serial.begin(115200); // serial data rate of the Spektrum Satellite

    void loop()
    if (Serial.available() > 0)
    if (val [index] == 0×01 && val [index-1] >=0)
    for (index =0; index <17; index++)

  15. Ian

    2 years ago

    Hi Mikal,
    Great work :)
    It isn’t clear to me how timing is managed. It seems to me that ‘MsTimer2′ conflicts with your library?


  16. Mikal

    2 years ago


    Anything that generates interrupts (read: Tone, Servo, MsTimer2) has the potential of interfering with the NewSoftSerial timing, and vice versa.

  17. conrad

    2 years ago

    Hi Mikal,
    I just read your response to @Ian and realised that is my problem as well! I’m reading a compass and GPS with the SoftwareSerial and triggering a camera with the Servo.h library. Alone, the Servo trigger works great, the moment I SoftwareSerial.begin(), the signal when Servo.write(0) then the signal fluctuates. I don’t get this behaviour though when Servo.write(180) – the max.
    Any thoughts on a solution to this?
    Thanks and have a great day,
    Conrad :)

  18. Mikal

    2 years ago


    Yep, it’s a pretty well-known problem. One workaround that I often use is to employ the older version of the Arduino Servo library, which I have posted here as PWMServo. It doesn’t use interrupts to drive the motor, but has the disadvantage of only being usable on pins 9 or 10. Will that work for you?

  19. Marjan

    2 years ago

    Hi, Mikal!

    1. Library works great for enabling another serial to ATmega328 series – having universal code for both boards (below).

    2. Now I would like to attach a (non-default) logger which has 4800,8E2,no handshake protocol.

    @Cenek, @Tinker, … Maybe anyone heard of configurability options, parity, data and stopbit configuration options below already implemented?

    3. What about adding code to TX – void SoftwareSerial::write(uint8_t b), between 8th bit and “restoring pin to natural state”, sth. like:

    if Even(b) { // calculate Even
    tx_pin_write(HIGH); // send 1
    tx_pin_write(HIGH); // send 1st stop bit
    tx_pin_write(HIGH); // send 2nd stop bit

    Here’s my code part:

    #ifdef MEGA
    const byte rxPin = 19; // (just for breadboard /proto reference)
    const byte txPin = 18; //
    #define serDevice Serial1 // substitute
    const byte rxPin = 6; // receivePin
    const byte txPin = 7; // transmitPin
    SoftwareSerial serDevice = SoftwareSerial(rxPin, txPin);

  20. David (D9W)

    2 years ago

    I was wondering if you have run across problems with using the LS20031 GPS from SparkFun and the SoftwareSerial? You can read over at the Sparkfun forum what I have ran into with this library >>

    If I do a direct serial dump to the monitor I get clean good GPS “code”, but using SoftwareSerial I get things like >>


    Not all of the characters are showing up in that example, but I think you can see some of them.

    What kills me is that back in .22 IDE I got both this library and tinyGPS to work with expanding the buffer out >>
    changed ->
    define _NewSS_MAX_RX_BUFF 64 // RX buffer size


    define _NewSS_MAX_RX_BUFF 256// RX buffer size
    but changing that or changing Baud rates has no effect now with the new 1.0 IDE.
    (When I say that if you have the wrong baud rate you just get nonsense- meaning if I had it wrong you don’t get sense and nonsense mixed together).

    Do my question- What am I doing wrong?

  21. Nacho Mas

    2 years ago


    I have interferences with my code using softwareserial to read a gps. My code use timer2 isr to implement a modem.

    Modem function are critical for my application. Loosing some gps data frames are not a problem so I want to stop gps rx when modem is in use.

    ¿What is the best way to disable temporally all serialsoft interrupts and processing?

    Thank you for this great soft!

    Thank you in advance
    Nacho Mas

  22. yrame

    2 years ago

    Hi! I am working with a Gizduino with GSM module which will act as an SMS controller of appliances. The user will text ON/OFF or may inquire about the switching state of the appliance being controlled. My problems are:

    1. I don’t know how to interface AT commands with Arduino.

    2. I’m not sure if the GSM module gets the text message being sent, because when I tried to text ON, there was no output in the serial monitor.

    3. Serial.print(“AT”) – does this really make the GSM module respond? Or is it just a mere text output?

    Help me please… I wanna graduate already! T-T

  23. Mikal

    2 years ago


    I don’t have time right now to develop the necessary support for differing serial protocols, but I’m pretty sure that your proposed solution would work. There are two places in NewSoftSerial where bits are serialized either in or out. If you modify this code slightly you should be able to support 8E2 or 7N1 or whatever you like. Ultimately, it would be cool to supply a parameter on the NewSoftSerial constructor that allowed the user to specify the protocol. They are talking of doing this with the HardwareSerial port. Thanks for the feedback.


  24. Mikal

    2 years ago

    David, 57.6K baud is pretty dicey for software serial. Does the unit you mention support lower baud rates? What other devices are you using that may be interfering with timing?

  25. Cenek

    2 years ago

    hello, I need “2 stop bits”, how should I change the code? thanks. f.

  26. Mikal

    2 years ago

    @Cenek, and everyone who wants a protocol other than the default N81,

    You need to modify two functions, the ones responsible for serializing the bits of a byte for TX and RX. These are, respectively, write() and recv(). In write() you look for this code:

     if (_inverse_logic)
        for (byte mask = 0x01; mask; mask < <= 1)
          if (b & mask) // choose bit
            tx_pin_write(LOW); // send 1
            tx_pin_write(HIGH); // send 0
        tx_pin_write(LOW); // restore pin to natural state
        for (byte mask = 0x01; mask; mask <<= 1)
          if (b & mask) // choose bit
            tx_pin_write(HIGH); // send 1
            tx_pin_write(LOW); // send 0
        tx_pin_write(HIGH); // restore pin to natural state

    To add additional bits, simply set the line in the correct state using tx_pin_write(HIGH) (or LOW) and delay using tunedDelay(_tx_delay);

    On the recv() side, look for this code:

       // Wait approximately 1/2 of a bit width to "center" the sample
        DebugPulse(_DEBUG_PIN2, 1);
        // Read each of the 8 bits
        for (uint8_t i=0x1; i; i < <= 1)
          DebugPulse(_DEBUG_PIN2, 1);
          uint8_t noti = ~i;
          if (rx_pin_read())
            d |= i;
          else // else clause added to ensure function timing is ~balanced
            d &= noti;
        // skip the stop bit
        DebugPulse(_DEBUG_PIN2, 1);
        if (_inverse_logic)
          d = ~d;
        // if buffer full, set the overflow flag and return
        if ((_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF != _receive_buffer_head)
          // save new data in buffer: tail points to where byte goes
          _receive_buffer[_receive_buffer_tail] = d; // save new byte
          _receive_buffer_tail = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF;
    #if _DEBUG // for scope: pulse pin as overflow indictator
          DebugPulse(_DEBUG_PIN1, 1);
          _buffer_overflow = true;

    and add another line like tunedDelay(_rx_delay_stopbit); to skip another stop bit. Make sense?

  27. Mikal

    2 years ago


    I’ve never played with a GSM module. What’s the model number? I suspect that it’s a simply matter of wiring it up correctly, and yes, I would expect that Serial.print(“AT”); would generate some results. Or rather serial.print


    (“AT”); will. The latter sends the LF character after the AT, and I think that’s crucial for a modem-like device.

  28. Vladimir

    2 years ago

  29. Vladimir

    2 years ago

    Example initialization SoftwareSerial8E2 port:

    SoftwareSerial mySerial(2, 3);

    void setup()

    // set the data rate for the SoftwareSerial8E2 port
    mySerial.begin(38400, 1, 2);


    38400 – bound
    1 – parity bit enable (0 – parity bit disable)
    2 – two stop bit (1 – one stop bit)

  30. David (D9W)

    2 years ago

    I am right now just have an I2C backpack hooked up to my Arduino from Adafruit, plus their AM2302 (wired DHT22) temperature-humidity sensor, and sparkfun’s 66 Channel LS20031 GPS 5Hz Receiver. But right now the only software I am running is for the LS20031. I am using the example code that came with the Arduino 1.0 IDE. What I am after is getting the GPS time, and once I correctly the hookup the GPS to the Arduino, it worked with the test_with_gps_device from the 1.0 IDE.

    What’s frustrating is when you had Ver 9 of the TinyGPS and the NewSoftSerial, I tweeked the NewSoftSerial buffer and got it working great with .22 IDE (when most people were having problems with it.) Same things connected to the Arduino, and I was just focusing on getting the TinyGPS code to work on the Arduino minus any other code for the other parts. I followed Sparkfun’s tutorial on the LS2031 { } and used their example to make sure the Arduino could see the data stream. Now with the new Arduino 1.0 IDE, using the softSerial as I pointed out I am getting garbage part of the time, but your TinyGPS is able most of the time to pick out what it needs to show the time in the test_with_gps_device. I have played around with that code to see how the two libraries worked, and most of the time it looks like the buffer is hit and miss, but it still shows the correct time. The static_test always give a bad first line but after that it’s able to parse out the correct info in the data stream.

    I know you have said my baud rate is too fast on the LS20031, but then why was I able to get the Ver 9 to work? All I had to do was increase the buffer size to 128 in NewSoftSerial? And now not even that has an effect with the 1.0 IDE?
    One other question: With the TimeGPS library that’s floating around on the main site, is that any good with the current TinyGPS? I corrected the newSoftSerial to softSerial for the 1.0 IDE, but it seems in never get’s out of setup(). Again all I am after is the time from TinyGPS.

  31. Jorge

    2 years ago

    Hi Mikal, thank you very much for your SoftwareSerial.

    I have one question, I’m using the Arduino 1.0 with low power consumption, I realize when I turnoff my serial devices (GPS&GSM) and set the atmega328 to power down the current consumption is in my case 0.3mA, but when I declare SoftwareSerial XYZ(A,B);
    and I execute the same previous steps, the current consumption goes higher, as 0,7mA. I’ve tested different scenarios and it happens always when I declare 1 or more SoftwareSerial Objects.
    Question: Do you see any reason for that?, Maybe SS is using some extra microcontroller setup that requires more energy??

    Thank you very much!


  32. Mikal

    2 years ago


    Yes, when a SoftwareSerial object is activated with a valid transmit pin, the first thing the library does is bring the TX line high. This is required because a serial pin is high when in the idle state.

  33. Jorge

    2 years ago

    Thank you Mikal, I’ve set the TX and RX pin to Down, just before PowerDown mode and the consumption went back to 0.5mA. You saved me!

  34. Manash

    2 years ago

    Sir, Can I use your NewSoftSerial library in WinAVR? If yes, then what would be the syntaxformat be like?


  35. Jorge

    2 years ago

    Hi Mikal, I’m back ;-.)

    I’m facing some challenges to send SMS using the latest SoftwareSerial on Arduino 1.0.
    It’s acting very strange, some times I need to call the same code twice to send 1 SMS, other times i need to add a huge delay.
    The same code use to work fine with NewSoftSerial on Arduino 0.22/0.23.
    I’ve simple changed the old nss.println(26,BYTE) form for the new nss.write((byte)26), but it’s not working all times.
    Do you believe this is something related to the way the new implementation works? Some waiting or sync issue? Any ideas?

    Thank you, once again!

  36. Mikal

    2 years ago

    @Manash, if you’re asking for permission, the answer is a definite “yes”. If you’re asking how it might be done, I don’t know exactly, but I suspect that it wouldn’t be too hard to port. The code itself doesn’t rely over much on Arduino particularly. Has anyone tried to port NSS to a non-Arduino environment?

  37. Mikal

    2 years ago


    Can you describe what you mean by “it’s not working at all times”? Does that mean simply that the SMS device isn’t responding like it should?

  38. Jorge

    2 years ago


    What I mean is that sometimes the AT commands do not go thru, for instance, I have the same code sending SMS in 5 different devices (SM5100-B) with the old NSS and they work fine, I’ve upgraded to arduino 1.0 and I’m using the SoftwareSerial (NSS official) changed the nss.print for nss.write for byte, but sometimes the command doesn’t go thru, I had to add many AT, delays. Sometimes it sends the first, but no the next sms;
    Another example:
    I have an AT command to turnoff the GSM module, depending which command was sent to the serial before the turn off command, it doesn’t work, I have to type it twice or more.

    Below the old and new code:

    CELL.println(“AT+CMGF=1″); // set SMS mode to text
    CELL.print(“AT+CMGS=”); // now send message…
    CELL.print(34,BYTE); // ASCII equivalent of ”
    CELL.println(34,BYTE); // ASCII equivalent of ”
    delay(500); // give the module some thinking time
    loop to read message from file (in_char); // Read file char by char;{

    // CELL.flush(); //Attempt to make it work
    // CELL.println(“AT”); //Attempt to make it work
    // delay(500); //Attempt to make it work

    CELL.println(“AT+CMGF=1″); // set SMS mode to text
    CELL.print(“AT+CMGS=”); // now send message…
    CELL.write((byte)34); // ASCII equivalent of ”
    CELL.write((byte)34); // ASCII equivalent of ”
    delay(500); // give the module some thinking time
    loop to read message from file (in_char); // Read file char by char;{

    Thank you again.


  39. David W

    2 years ago

    Mikal- First Thanks for all your help that you have freely given.

    I just want to give feed back to your suggestion about looking at what SoftwareSerial is feeding out to TinyGPS. I stripped out SoftwareSerial out of the example that came with TinyGPS and read directly from Pin 0 from the Arduino Uno. The results were telling and your correct TinyGPS works like a charm. For some strange reason SoftwareSerial strips out all RMC messages. What’s weird is out of all the six possible NMEA messages, The only two that get passed are GGA and GLL. From what I am seeing is you get a GLL messages to every GGA messages- (And no I have not change the factory settings on my GPS- as reflective of the raw data that I sent from the LS23001 to the Arduino IDE’s monitor). As you know that’s not right because there is a sequence that every GPS goes through which means you get one of each message every time you pass through the cycle. On top of that; as you already know without a RMC message you can’t get the date. And TinyGPS only uses the two messages (GGA and RMC) to do it’s magic. If I had 500 dice and I through them up in the air and looked at what numbers showed up when they came down. I should at least come up with every number between 1 and 7. Yes, I might come up with more number X then the others, but I should come up with at least one representative of the 1 through 7 faces of the dice. That’s not happening with SoftwareSerial. 500+/- NMEA messages and not one RMC message shown up in 235 times of running TinyGPS with the modified code you suggested. Not even a part of the message. Not a part of GSA, GSV or VTG showing up either. I am only getting two messages and they are the GLL and GGA. Something is “throwing” the dice off.

  40. Mikal

    2 years ago


    Thank you for your detailed feedback. I’m going to postulate that you are experiencing a buffer overflow condition. It’s easy to prove. Just print out the value of the software serial “overflow” member:

    Serial.print("Overflow is ");

    Here’s what I guess is happening. Your GPS unit sends 6 sentences every second (or worse, every 200 milliseconds). These 6 are always bunched together and the first two are the GLL and GGA sentences. As they arrive you begin processing them and start getting slow about removing the incoming data from the 64-byte SoftwareSerial buffer. The buffer overflows and the remaining 4 sentence are either truncated or lost altogether. TinyGPS discards any partial sentence it finds.

    Now your program gets caught up so that by the time the next batch of 6 sentences arrive one second later, it is ready for them. But again, only the first two sentences are actually processed.

    Make sense?

  41. Aakash

    2 years ago

    will you plz guide me were i can get this library download?

  42. Andrea

    2 years ago

    Hi! I need help, i have an error about this library, well in fact the library i have is softwareserial, but there´s an error of the pins or something like that with 12 and 13
    Have somebody had this error and could help me please?

  43. Sebastian

    2 years ago

    is it possible to tweak the SoftwareSerial library in a way such that higher baudrates (such as 460800) are supported? I would appreciate this very much.
    Thank you for this very nice library.

  44. Mikal

    2 years ago


    Unfortunately, no. The AVR processors just aren’t powerful enough to process data at that rate. Even 115K and 57K are not very reliable.

  45. Nimit

    2 years ago

    Hi Mikal,

    Would you please be so kind to help me on this Newsoftserial, I have to pause this Softserial and restart again after I do some interupt because the Newsoftserial keep disable interupt.

    Can I used End(); and Begin(); or anything else better for thst?




    2 years ago


    I am using ATmega644 or ATmega1284 as Sanguino. An improvement to old Arduino versions (up to 22) have been done by two persons Zac Hoeken for 644 and R K Sharma for 1284.

    Can I add your soft serial library to those Arduino 21 or 22 version or is it good for ATmega328?


    -P W Dandekar

  47. pescadito

    2 years ago

    i tried to run SoftwareSerialExample over a AtTiny85 bootburned with arduino, but i only get gabarish characters when read o write.
    I use pb2 for rx and pb3 for tx. i tried 1, 8 and 20 mhz, at 9600 to 2400 bps without succeful.
    i see a lot of discussion over different forums but no easy end solution appears. Someones talk about hand tunning the clock processor.

    Do you have any tip to allow AtTiny85 support SoftwareSerial?
    Best regards Pescadito.

  48. Mikal

    2 years ago


    It should be ok to simply end() and then begin() again. That’s what I designed end() for. Let us know if it works…!

  49. Mikal

    2 years ago


    I think NSS should work fine with Sanguino–as long as you have the correct timings. It’s not just limited to the ATmega328.

  50. Mikal

    2 years ago

    Does the ATTiny85 even support pin change interrupts?

    What is the processor clock speed on that device?

89 Trackbacks For This Post
  1. NewSoftSerial 5 « Arduino

    [...] NewSoftSerial version 5 is available. A lot of people have been using this library — thanks! — but I really need to recognize the exceptional work of two contributors. [...]

  2. NewSoftSerial 6 « Arduiniana

    [...] I posted the new library. [...]

  3. เริ่มต้นสร้าง GPS จอสีกับอาดูอี้โน่ | Ayarafun Factory

    [...] ในรอบนี้ผมได้ใช้ newSoftwareSerial3 จะได้ลองด้วยว่า มีปัญหาไหม

  4. Unlogic » USB Storage and Arduino

    [...] of the first things to do is download NewSoftSerial

  5. The Hired Gun » GPS project: the Bluetooth saga

    [...] to the task at hand, which happened to be adding 3 lines of code: declaration of an instance of NewSoftSerial, calling the instance constructor with a baud rate, and a single call to pass the char from the [...]

  6. layer8 » Controlling A Roomba with an Arduino

    [...] and the XBee module has a serial interface.  So how does this really solve my problem?  Enter NewSoftSerial, an updated version of the Arduino software serial library, which basically lets you drive a serial [...]

  7. This and That » Blog Archive » Arduiniana - What else would it be?

    [...] is probably the coolest gift idea I’ve seen.  Mikal, you rock.  And also, thank you for NewSoftSerial.  [...]

  8. Interfacing the Arduino with the DS1616

    [...] way.  Let’s move onto the software.  Communication with the DS1616 is established using the NewSoftSerial library.  Getting data is essentially a case of lots of bit banging.  The DS1616 library [...]

  9. Serial Multiplexing « Interactive Environments Minor 2009-2010

    [...] So we started looking for a solution to overcome this tiny inconvenience. First we looked into a software serial but this didn’t work out, it was a bit too much for the arduino’s little processor to [...]

  10. Atmega/Arduino (Soft-) Serial Ports | Jochen Toppe's Blog

    [...] software serial port. I briefly thought about writing one, but then I found this great libary, the New SoftSerial. It is as simple to use as the original library, but unfortunately once I connect the RF receiver, [...]

  11. The Frustromantic Box, Part 4: Software « New Bright Idea

    [...] developers for the great libraries, and to Mikal Hart in particular for his work on the TinyGPS and NewSoftSerial [...]

  12. side2 » Bimeji Client for Arduino

    [...] このソースでは、PS2ライブラリとNewSoftSerialライブラリを利用しています。 コンパイルするには、これらのライブラリを有効にしておく必要があります。 [...]

  13. Live Twitter Table using New Bluetooth Shield | Club45

    [...] as a well. The shield can be wired to any of the pins on the Arduino. Right now we’re using NewSoftSerial on pins 4 and 5. It can be attached to the hardware RX and TX pins, but interferes with [...]

  14. tokyo->kobe->osaka << Motoi Ishibashi

    [...] 急遽、Arduinoでシリアル通信をふたつやる必要が発生してホテルで開発。といっても手元にハードがないので、ほとんど勘でプログラムしているようなもの。 次の日現場で試すも、予想通り動かない。そりゃそうだ。 NewSoftwareSerialなんていう便利なものがあるのを後で知った。 [...]

  15. VDIP1 USB Host Controller « Arduino Fun

    [...] chose the NewSoftSerial library to give access to the VDIP1.  The first attempt was to use the AFSoftLibrary and it just [...]

  16. Project Lab

    [...] software running on the Arduino ATMEGA328 chip utilizes the wonderfully robust NewSoftSerial library for communicating with the EM-406a GPS module and the very convenient TinyGPS library for [...]

  17. Box Round 2 « Stromberg Labs

    [...] is available here. I borrowed from a couple of people’s Arduino libraries to get this done, notably NewSoftSerial from Arduiniana and the GPS Parsing code from the Arduino website for parsing the NMEA strings. [...]

  18. Grok Think » Blog Archive » I got Arduino sending temp to the computer using xbee wireless.

    [...] I had to use this library to communicate with the xbee from the arduino: [...]

  19. GPS – Welcher Chip? | Ranzow im Umbau

    [...] wird über die Serielle Schnittstelle angesteuert. Die werde ich wahrscheinlich über die NewSoftSerial Library [...]

  20. GPS – Welcher Chip? | Ranzow im Umbau

    [...] GPS Modul wird über die Serielle Schnittstelle angesteuert. Die werde ich wahrscheinlich über die NewSoftSerial Library [...]

  21. Cititor RFID 125KHz « Tehnorama

    [...] metoda de a afla codul cartelei este de a utiliza biblioteca NewSoftSerial, disponibila gratuit aici. Fisierul zip se dezarhiveaza si se copiaza in folderul libraries al distributiei [...]

  22. Lightweight software UART -> custom serial « Robotics / Electronics / Physical Computing

    [...] updated the NewSoftSerial library from Arduiniana (thanks Mikal !) so that it takes 2 extra [...]

  23. Control Camera with Arduino | SenSorApp

    [...] [...]

  24. GPS testing with LCD Character Display

    [...] the TinyGPS library from Arduiniana downloaded and installed for it to work. They suggest using NewSoftSerial, but I couldn’t get that to work, so I scrapped that portion. Here’s my [...]

  25. #Rallylog Fusebits

    [...] it as a fail and moved on, however last night when I set about writing the RFID read function using NewSoftSerial on the RFID I was getting nothing reported back back on the AVR, not a thing coming back from the [...]

  26. 433 MHz receiver and NewSoftSerial at

    [...] [...]

  27. Moving Forward with Arduino – Chapter 17 – GPS « t r o n i x s t u f f

    [...] devices. At this point you will need to install two libraries into the Arduino software – NewSoftSerial and TinyGPS. Extract the folders into the libraries folder within your arduino-001x [...]

  28. Moving Forward with Arduino – Chapter 17 – GPS « Hey it’s my blog…

    [...] this point you will need to install two libraries into the Arduino software – NewSoftSerial and TinyGPS. Extract the folders into the librariesfolder within [...]

  29. Sonar | Starter Kit

    [...] there is one more library – “NewSoftSerial”, which is free of these defects and, in addidion, handles inverted serial [...]

  30. Advanced RFID with Arduino and Python! | App Delegate Inc

    [...] NewSoftSerial [...]

  31. RFID Door Opener – Update 3 – LCD Woes - Sommineer

    [...] one on some other pins.  Per the suggestion of some people on the Arduino forums, I decided to use NewSoftSerial to do the communication.  Being interrupt driven, it was much more efficient than the older [...]

  32. keyHelper final project

    [...] the code you will need a very useful NewSoftSerial library, that, among other things, allows you to assign TX and RX on other pins then 0 and 1 and that way [...]

  33. Step-by-Step Guide on using the Bluetooth Bee, Bees Shield & Arduino to communicate via bluetooth | Michael Chuah

    [...] up would be to try and use the awesome NewSoftSerial library by Mikal Hart to communicate with the Bluetooth Bee by emulating the UART [...]

  34. Tutorial: Arduino and GSM Cellular – Part One « t r o n i x s t u f f

    [...] a software perspective we will need the NewSoftSerial Arduino library, so please download and install that before moving [...]

  35. Interfacing Arduino to GSM shield | Embedded projects from around the web

    [...] goes step by step how to connect Cellular shield to Arduino mega and communicate to it by using newsoftserial Arduino library. Whole process steps are monitored in terminal window, so it is easy to follow [...]

  36. Fully functional Arduino GPS logger « Liudr's Blog

    [...] NewSoftSerial library [...]

  37. LCD117 Controller Library - Jack Kern

    [...] also need the NewSoftSerial library installed in your Arduino sketchbook’s library [...]

  38. Touch game for the offspring | NinjaTool inc.

    [...] GLCD that I bought (without knowing ANYTHING about it beforehand I might add). The code uses the NewSoftSerial library which apparently does wonders, but as of yet has not been validated as the code assumes a 9V [...]

  39. Arduino GSM and GPRS shield | Open Electronics

    [...] the pin 4 and 5 there aren’t problems to upload the sketch but the maximum baudrate for NewSoftSerial (the serial library) is 57600. We performed a GSM library to controll easly the module. The GSM [...]

  40. Moving Forward with Arduino – Chapter 19 – GPS part II « t r o n i x s t u f f

    [...] forget the 10k ohm pull-down resistor). You will need to install the SdFAT library, NewSoftSerial library, TinyGPS library and the SdFat library if not already [...]

  41. Blog What I Made » YAHMS: Base Station

    [...] of just the standard Serial interface, see the links below for that too. You’ll also need NewSoftSerial of course and the Flash library which I’ve used to decrease memory usage. Follow the [...]

  42. Infovore » Nikon D-Series Intervalometer

    [...] a single wire, which again, keeps the number of wires from the Arduino down. I’m using the NewSoftSerial library to talk to it, which makes life [...]

  43. Arduino Experiments

    [...] you can use multiple serial “ports”, that are actually digital I/O lines, by using the NewSoftSerial library. This works exactly like the Serial library, but you can read from multiple pins, as long as you [...]

  44. EasyTransfer Arduino Library « The Mind of Bill Porter

    [...] it’s easier to pick which Serial port to use; Serial, Serial1, etc. AND support for the NewSoftSerial library for creating software serial ports on any pin. Inside the download zip file are two versions of the [...]

  45. Research: RFID, XBee and Arduino « Beyond the keyboard

    [...] neat thing is the NewSoftSerial library for Adruino, allowing you to turn any set of pins into additional RX/TX pins with free to set baud [...]

  46. jomuoru weblog » Blog Archive » Esto es Camus Party

    [...] de instalar la librería NewSoftSerial pude compilar e instalar el Arduino Firmware en mi placa. A continuación necesitaba descargarme [...]

  47. Update: Design review « Appiphania

    [...] a bit of this code at the end of this journal entry. The “NewSoftSerial” library was extremely easy to get working (code example [...]

  48. Anonymous

    [...] Modul per Software-UART? Bitte einen Link oder Hinweis wo ich nachlesen kann. danke Schaust du hier __________________ FHZ1300 | 2x JeeLink | AVR-NETIO | FS20 | 1-Wire | 2x XBEE Pro | 4x XBEE 2.5 [...]

  49. Using A Second (Software) Serial USB To Debug Your Arduino | Utopia Mechanicus

    [...] actually really easy, using some code called NewSoftSerial (available from this site, at the ‘Download’ subheading). This software is much like your Serial device you use on the Arduino, but it’s in software [...]

  50. Kemper LED / Arduino Interface » Powerhouse Electronics

    [...] provided by the software library “NewSoftSerial”. The library can be downloaded from:: Since the communications port is created using software any of the Arduino port pins can be used. [...]

  51. Android talks to Arduino | ★ Elmindo Blog ★

    [...] NewSoftSerial library from Mikal Hart: [...]

  52. Utilizando a Bees Shield em uma Arduino Mega « A arte do hardware

    [...] via jumper na própria shield. Para comunicação com essa Bee, é necessário o uso da biblioteca NewSoftwareSerial, permitindo fazer que dois pinos digitais se tornem mais uma [...]

  53. Arduino camera and geotagger |

    [...] NewSoftSerial lib was used for communicating over serial using an IO [...]

  54. Bluetooth + Arduino + Android – 1 : Transmettre des données d’un capteur branché sur une carte Arduino vers un Smartphone Android via bluetooth

    [...] 1– télécharger la bib­lio­thèque New­Soft­Se­r­ial pour Arduino Des expli­ca­tions et exem­ples plus détail­lés con­cer­nant cette bib­lio­thèque sur cette page ( [...]

  55. Arduino + fon + OpenWRT + ser2net + NewSoftSerial « sea side she side

    [...] そのためソフトウェアシリアルを再現させたライブラリがありますのでそれを利用します。とはいっても標準ライブラリのSoftwareSerialは利用しません。高機能で速度もでるようになったNewSoftSerialを利用します。 [...]

  56. David C. Dean Arduino GPS – On the Cheap

    [...] NewSoftSerial Library - [...]

  57. Telemetry Using Xbee Modules | Anacortes RC Sailors

    [...] arduino remotely can be found here. For communication over XBee the Arduino appears to need the NewSoftSerial library. LD_AddCustomAttr("AdOpt", "1"); LD_AddCustomAttr("Origin", "other"); [...]

  58. NewSoftSerial, Attachinterupt() and Pins 2,3 | Anacortes RC Sailors

    [...] for attacheinterupt() are 2 and 3. The GPS shield uses digital 2 and 3 for GPS communication using NewSoftSerial. So I tried moving the GPS to other pins, 8 and 9 worked. Now pins 2 and 3 are free for my [...]

  59. Telemetry Using Xbee Modules | Anacortes RC Sailors

    [...] arduino remotely can be found here. For communication over XBee the Arduino appears to need the NewSoftSerial library. [...]

  60. [Arduino] Lecteur RFID à écran lcd, avec stockage du tag “valide” en EEPROM externe I2C « Skyduino – Le DIY à la française

    [...] Dans ce projet vous pouvez remarquer que je suis obligé d’utiliser deux port série, un à 9600 bauds pour l’écran lcd, et un autre à 2400 bauds pour le lectuer RFID. Normalement il me faudrait une mega (qui possède 3 port série) pour faire ce projet en hardware, mais il existe aussi des librairies Serial software ! C’est pourquoi je vais utiliser la librairie NewSoftSerial disponible ici : [...]

  61. An Idiot and an Arduino: Pretty WiFly for a White Guy « ~jmoskie

    [...] went through each error, and tried to resolve it myself. Some were easy. The "NewSoftSerial" libraries were incorporated into the core libraries, and they replaced the default SoftwareSerial [...]

  62. Arduino vs Arduino Mega – Which To Use? | Utopia Mechanicus

    [...] speed if you need a second or third (or fourth) port. On the Uno, you can do similarly using the NewSoftSerial library; however, software is slower, and if your program is pushing the limits, you may find a hardware [...]

  63. I can solder! 7-Segment Serial Display & Nunchucky operational « I Am Chris

    [...] already.  I found this wall of text which I managed to digest down into this gist (and updated it thanks to these notes) which you can see running in the above [...]

  64. S2 » Android + Bluetooth + Arduino

    [...] そして、シリアル通信のテストに利用したArduinoのソースです。 NewSoftSerial(Arduinoライブラリ)を利用しています。 [...]

  65. Getting started with DroneCell and Arduino.

    [...] DroneCell and the GPS simultaneously. I stumbled upon this interesting behavior in NewSoftSerial. NewSoftSerial*|*Arduiniana. I seem to at least have something to go on… Using Multiple Instances There has been [...]

  66. Emular pines Serial de Arduino con la librería NewSoftSerial » Blog Archive » el blog de giltesa

    [...] eso es lo que es capaz de hacer la librería NewSoftSerial (más documentación aquí). Usándola podremos emplear el resto de pines como puertos serial, ya [...]

  67. Time - He's waiting in the wings - Cuyahoga

    [...] in the download is TimeGPS.pde, but it’s a touch outdated now that Mikal Hart’s NewSoftSerial library has been rolled up into the core (since 1.0) and renamed SoftwareSerial. The problem I had [...]

  68. Arduino的通讯扩展板介绍 | 爱板网

    [...] GPS模块与Arduino的通讯程序 [...]

  69. Giving Arduino a second UART over I2C by stacking another Arduino on top « CyclicRedundancy

    [...] tried using the SoftSerial (or the NewSoftSerial) library but ran into data corruptions even at the low speeds, so I decided to look for ways to get another [...]

  70. RFID Reader #1 « Tesla UIs

    [...] the example code. There some issues on the Arduino library SoftwareSerial, which changed to the NewSoftSerial once in a while. Share this:TwitterFacebookLike this:LikeBe the first to like this. Categories [...]

  71. Resources for the VCNL4000 IR Proximity Sensor | Sciencearium

    [...] - Share this: This entry was posted in AT Physics Class and tagged arduino, IR, proximity [...]

  72. Serial LCD do-it-yourself(DIY) kit | BUILD CIRCUIT

    [...] NewSoftSerial Library - Required for the example sketches. Sets up a second (third, fourth,…) serial port on the Arduino. [...]

  73. How to assemble serial LCD kit | BUILD CIRCUIT

    [...] NewSoftSerial Library - Required for the example sketches. Sets up a second (third, fourth,…) serial port on the Arduino. [...]

  74. Android talks to Arduino board - Arduino for ProjectsArduino for Projects

    [...] from this project (bluetooth_chat_LCD.pde attached below) – NewSoftSerial library from Mikal Hart: – Eclipse – Android Development Kit (explicitly follow all of Google’s installation [...]

  75. Burn Arduino Bootloader on an ATtiny45 for SoftwareSerial | No bread? Make it!

    [...] いいね:いいね 読み込み中… カテゴリー Arduino, [...]

  76. Burn Arduino Bootloader on an ATtiny for SoftwareSerial | No bread? Make it!

    [...] いいね:いいね 読み込み中… カテゴリー Arduino, [...]

  77. Please wait your turn! Stratoballoon GPS Sensor Sketch « Mark Gilbert's Blog

    [...] to the GPS receiver, I’d be writing to the data logger serially.  I found information here about running multiple devices serially – the short answer is that you have to access the serial [...]

  78. Going to Arduino from C#, Java, … string trouble | Hydroinformatix the Gaul

    [...] kB). I used this method and solved my intermitting (and making me crazy…) problems 2) Using PString library, added by NewSoftSerial and put in official version of Arduino. It is very handy: it hands you a [...]

  79. The Frustromantic Box, Part 4: Software | New Bright Idea

    [...] developers for the great libraries, and to Mikal Hart in particular for his work on the TinyGPS and NewSoftSerial [...]

  80. Le Dan-TECH » 2ème Partie : Reconnaissance vocale avec Arduino

    [...] , les ports 12 & 13 de l’arduino sont utilisés (liaison arduino-module via la classe newSoftSerial) et ne permettent pas l’emploi du shield Ethernet sur une platine « arduino [...]

  81. on the trail of the elusive Power Cost Monitor signal | We Saw a Chicken …

    [...] I rewrote the logger to use the Arduino’s internal UART, since — lovely though NewSoftSerial may be — it causes millis() to report wildly inaccurate times at low bit rates. I recorded a [...]

  82. 86duino

    [...] require that protocol. The version of SoftwareSerial included in 1.0 and later is based on the NewSoftSerial library by Mikal [...]

  83. 86duino

    [...] This requires the TinyGPS and NewSoftSerial libraries from Mikal Hart: and [...]

  84. Kerry D. Wong » Blog Archive » RF Data Link Using Si4021 And Si4311

    [...] BT1 pin settings (which are done in hardware), the receiver is totally configuration free. I used NewSoftSerial library in the code below. The main loop simply print out the incoming bit stream. You may also use [...]

  85. how to set up arduino + pololu mini maestro (for an 18 servo hexapod) | orange narwhals

    [...] newsoftserial should be downloaded from the internet and the folder inside the zip put in (path to where you [...]

  86. Starter Kit Sonar » Starter Kit

    [...] szczęście jest jeszcze jedna biblioteka „NewSoftSerial”, która jest pozbawiona tych wad i na dodatek obsługuje zanegowany sygnał [...]

  87. Twitter Poem Box -Use Arduino for Projects

    [...] Download the TrueRandom, NewSoftSerial, and Twitter [...]

  88. Подключение GPS L30 модуля используя GPS Шилд от SparkFun » Arduino Market

    [...] NewSoftSerial [...]

  89. Tema 5 – Proyectos Arduino | Aprendiendo Arduino

    [...] NewSoftwareSerial: [...]

Leave a Reply