Pages: [1]   Go Down
Author Topic: SoftwareSerial library not working on Arduino 1.0, NewSoftSerial on 0023 works  (Read 3779 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I can't get SoftwareSerial library working with Arduino 1.0. Even if I use the included example (Examples/SoftwareSerial/SoftwareSerialExample) I can't receive anything, but when I start Arduino 0023 and use NewSoftSerial with same settings and ports as in SoftwareSerial on Arduino 1.0, everything is working and I'm receiving data from a module that uses rx/tx to communicate.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 84
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the lack of replies is because of the lack of information provided.  "I can't get _______ working" doesn't go far and at best you'll be asked to provide more information.  Post your code and describe your problem's symptoms in much more detail and I'll bet it's a quick and easy fix.  Also make sure to post what version of NewSoftSerial you were using on Arduion 23.  You can access this using the library_version() function.

I can't tell from your post if you're aware or not, but Mikal changed the library in version 11 beta to actually be used as "SoftwareSerial" from "NewSoftSerial" in preparation for it's integration into Arduino 1.0 as the new standard software serial library.  So again, make sure you post the versions you're talking about and it'll be a lot easier to sort all of that out.

That said, I'm preparing to convert a newer project over to Arduino 1.0 "SoftwareSerial" just like a lot of other people so if anything odd comes up I'll check back here and see what other help I can offer.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This code is from the SoftwareSerial example folder. I've changed RX/TX ports to the right ones, which works on my other project file in the earlier version of Arduino. I'm 100% sure that this is not a hardware problem since the other project is working and receiving data from my serial device.

"Goodnight moon!" prints to Serial output but I'm not able to receive anything from mySerial.

Code:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(8, 9);

void setup() 
{
  Serial.begin(9600);
  Serial.println("Goodnight moon!");

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

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

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey,
I have ( i think ) the same issue.
Here is the situation for a project using Arduino-Uno

in my arduino-0023 environment:
I used the NewSoftSerial10c version of Arduiniana and everything works fine (mainly reading data on pin2) .

I noticed that there was a new version of this library "NewSoftSerial11" and I tried for the exact same project and environment for a potential move to the Mega [http://arduiniana.org/2011/01/newsoftserial-11-beta/].
But I did not get it to work.

I am currently also migrating to the new arduino-1.0 environment and I noticed the same issue with the almost similar library SoftwareSerial (standard arduino-1.0)

After a quick check, it seems that available() does not become true. But I did not had the time to dig deeper.
Anyone facing the same issues and has the solution or a hint?

Thanks in advance
TiJean
« Last Edit: December 14, 2011, 10:52:13 am by Tijean » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok I found it:
In the blog post: "This allows for multiple simultaneous instances, although only one can receive at a time."

So actually I needed to first call "mySerial.listen()" before receiving any data on each Serial Instance.
Seems to work now for me.

Hope it helps.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm having the same problem when I attempt to compile the latest GPS_DATALOGGER from Adafruit. 

My error code is: " error: 'class SoftwareSerial' has no member named 'available'  "

Works fine under 0023 and NewSoftSerial10c.

Not sure how or where to use the solution you said fixed your problem? 

Do you have some sample code with the "listen" and "available" members being called/used?

Thanks,
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was having the same problem.... couldn't even get the sample code to compile.  Found that you need to remove the NewSoftSerial folder out of the "sketch folders:library" which by default is in your "mydocuments/arduino/library" folder (if you made one) OR wherever you put the NewSoftSerial folder (could be in your "Arduino-1/library" folder.  Either way it needs to be out of the path that Arduino-1 looks for 'h' files.  I found this out by going to a virgin computer and loading Arduino-1 and the sample compiled with no problems. smiley-mr-green
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys! I am a beginner for this certain hobby, I am using my Arduino Dueminalove with Xbee shield and the Bluetooth Bee V2.0+EDR and fortunately I can/'t configure it. I already used the puTTy to connect my PC and the Bluetooth through USb, it doesn't work.. then I downloaded the Arduino 0023 that contains the NewSoftSerial Lib, I Compiled a code below :


Code:
#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 9
#define TxD 10
#define DEBUG_ENABLED  1

SoftwareSerial blueToothSerial(RxD,TxD);
char incoming;

void setup()
{
  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  setupBlueToothConnection();
  pinMode(4, OUTPUT);    
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);

}

void setupBlueToothConnection()
{
  blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
  delay(1000);
  sendBlueToothCommand("\r\n+STWMOD=0\r\n");
  sendBlueToothCommand("\r\n+STNA=SeeeduinoBluetooth\r\n");
  sendBlueToothCommand("\r\n+STAUTO=0\r\n");
  sendBlueToothCommand("\r\n+STOAUT=1\r\n");
  sendBlueToothCommand("\r\n +STPIN=0000\r\n");
  delay(2000); // This delay is required.
  sendBlueToothCommand("\r\n+INQ=1\r\n");
  delay(2000); // This delay is required.
}

//Checks if the response "OK" is received
void CheckOK()
{
  char a,b;
  while(1)
  {
    if(blueToothSerial.available())
    {
      a = blueToothSerial.read();

      if('O' == a)
      {
        // Wait for next character K. available() is required in some cases, as K is not immediately available.
        while(blueToothSerial.available())
        {
          b = blueToothSerial.read();
          break;
        }
        if('K' == b)
        {
          break;
        }
      }
    }
  }

  while( (a = blueToothSerial.read()) != -1)
  {
    //Wait until all other response chars are received
  }
}

void sendBlueToothCommand(char command[])
{
  blueToothSerial.print(command);
  CheckOK();  
}

void loop()
{
  // get character sent from Android device
  incoming=blueToothSerial.read();    
  // decide what to do with it
  switch (incoming)
  {
  case '1':
    digitalWrite(4, HIGH);
    blueToothSerial.println("pin 4 HIGH");    
    break;

  case '2':
    digitalWrite(5, HIGH);
    blueToothSerial.println("pin 5 HIGH");    
    break;

  case '3':
    digitalWrite(6, HIGH);
    blueToothSerial.println("pin 6 HIGH");    
    break;

  case '4':
    digitalWrite(7, HIGH);
    blueToothSerial.println("pin 7 HIGH");    
    break;

  case '5':
    digitalWrite(4, LOW);
    blueToothSerial.println("pin 4 LOW");    
    break;

  case '6':
    digitalWrite(5, LOW);
    blueToothSerial.println("pin 5 LOW");    
    break;

  case '7':
    digitalWrite(6, LOW);
    blueToothSerial.println("pin 6 LOW");    
    break;

  case '8':
    digitalWrite(7, LOW);
    blueToothSerial.println("pin 7 LOW");    
    break;
  }
  delay(100);
}
__________________
ERROR

btb1.cpp: In function 'void CheckOK()':
btb1:66: error: 'class SoftwareSerial' has no member named 'available'
btb1:73: error: 'class SoftwareSerial' has no member named 'available':

Can anyone can help to fix them all out?
thanks..


Moderator edit: [code] [/code] tags added.
« Last Edit: February 10, 2013, 10:49:53 pm by Coding Badly » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49071
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am using my Arduino Dueminalove with Xbee shield and the Bluetooth Bee V2.0+EDR and fortunately I can/'t configure it.
There is something fortunate about that?

Quote
then I downloaded the Arduino 0023 that contains the NewSoftSerial Lib, I Compiled a code below :
So? You didn't change SoftwareSerial to NewSoftSerial, so the obsolete SoftwareSerial is being used, which, as the compiler is telling you, doesn't have an available method.

Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Several months ago, I tried using SoftSerial and AltSoftSerial, and you can see the results here,

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

Basically, even Nick Gammon couldn't get the darn thing to work. I eventually gave up completely
on it, even though some people seem to have no problems.

I guess there are 2 kinds of SoftSerial people in the world. I'm still hoping I can someday move into
the world of the-haves.
« Last Edit: November 19, 2012, 01:15:14 pm by oric_dan(333) » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

NewsoftSerial didn't want to work. I've just tried with different ports, and it's working even they are not agreed by the documentation.

Code:
#include <SoftwareSerial.h>
//SoftwareSerial debugSerial (48, 46); // RX/TX
OR
SoftwareSerial debugSerial (47, 48); // RX/TX

I have a Seeduino Mega 1280.
Logged

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3007
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

At which school are they teaching people to write these ridiculous case statements ?
Logged

Pages: [1]   Go Up
Jump to: