Pages: [1]   Go Down
Author Topic: NewSoftSerial not working for me anymore  (Read 1465 times)
0 Members and 1 Guest are viewing this topic.
Moss
Offline Offline
Full Member
***
Karma: 1
Posts: 119
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have been struggling for a few days to read some serial info from an rs485 network, and I thought it was my ttl conversion chip setup that was not working properly, but I have tested with an ftdi cable and I get perfect readings. Why can I not read the same into the arduino?

The sketch I have been trying is based on the simple example, and simplified even more:
Code:
#include <NewSoftSerial.h>

NewSoftSerial mySerial(6, 7); //rx,tx

void setup()  
{
  Serial.begin(19200);
  Serial.println("Goodnight moon!");
  // set the data rate for the NewSoftSerial port
  mySerial.begin(19200);
}

void loop()                     // run over and over again
{

  if (mySerial.available()) {
      Serial.print((char)mySerial.read());
  }
}

It should read strings like:
41 00 00 00 DF 17 20 83 08 4F 6B C7 08 6B
(hex or not is not important at this stage, I'm trying to find the fault)
but instead it's dead silent.

Is there a reason why the library example used two different speeds for mySerial and Serial?

Joachim
Logged

Connecticut
Offline Offline
Edison Member
*
Karma: 16
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think your problem is that you are using the old AND new serial libraries. Try only using the NewSoftSerial functions (in your case, myserial.function().
Logged

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

Quote
Is there a reason why the library example used two different speeds for mySerial and Serial?
Yes. The example illustrates that it is not necessary that the two devices (whatever is connected to the NewSoftSerial TX and RX pins and whatever is connected to the hardware TX and RX pins (0 and 1)) communicate at the same speed. The data coming in on the software port comes in at one speed, and the data going out on the hardware serial port (or the other way around) can go out at a different speed.
Logged

Moss
Offline Offline
Full Member
***
Karma: 1
Posts: 119
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Update:


I got it working again, by making the switch to 0022 and deleting and downloading the library again.

Joachim
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 178
Posts: 12288
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Thank you for the follow-up.
Logged

Pages: [1]   Go Up
Jump to: