NewSoftSerial

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.

Improvements

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
  gps.listen();
  read_gps_data();  // use gps as active device
  // collect temperature data from thermometer
  therm.listen();
  read_thermometer_data(); // now use therm
  // LCD becomes the active device here
  LCD.listen();
  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()
{
  device1.listen();
  if (device1.available() > 0)
  {
    int c = device1.read();
    ...
  }
  device2.listen();
  if (device2.available() > 0)
  {
    int c = device2.read();
    ...
  }
}

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.

Download

The latest version of NewSoftSerial is available here: NewSoftSerial12.zip.  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

Acknowledgements

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
645 Responses → “NewSoftSerial”

  1. Faheem

    5 years ago

    Hi,
    i am using atmega 328 to communicate with my mongose imu which also have atmega 328 controller. i am reading data from sensor using Software Serial and then printing these data using hardware serial pin on UNO board. It print or transmit data correctly for some time means for just 5 or 10 seconds after that it transmit constant form of data………i need your help


  2. Marc

    5 years ago

    Hey.
    I’m working with an Arduino Uno on which i’m trying to hook up two RFID readers (Parallax readers running at 2400 bps). (I’m running Arduino 1.0)
    I can get i to work fine with 1 RFID reader, but when hooking the other one up, it won’t read anything. I pasted my code on pastie.org here:
    http://pastie.org/3890243
    (Sorry for the danish comments a few places)
    It’s meant to act like this:
    Reader1 reads the tag and lights a LED and if reader2 reads the tag and lights another LED and turns the other one off.
    CHeers for any help. :)
    /Marc


  3. Mikal

    5 years ago

    @Faheem,

    It’s hard to guess. Can we see your code?


  4. Mikal

    5 years ago

    @Marc,

    Read carefully the section on “Using Multiple Instances”. Your code is almost a textbook example for what not to do with multiple ports. For your application I think you’d roughly want to do something like:

    void loop()
    {
      port1.listen();
      // wait for several seconds or until you get a valid code on port 1
      ...
      port2.listen();
      // wait for several seconds or until you get a valid code on port 2
      //
    }
    

  5. Marc

    5 years ago

    @ Mikal
    Well, i feel a tad stupid now. >.<
    You said, "wait some time", so i added a delay(250); after my listen(); calls and that fixed it. :)
    Thank you for the help mate. ;)


  6. Larry Walker

    5 years ago

    Mikal:

    I am trying to use the NewSoftSerial library (freshly downloaded today) under Arduino v21 with the SD library to talk to a LadyAda Data Logger shield (http://www.ladyada.net/make/logshield/).

    I’ve incorporated the LadaAda sample code into my project and can log data to the SD card just fine. My design needs to use an RS232 connection on D0/D1 as a connection to a maintenance/control panel (talks to a PC terminal emulator in practice or to the Arduino serial monitor in testing) but I also need to drive a Sparkfun Serial 4×20 LCD. So I’m trying to run NewSoftSerial on D2/D3 to drive the LCD. That also works fine in a small test case (i.e. it co-exists with the standard Serial reads/writes to the D0/D1 console).

    But when I combine it all into my project, the first call to SD.exists() blows up and throws me back into executing the setup() routine again, as if a reset had occurred.

    I can reproducibly turn this failure mode on/off merely by uncommenting/commenting the line:

    #include

    (This is with all calls to NSS functions commented out, to suppress compiler errors when the #include is commented out…)

    Can you suggest what the conflict between the NSS and SD libraries might be, and/or recommend a work-around?

    Oddly, the SD.begin() call in my setup() routine does NOT fail, only the subsequent SD.exists() call. Not sure if that’s a helpful clue or not…

    Thanks in advance for any suggestions you can offer,

    Larry


  7. Larry Walker

    5 years ago

    oops:

    the #include that toggles my problem on/off should have had “NewSoftSerial.h” (minus the quotes) in a less-than/greater-than pair, but I think they got eaten when I submitted my question…

    retest of include line, just for reference:

    #include

    Larry


  8. Larry Walker

    5 years ago

    : my apparent problem with Sd vs NSS is resolved: operator error. This is the my first Arduino project that has hit the limit on RAM. And since the Arduino IDE does not give any feedback on RAM usage, the timing and symptoms of RAM overflow are messy and bizarre. Took me quite a while to hip to what was going wrong.

    As far as I can tell, just #including NewSoftSerial.h must ad just enough RAM usage to trigger overflow.

    I finally thought to try to reproduce what I was seeing (commenting/uncommenting the #include to toggle the failure mode on/off) by adding the #include to the CardInfo sketch that goes with the SD shield: no effect…

    Time to look at a Mega, I guess!

    Sorry for the false alarm

    Larry


  9. Baz

    5 years ago

    I tried to figure out yesterday some strange behaviour in my simple code that was reading bytes at 600 Bauds.
    After a while, i discovered that there is now row for 600 bauds in delay tables.
    It was hard to figure out because no error code is thrown when bad baudrate is selected. What is strange however is that i was really able to read bytes at 600 bauds by switching off the “available” test that was always returning 0.

    I tried to mimic the other rows to add a 600 baud line, and it seems to work fine now.
    However, there is no comment in the code about how the different delays have been chosen (on the same line, there are some small difference (+- 3).

    I think it should be cool to have 600 baud support in the future, since it is not a seldom baudrate, and to have also a feedback on “begin” when the baudrate is not supported.

    Baz


  10. Mikal

    5 years ago

    Thanks for the follow up, Larry. Yeah, those low RAM scenarios are devilishly hard to debug!


  11. Scott

    5 years ago

    SoftwareSerial is not compiling for the Leonardo. I am told it is because there are some details still missing for implementing the interrupts needed. I use software serial quite a bit and would really appreciate it if it would run on the Leonardo!

    Any ideas?


  12. Bernd

    5 years ago

    Hi!
    Is it possible to use it with an AtMega8 and Arduino?ä

    Yours

    Alexander


  13. Mikal

    5 years ago

    @Bernd,

    I don’t think the AtMega8 supports pin change interrupts, so no, I don’t think NewSoftSerial will work.


  14. Tiago Custódio

    5 years ago

    Hi, i’m looking forward to use SoftwareSerial in an attiny85 running at 16.5Mhz, but i can’t figure how to calculate the delay table that should be used. Any heads up?


  15. toni

    5 years ago

    i want ask something mr and mrs.

    i got some troubles yesterday, when i want send message using arduino with wavecom 1206b for gsm communicating.
    when i use rx and tx normally by using arduino, its rx and tx original, my code can work i can send message and recieve and read message. but when i implement it with the other serial that using pin 2 and 3, or rx and tx from newsoftserial. it can’t work suddenly. when i change to use rx and tx original in arduino again it can work again.
    can you help me ?
    is there different thing in serial that provide by arduino and newsoftserial ?


  16. Mikal

    5 years ago

    @Tiago,

    If it’s really 16.5MHz, for a start I would take each value in the 16 MHz table and multiply by (16.5 / 16) or about 1.03125. In other words, you’d be increasing the number of delay cycles by 3% to compensate for the fact that the processor is running about 3% faster.

    This won’t be perfect, but it will probably be close enough at the slower baud rates.

    Mikal


  17. Mikal

    5 years ago

    @toni,

    Software serial uses a completely different technology than HardwareSerial, but the end results should be the same. Is it possible that you have the RX and TX pins reversed?


  18. Jessi

    5 years ago

    @Toni,

    I’m having the same problem on Arduinop Mega. Serial works great, but 1, 2, and 3 won’t work at all. I’ve checked the rx/tx connections.
    I simplified the code to the basic “Hello World” and nothing happens. It runs fin when I use the original pins though.

    void setup()
    {
    Serial1.begin(9600);
    Serial1.println(“Hello World!”);
    }

    void loop()
    {
    }

    Thoughts?


  19. Thomas

    5 years ago

    This is good information but where do I download NewSoftSerial?


  20. UnaClocer

    5 years ago

    I need to run at 7815bps (could get away with a little higher/lower on this one), and 12500bps. Will the software serial library be capable of that?


  21. Mikal

    5 years ago

    @Thomas,

    It’s down near the bottom of the page.


  22. Mikal

    5 years ago

    @UnaClocer,

    I’m afraid the library doesn’t support those bit rates, though it would mean only adding a line to the baud table to do it. You’d have to calculate that, though.


  23. Bodhi

    5 years ago

    Hi all,
    i need to work with a frequency of aprox. 960baud and a F_CPU=16Mhz. In the library this freq. is not used and i’ve not been able to find on the web what is rxcenter //rxintra//rxstop//tx need for 960baud. Could you please help me to add these parameters and then modify the lib.
    Thanks in advance,


  24. sleepy

    5 years ago

    hi ,

    I’m testing the hello world exaple on may adruino uno. but the code prints out only goodnight moon. I also don’t see tx or rx led flashing. can you help getting this to work?

    #include

    SoftwareSerial mySerial(2, 3);

    void setup()
    {
    Serial.begin(57600);
    Serial.println(“Goodnight moon!”);

    // set the data rate for the SoftwareSerial port
    mySerial.begin(4800);
    mySerial.println(“Hello, world?”);
    }

    void loop() // run over and over
    {
    if (mySerial.available())
    Serial.print((char)mySerial.read());
    if (Serial.available())
    mySerial.print((char)Serial.read());
    }


  25. Andrew Symington

    5 years ago

    Hi Mikal

    I notice that both the recv and write functions are blocking, because of the delay function. Is there a specific reason that you didn’t use CTC timers and a state-based approach to sending and receiving? For example, if you set the clock prescaler to 8 on an 8MHz AVR, you’d effectively have a 1us internal tick. You can then set the HW compartor on the clock to fire an interrupt after a given number of microseconds. A state-based architecture could maintain the current start / data / stop bit of the message that is being received or transmitted. I’ve implemented this approach, and I seem to get some characters at 9660 baud, while the others are garbled. I’m not sure if this has to do with an inherent design flaw (clock jitter) or bad delay values. Any input would be appreciated.

    Andrew


  26. Bob

    5 years ago

    Hi, firstly, what a great implementation of a softserial this is, but I have a little problem.. I need to be able to switch OFF the softserial interrupt when I am not using it (thats like most of the time)

    I put the “SoftwareSerial mySerial(x,y)” before my init code just to set up the pins I want to use, then I want to inhibit it until I need it

    I really cant run this alongside my DMX code as the two seem to dislike each other very much, and it seems to do some very strange things with my millis() and MsTimer2 code.. if I remove the softserial alltogether it all works just fine, but I really would like to use the softserial too

    Please help, thanks


  27. Mikal

    5 years ago

    @Bodhi,

    I would simple add an extra line to the delays table that supports 960 baud. Just copy the line for 9600 baud and multiply all the delay values by 10. It won’t be exact, but I bet it will work.


  28. Mikal

    5 years ago

    @sleepy,

    You’ll only see “Hello, world?” if you have connected a serial display device to pins 2 and 3. And you won’t see the TX/RX leds flashing, because they only “listen” to the real serial port on pins 0/1.


  29. Mikal

    5 years ago

    @Andrew Symington,

    I replied via email.


  30. Mikal

    5 years ago

    @Bob,

    The SoftwareSerial object doesn’t allocate the interrupt until you call .begin(…). You can wait until you need the interrupt and only then call begin. Also, you can call end() to quit using the interrupt at any time.


  31. Åge Ågesen

    5 years ago

    I’m having serious issues with SoftwareSerial included in the MacOS version of Arduino 1.0.1. I’ve explained the problem her: http://electronics.stackexchange.com/questions/40408/making-an-echo-sketch-using-softwareserial-and-bluetooth. I would appreciate any help regarding this problem.


  32. Harald

    5 years ago

    Hi Mikal,
    I don’t know if I use your library in the wrong way but when I uncomment the line Serial.begin(9600) I will not get any outputs from mySerial (listening on RX and TX for incoming data from a XBee) any more.
    Isn’t there a way to mix both serials: SoftwareSerial and the ‘normal’ Serial ?
    I want output on the monitor which doe not come from mySerial.
    Thanks for your help.
    Regards
    Harald

    #include

    SoftwareSerial mySerial(2,3);

    void setup()
    {
    //Serial.begin(9600); //if I uncomment this line I will not get
    // any output from mySerial
    mySerial.begin(9600);
    }

    void loop()
    {
    if(mySerial.available())
    {
    char c = mySerial.read();
    mySerial.println(c);
    }
    Serial.println(“Hallo”);

    delay(2000);
    }


  33. Mikal

    5 years ago

    @Harald,

    What is mySerial connected to? That delay(2000) line is ominous. It will almost certainly cause data coming from mySerial to be missed.


  34. Simon

    5 years ago

    Hi Mikal

    I have been chasing down a problem of changing the buffer size see :-

    http://arduino.cc/forum/index.php/topic,128544.0.html

    You may like to consider adding the change or commenting on the buffer size in the header.

    … Simon


  35. pabloxid

    5 years ago

    Hi.

    In my experience, the official softwareSerial Arduino library performs very well, but has a couple of drawbacks, both related to the delay table that it’s based on:

    1) it does not support arbitrary baudrates, such as 3600, 5500, etc.

    2) it’s based on a delay table so, the lower the baudrate, the higher the wasted CPU time, to the point that, for example at 2400 or 1200 baud, if you receive a constant stream of data, the processor becomes unusable.

    To overcome this pair of constraints, I made a small modification that worked very well in my ATtiny85, in wich I use a timer to generate timing, instead of a delay table.

    Unfortunately, my code is not neat enough to be ported to any micro, but I hope you can appreciate the idea and implement it in future releases of this library.

    Here is the link: http://www.pablogindel.com/images/SoftSerial.rar

    Regards,
    P.G.


  36. Bernard

    5 years ago

    I Mikal,
    I have carefully read Marc’s post and your answer so my question is : what object.available() is used for ?
    Can you explain me the difference between your example doing nothing and the Arduino example doing something ?
    Arduino :
    void loop()
    {
    // There is no objectname.listen()
    if (mySerial.available())
    Serial.write(mySerial.read());

    Yours :
    void loop()
    {
    device1.listen();
    if (device1.available() > 0)
    {

    Looking forward to reading you.
    Best regards.
    Bernard.


  37. Ray

    5 years ago

    Does this library support the same extensions made to the HW serial support where the begin method supports a second argument to set the mode (such as SERIAL_8N2 to set 8-bit, no parity, 2-stop bits)?


  38. Ray

    5 years ago

    I’m interfacing with a device that uses 1 start-bit, 8-bit data, no parity and 2 stop-bits. Does the SoftwareSerial library support configuration for 2 stop-bits, as the hardware Serial now does via the optional second initialization parameter that is used to set the mode (such as SERIAL_8N2)?


  39. Attilio

    5 years ago

    I’m using SoftwareSerial with 8mHz atmega328 and I experiencing problems in communicating.

    I summarized with the code attached below. If I use hw Serial the sketch work as expected.

    If I use SoftwareSerial only the first few bytes (2 or 3 bytes) are replied correctly and the remaining are garbled.

    Any idea of the problem?

    Thanks for yours help
    Attilio

    #include
    #include “SoftwareSerial.h”

    #define SWRXPIN 5
    #define SWTXPIN 6

    SoftwareSerial debug(SWRXPIN,SWTXPIN);

    //#define debug Serial

    void setup() {

    debug.begin(9600);
    debug.println(“starting modem”);
    }

    void loop() {
    char r;
    if (debug.available() > 0) {
    r = debug.read();
    debug.print(r);
    }

    }


  40. Mikal

    5 years ago

    Thanks Simon.


  41. Mikal

    5 years ago

    Thanks pabloxid. I love timer-based delays, but the problem is that they don’t work very well at higher baud rates in “busy” systems. If you rely on timers, you also allow for the possibility that other timers and devices might cause the timing to be delayed enough to inject corruption into the system. But I agree that it’s a better scheme at low baud rates. Thanks for


  42. Mikal

    5 years ago

    Bernard,

    I believe those should normally be equivalent. available() is a method which returns the number of characters available to be read. In the top example, the code is checking to see if this value is non-zero. In the bottom, it’s checking to see if it’s greater than zero. If you have only one soft serial device in the system, it doesn’t matter if you call .listen() or not.


  43. Mikal

    5 years ago

    @Ray, no, I’m afraid not. I would like those, but no, it doesn’t currently.


  44. Mikal

    5 years ago

    @Attilio,

    Hmm.. I can’t see why that wouldn’t work. Is there any hardware collision?


  45. Attilio

    5 years ago

    @Mikal

    no hardware collisions: I’ve simply an atmega328p on a breadboard, 8MHz internal oscillator, an usb to serial converter.
    The breadboard is powered with 3V.

    My fuses:

    atmega328bb.bootloader.low_fuses=0xE2
    atmega328bb.bootloader.high_fuses=0xDA
    atmega328bb.bootloader.extended_fuses=0×07

    avrdude -c [programmer] -p m328p -U lfuse:w:0xe2:m -U hfuse:w:0xda:m -U efuse:w:0×07:m

    greetings
    Attilio


  46. pabloxid

    5 years ago

    @Mikal,

    I understand your point. Perhaps the best solution would be to use a timer at low or arbitrary baudrates, while keeping a delay-table for high baudrates, integrating both implementations in a single library?


  47. Sajid

    5 years ago

    Hi,
    thanks for such a great library , i used it to communicate several Arduino but the problem i am facing is that the data corrupts after some intervals of data as show in the below image, can you please tell me how to solve this issue, i am looking forward for your reply.thanks

    https://mail-attachment.googleusercontent.com/attachment/u/0/?ui=2&ik=58f2ad39b5&view=att&th=13ba033fb08fcac3&attid=0.1&disp=inline&realattid=f_har6p2m20&safe=1&zw&saduie=AG9B_P-HEsbSzOf0c1t9f7IJF-lX&sadet=1355602489931&sads=GYIyurJyjUKR62_UjLfjxXENWj4&sadssc=1


  48. Mikal

    5 years ago

    Sorry, I can’t see that image Sajid. It’s not publicly shared.


  49. Sajid

    5 years ago

    Hi,
    thanks for such a great library , i used it to communicate several Arduino but the problem i am facing is that the data corrupts after some intervals of data as show in the below image, can you please tell me how to solve this issue, i am looking forward for your reply.thanks

    http://oi45.tinypic.com/2ikxoph.jpg


  50. Deborah O'Connor

    4 years ago

    I am so confused…
    I have Arduino Uno R3, IDE 1.0.3 and a peice of code using a GSM shield…
    I keep reading confused things about NewSoftSerial and SoftwareSerial….
    which is “new”, which goes in my library?, which include file do I use….
    is it on Arduino or in the library?
    Examples all say “newsoftserial” but my IDE didn’t compile until I changed to SoftwareSerial.h…
    Are the calls still SoftwareSerial ?
    I read everything I can get my eyes on but in this case it has been just a source of confusion.
    Thanks much.

92 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:  http://arduiniana.org/libraries/newsoftserial/ [...]

  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

    [...] http://arduiniana.org/libraries/newsoftserial/ [...]

  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 mitat.tuu.fi

    [...] http://arduiniana.org/libraries/newsoftserial/ http://www.sparkfun.com/commerce/product_info.php?products_id=8950 [...]

  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 http://arduiniana.org/libraries/newsoftserial/ 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:: http://arduiniana.org/libraries/NewSoftSerial/. 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: http://arduiniana.org/libraries/newsoftserial/ [...]

  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 | jarv.org

    [...] 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 NewSoftSerial10c.zip. Des expli­ca­tions et exem­ples plus détail­lés con­cer­nant cette bib­lio­thèque sur cette page (http://arduiniana.org/libraries/newsoftserial/). [...]

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

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

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

    [...] NewSoftSerial Library - http://arduiniana.org/libraries/NewSoftSerial/ [...]

  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 : http://arduiniana.org/libraries/newsoftserial/ [...]

  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 Nolan.ca

    [...] 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

    [...] - http://arduiniana.org/libraries/NewSoftSerial/ 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: http://arduiniana.org/libraries/newsoftserial/ – Eclipse – Android Development Kit (explicitly follow all of Google’s installation [...]

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

    [...] http://arduiniana.org/libraries/newsoftserial/ いいね:いいね 読み込み中… カテゴリー Arduino, [...]

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

    [...] http://arduiniana.org/libraries/newsoftserial/ いいね:いいね 読み込み中… カテゴリー 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: http://arduiniana.org/libraries/TinyGPS and http://arduiniana.org/libraries/newsoftserial/ [...]

  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 http://code.google.com/p/tinkerit/wiki/TrueRandom, NewSoftSerial http://arduiniana.org/libraries/newsoftserial/, and Twitter [...]

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

    [...] NewSoftSerial [...]

  89. Tema 5 – Proyectos Arduino | Aprendiendo Arduino

    [...] NewSoftwareSerial: http://arduiniana.org/libraries/newsoftserial/ [...]

  90. Twitter Poem Box -Arduino for Projects

    [...] Download the TrueRandom http://code.google.com/p/tinkerit/wiki/TrueRandom, NewSoftSerial http://arduiniana.org/libraries/newsoftserial/, and Twitter [...]

  91. 아두이노의 통신 방법, 핀 정리 (Serial, UART, Software Serial, SPI, I2C) | Hard Copy Arduino

    [...] NewSoftSerial (Arduino IDE 1.0 이후 버전만 지원) – Serial 모듈별로 인스턴스를 생성해서 여러개를 사용할 수 있지만 한번에 하나의 인스턴스만 전송/수신 할 수 있습니다. 다른 라이브러리와의 충돌 가능성도 약간 있는 듯 합니다. http://arduiniana.org/libraries/newsoftserial/ [...]

  92. 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 [...]

Leave a Reply