NewSoftSerial

A New Software Serial Library for Arduino

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
  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 “use” an object by calling its begin(), available(), read(), or print[ln]() methods, 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 = device1.read();
    ...
  }
  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

Upcoming Improvements

  • RTS/CTS flow control
  • support for Arduino Mega

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: NewSoftSerial10c.zip

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.

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 January 18, 2010 at 12:26 pm
207 Responses → “NewSoftSerial”

  1. Mikal

    5 months ago

    Probably– at 8MHz you are somewhat capped on baud rate though. If you’re using using one of those 4800-baud GPS, I would expect it to work ok.


  2. Mikal

    5 months ago

    Jeff–

    If someone could generate the appropriate timing tables for 12MHz — I don’t have any test devices — I’m sure it would work fine. You could just do an approximation by averaging the 8 and 16MHz values.

    Mikal


  3. Obi

    4 months ago

    Hello Mikal thank you for your support with these libraries I was wondering if the Mega supported newsoftserial library have been released yet


  4. Patrick

    4 months ago

    I could use some help. I am using this for my GPS. I am trying to get the bearing and i understand that the GPS does that for you.

    // track angle
    parseptr = strchr(parseptr, ‘,’)+1;
    trackangle = parsedecimal(parseptr);

    Is the above in the code for the bearing?
    if it is, i can not get it to tell me bearing.
    It prints random numbers and sometimes some weird characters. Every other part of the code works and i have written my own distance code that works. I also wrote code for telling me bearing from my current location to a different GPS point. I would like to get my current bearing when i move but i can not get the above code to work. Any help would be appreciated.


  5. Mikal

    4 months ago

    Hi Obi–

    No, not yet. But the next version of Arduino will likely contain a version of NewSoftSerial that does support Mega.

    Thanks,

    Mikal


  6. Mikal

    4 months ago

    Patrick, are you using TinyGPS? TinyGPS does support the “course” field. Is that what you’re talking about?

    Mikal


  7. Patrick

    4 months ago

    Mikal

    I am using your newsoftserial library and the example gps code that comes with it.


  8. Patrick

    4 months ago

    Mikal

    I was able to easily switch my formulas over to the tinygps library. So i will use that one since it gives heading. Thank you.


  9. kee nethery

    4 months ago

    Not to be unappreciative but … is there any documentation? For example: it is not obvious in NewSoftSerial myGPS(3, 2); if pin 3 is TX or RX. I’m sure I can connect up to a serial LCD and figure it out but it would be nice if there was documentation.

    As a suggestion, perhaps grab all the docs associated with: http://arduino.cc/en/Reference/Serial and alter them to describe NewSoftSerial. Less work for you (or someone knowledgeable) and it would allow beginners to compare and contrast. Thanks!


  10. Joe

    4 months ago

    I am using 10c of your NewSoftSerial and see strange behaviour in my sketch.
    I can call the print method from the sketch but when it is called from a lib
    via a ptr passed in to the “translator” contructor, print does nothing. I have put this on the o-scope to verify.

    nss.print(‘X’, BYTE); // Put this in for DEBUG. It works.

    translator.sendPackerRequest();

    if (translator.waitForPacket() == true) { // The “print” in “waitForPacket()” does nothing…
    Serial.println(“DEBUG: Received Packet”);
    // Received packet, and passed checksum. Now parse it.
    //translator.parsePacket(); // Done in waitForVipecAPacket now
    //translator.translate();
    //translator.sendPacket();
    }
    else {
    //Serial.print(“.”);
    Serial.println(“DEBUG: Failed to Receive Packet”);
    }


  11. Mikal

    4 months ago

    Kee, the documentation is indeed a little weak I agree. For your specific situation the RX is always the first parameter (just like in SoftSerial).

    Mikal


  12. Mikal

    4 months ago

    Joe, without looking at the code for this “translator” object I wouldn’t be able to guess why your application doesn’t print anything.

    Mikal


  13. Spencer

    4 months ago

    I am trying to load your code into my arduino and its not working. I am new and maybe I don’t understand what to do. I have an Arduino and a gps and I am pasting your code into my version 18 of the arduino IDE and it comes up with errors. Do I need to download TinyGPS to arduino? Please help.


  14. Mikal

    4 months ago

    You didn’t say what code you are trying, but if it requires TinyGPS, then you need to install it correctly. Perhaps if you listed the first couple of error messages?…


  15. Phlogi

    4 months ago

    Hi there

    Is there any development version of this that has already support for the Arduino Mega? If not I’ll start porting it soon.


  16. pantelis

    4 months ago

    Does the new newsoftserial version (10c) makes the feedgps() function of tinyGPS not compatible or something?

    i mean:
    ////////////////////////////////////////////////
    from newsoftserial
    /////////////////////////////////////////////////
    This means that you can’t write code like this:
    void loop()
    {
    if (device1.available() > 0)
    {
    int c = device1.read();

    }

    ////////////////////////////////////
    tinyGPS
    bool feedgps()
    {
    while (nss.available())
    {
    int c = nss.read();
    if (gps.encode(c))
    {
    // process new gps info here
    }
    }
    }
    ////////////////////////////////////////////

    I’m using tinyGPS with a ping ultrasonic sensor. I didnt try to create a newsoftserial object for the sensor (yet), but it seems that it fails to work as it does, when I use it without the gps and a newsoftserial object.
    For example, I have set my vehicle to stop its motors when the sensor reads an obstacle in a distance of 70cm. Instead, the vehicle stops well below 70cm and sometimes it does not stop at all.

    here’s what I do:

    void loop()
    {
    get_gps_data();
    if (newdata)
    {
    if(sensor_readings < 70) avoid_obstacle_routine();
    forward();
    }
    }
    —————————————–
    bool feedgps()
    {
    while (nss_gps.available())
    {
    if (gps.encode(nss_gps.read()))
    return true;
    }
    return false;
    }

    void get_gps_data()
    {
    nss.begin(4800);
    unsigned long start = millis();

    // Every 1 second we print an update
    while (millis() – start < 1000)
    {
    if (feedgps()) newdata = true;
    }

    if (newdata) gpsdump(gps);
    nss_gps.end();
    } // end of get_gps_data()

    ——————————————-

    What am I doing wrong? Should I declare an nss object for my sensor? Maybe not use the nss.end() method in the end of the get_gps_data function. I’m kind of lost here :(


  17. Larry

    4 months ago

    Very impressive library! I’m just having one weird issue: I have to use the same baud rate on the NewSoftSerial instance as I do on the hardrware UART or there seem to be sync issues.

    I explain: First, I successfully H/W 4800 read, parse and H/W 4800 serial print NMEA data from a GPS module, confirming the data by looking at it in a serial monitor app. Second, I repeat this success now using NewSoftSerial, connecting the GPS to RX pin 2 and setting 4800 baud on both NewSoftSerial pin 2 and H/W UART. Third, all I change is baud to 9600 on UART and now there is a problem. The board generates correct output for a second or two, but then the data generated gets choppy and corrupted and finally ceases. It’s like it’s having trouble synchronizing the 4800 baud on pin 2 and the 9600 on the H/W. Though I know the two are really uncorrelated.

    Can you help? Does this have to do with trying to use two serial interfaces at once? Any suggested corrective action?

    Thank you!


  18. Mikal

    4 months ago

    @pantelis –

    In most cases you would never call nss.end(). There shouldn’t be any incompatibility between TinyGPS and NewSoftSerial. You should probably only call nss.begin() once at the beginning of your program.

    Mikal


  19. Wolfgang

    4 months ago

    High Mikal,

    Many Txs for the NSS!
    Unfortunately I cannot receive proper datas from my 9DOF Razor board (8Mhz) sent by the standard serial to my 2009Board (16Mhz), no matter which boud rate. The razor reports properly via the 3.3V FTDI to the serial screen on the computer. Sending datas from the razor to the 2009board (receiving with nss) and resending via standard serial to the computer does not work. If I send 1 digit with one serial.print from the razor it is ok, two digits it still receives the first one only. If I do it with two serial prints (one digit each), I can put it through to the computer.- Strange
    May I kindly ask to help?- many thanks in advance,
    b.r.
    Wolfgang


  20. pantelis

    4 months ago

    Right, after running some more tests, also using a nss object for the ping, I realised that the lib was working fine. It was actually the ping that was closing obstacles in a shallow angle and couldn’t detect them, unless it was close enough so the echo was able to reflect and return to the ping in order to take a measure.


  21. jab

    4 months ago

    Thanks for what might be the most useful Arduino library ever! But.. :)
    Recently I have started using some Teensy2.0 boards, and I have a problem with NSSv10c and receive when using high pin numbers. I have a test controlling four Sony camera modules. Cam1 on arduino pin 14&15, cam2 16&17, cam3 18&19 and cam4 on pin 20&21. Cam1 works fine both send and receive. But cam2,3&4 will only transmit and does not receive incoming data (read() == -1). I have scoped the pins and conformed there is data on all tx&rx pins, but only the NNS instance using pin 14&15 receives data. I have also made sure only one NSS instance will send and receive before moving one to the next one as stated in the using multible NSS examples.


  22. Mikal

    4 months ago

    @Wolfgang: is NSS used only for receiving on the Arduino? Or are you transmitting too? Transmitting with NSS can cause received bytes to be lost, but I wouldn’t expect transmitting with Serial to affect NSS reception. Hm…

    Mikal


  23. Wolfgang

    4 months ago

    High Mikal,

    Yes, it triggers the datas to be sent, thereafter 25 mills delay, as faster I can´t receive anything. If I want to send -179 from the razor with hardware serial to the 2009board receiving with nss, what would be the best code at what max speed?

    many thanks in advance for your help!

    b.r.
    Wolfgang


  24. Mikal

    4 months ago

    Wolfgang, I can’t immediately figure out why that doesn’t work. Perhaps if you shared your code?

    Mikal


  25. Mikal

    4 months ago

    @jab,

    Thanks for that most useful data. I haven’t played with a teensy 2.0, so I haven’t been able to verify anything, but it seems like good data. If you connect only one camera (and one NSS object to support it) to, say, pins 20 and 21, does that work in isolation? (I’m trying to figure out whether the pin mappings are wrong for high pins, or whether there is a problem with multiple objects.)

    Thanks!

    Mikal


  26. Wolfgang

    4 months ago

    Dear Mikal,

    this send the datas from the razor at 38400 baud, rolli is type int and is defined in main page. If connected to the comp directly, datas are received in perfect order.

    void printdata(void)
    {
    rolli= int(ToDeg(roll)+180);
    if (Serial.available()) {
    Serial.read();
    Serial.print ((rolli));
    }
    }

    This receives the data from the razor and send to serial window of Arduino 0018:

    #include
    NewSoftSerial Gyro(4,5);
    byte roll=0;

    void setup() {
    Gyro.begin(38400);
    delay(100);
    Gyro.flush();
    Serial.begin(57600);
    delay(100);
    }

    void loop() {

    Gyro.print(1);
    delay(30);
    if (Gyro.available()) {
    delay(25);
    Serial.println(Gyro.read(),BYTE);
    }

    Gyro.flush();
    Serial.flush();
    }

    If I add more Serial.print(Gyro.read(),BYTE), I receive more bytes (amount how many digits are sent), which are not correct ASCII characters. If there are no more bytes, I receive -1.

    many thanks again,
    b.r.
    Wolfgang


  27. jab

    4 months ago

    @Mikal: It is most likely a pin mapping/interrupt related problem. I can swap pins on any of the four NSS instances controlling cameras, and the one using pins 14&15 start working both ways. While the others will only transmit.


  28. jab

    4 months ago

    @Mikal: Sorry, forgot to answer you specific question about a single NSS on high pins. I left the project at work, so I will test that first thing tomorrow morning.


  29. jab

    4 months ago

    @Mikal: I have just confirmed that a single NSS object on pin 20&21 does not work with the Teensy 2.0, so the problem is most likely not related to using multiple objects.


  30. jab

    4 months ago

    @Mikal: After some more testing, it would seem that NSS receive on the Teensy 2.0 will only work if PORTB (PCINT) pins are used as RX pins.


  31. JLux on Arduino

    4 months ago

    But supposing I need send to this command to Arduino:

    Print #4 , Chr(&H80) ; Chr(&Ha4) ; Chr(&H30) ; Chr(&H02) ; Chr(&H09);

    (this command is a command to be send to a fingerprintsensor)

    How can I accomplish that task with NewSoftSerial ??

    JLux


  32. Mikal

    4 months ago

    See email JLux…

    Mikal


  33. aka ged

    3 months ago

    Hi Mikal,
    I really like the idea of what you’re doing with NewSoftSerial, but
    I’m having trouble compiling it into a sketch for my Serial graphicl LCD 128×64.
    Using Arduino-0018 with a duemillanove 328p.
    OpSys:Win2000 Pro SP4. Have the used run.bat to sort the java PATH.
    The NewSoftserial directory is in my sketch folder.
    Getting these compile errors:-

    27: error: NewSoftSerial.h: No such file or directory In function ‘void setup()’:
    In function ‘void loop()’:
    Bad error line: -2

    Now, I have been a programmer in days gone by, is the any other way to direct the compiler to non-standard libraries ? Or, am I missing something really basic?? :-(

    tia aka ged


  34. Eric

    3 months ago

    @Mikal
    I’m having some issues using your library with my Parallax RFID reader.
    I have outlined the issue on the Arduino forums here http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1273612596/0
    If you have any insight on what might be wrong it would be greatly appreciated.

    Thanks


  35. Mikal

    3 months ago

    @aka ged–

    You don’t put libraries in your sketch folder; they need to go whereever the built-in libraries are. In Windows this is in the hardware\libraries folder underneath Program Files.

    Mikal


  36. Mikal

    3 months ago

    Hi Eric–

    See my response on the forum. You need to check rfid.available() before trying to read bytes.

    Mikal


  37. Darin

    3 months ago

    Mikal:

    Isn’t you “object.available()” caveat in “Using Multiple Instances” violated in you TwoNSSTest.pde example?

    Thanks.


  38. Fred

    3 months ago

    Hey Mikal,

    Great work with this library !!

    But I have a little trouble using it … I saw in other forum that the delay function can have trouble while using the librarie, so I try to avoid this problem (Ì really need delay in my application) by openning and closing the serial connection each time I need it. But I can’t figure why, but my program seems to be block when I call the begin function (in the loop place for example) …
    Can you help me figure what’s the problem ??
    A little response would be really appreciated, and if you really need it I can send you a sample code…

    Thank you very much !!!

    Fred


  39. Fred

    3 months ago

    Oups just a modification for my previous post, I’m using the serial to communicate between two arduino (or more) with simple RF component…

    And the begin does not fully block, it seems to stay on the begin function for a random time, or perhaps the time to the RF receiver to get any signal on its pin …

    Just for you to know, I’m trying to build an simple architecture with one arduino for the server role, and many other arduinos in emitters role, and each emitter arduino send data to the server arduino.
    So I need to use both hardware serial to send data, because with this one the end() method really disable the pins allowing me to send data with an other arduino (two RF transciever cannot be active in the same time), and then newsoftwareserial to do the listen task, because I need to know if an other arduino is sending data in order to know if can emit something…

    I really need help on this, I’m not an electronik an arduino specialist !!!

    Thank you anyway for your great work !!


  40. Mikal

    3 months ago

    @Darin,

    Perhaps I could have been a bit more clear in describing the hazards of multiple instances, but the main point is this: the first call of object.available() on an inactive NSS instance always returns 0. The function simply activates the instance and returns without waiting for any data to show up. This architecture works reasonably well except in the case where you write code that repeatedly checks available() first on one instance and then another. Each will never do anything but return 0. You must

    The sample code in TwoNSSTest.pde is a little different. It calls available() many, many times on each instance — continuously for 10 seconds — before switching to the other instance. This makes all the difference.

    In the real world, you probably would use time to decide to switch to a new device. You’d probably wait for a specific message or condition.

    Does that help?

    Mikal


  41. Mikal

    3 months ago

    @Fred,

    Delay is only a problem with NewSoftSerial in the sense that you run the risk of overrunning your receive buffer. You won’t solve that by calling begin and end repeatedly. Don’t do it! :) And if you do worry whether you’ve lost data, you can always check object.overflow(). Does that help?

    Mikal


  42. Fred

    3 months ago

    Hi Mikal,

    I’m going to have a look at the overflow() function to see if it can help me. But if I don’t open and close the connection when I need to use the serials functions, like if I start the serial function only in the setup, then when I use the delay() function somewhere in my code, the delay seems to be really untrustable… (1000ms in the code looks like 5000ms in the reality !!)
    Do you think there’s a way to avoid this kind of trouble ??
    Perhap’s by disabling the interuption while I’m not using it, but I’m not sure how to realize this (maybe I remember I see a function for that…) ?


  43. Darin

    3 months ago

    Thanks, Mikal.
    If I do want to repeatedly cycle between multiple instances, would you recommend 2 consecutive calls to object.available()…the first to “activate” the instance, and the second to do the work…or is there a more elegant approach? Just curious: Why did you choose not to automatically “activate” an inactive instance that is being referenced? Efficiency? I am, after all, making a conscious attempt to use the instance.

    Regards.


  44. Mikal

    3 months ago

    @Darin,

    Yes, checking twice is what I recommend, but that’s usually what happens because in nearly every application, NewSoftSerial::available is called repeatedly in a loop and not just once.

    I think I have concluded that it would have been a better architecture to require the user to explicitly activate the instance. When NewSoftSerial gets folded into the Arduino kernel in the next few weeks, I think it will have this explicit activation feature.

    Mikal


  45. Mikal

    3 months ago

    Fred,

    I don’t think there is anything wrong with delay(). And before you substitute repeated begin/end calls, keep in mind that you were not having success there either. I suspect that there is something else going on in your code that is causing problems. I recommend incrementally simplifying your structure until you isolate the problem.

    Mikal


  46. Fred

    3 months ago

    Hi,
    I manage to isolate the part that was causing problem in my program. There’s two weird things, the first one is the begin method, I don’t know why but she take time to pass if there’s no data on the RF receiver … the second one still the delay that are not acurate when the serial is activated …

    I found a solution to my problem by modifiying the HardwareSerial librairie, I manage to create differents methods like endTX() or endRX() for the serial, in order to allow me to use them like I want…

    Thank you anyway for your help, really appreciate it … But If you manage to identify the problems I was talking about don’t hesitate to contact me !!!

    Bye !!


  47. Chibi

    3 months ago

    I have been having issues with incorrect read data. It is consistently corrupted. I am running at 115,200 BAUD. I have not had any problems sending data, but I keep getting -32640 when I should be getting zero. I am really confused because 0 is always 0 in all binary number systems. I was wondering if I was having an issue with the timing on the stop bit or perhaps my BAUD rate is too fast.


  48. Guz

    3 months ago

    @Wolfgang

    Hi, I try to connect the 9DOF to Arduino 2009 too.
    I try to power supply it with the external connector because I read that it needs 70mA and Arduino 3.3V is limited to 50mA.

    I use your code and I receive caracters but it is scrambled.

    I don’t succeded in receiving good caracters.

    Do you get that ?

    Regards.


  49. Mikal

    3 months ago

    chibi — there most definitely is a timing issue. The Arduino process just isn’t precise and fast enough to do 115.2K baud RX reliably.

    Mikal


  50. Mikal

    3 months ago

    @Guz–

    Do you have the grounds connected together?

    Mikal

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

Leave a Reply