Pages: [1]   Go Down
Author Topic: Having problem using NewSoftSerial on Arduino Pro mini 3.3V  (Read 589 times)
0 Members and 1 Guest are viewing this topic.
Singapore
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am having trouble using "NewSoftSerial" on Arduino pro mini 3.3V.

I have tried Uno and Pro mini3.3V, here are the results

Arduino Uno (Hardware Serial) - works fine
Arduino Uno (Software Serial) - works fine
Arduino Pro Mini 3.3V (Hardware Serial) - works fine
Arduino Pro Mini 3.3V  (Software Serial) - getting special characters in NMEA sentences.

Am I doing anything wrong?

I need to connect 2 serial devices (GPS and GSM modem), so I have to use Software Serial and as much as possible, "Pro mini" to keep the form factor small.

here is my code
Code:
#include <NewSoftSerial.h>
NewSoftSerial gps(9, 8);  // RX, TX

void setup()  {

    gps.begin(38400); 
    Serial.begin(57600);
}

void loop() {

while (gps.available()) {
      char c = gps.read();
      Serial.print(c);
}

}




« Last Edit: February 11, 2013, 03:11:39 am by Kashif » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where do you do Serial.begin () ?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That sketch doesn't even compile:

Code:
#include <NewSoftSerial.h>

void setup()  {
    NewSoftSerial gps(9, 8);  // RX, TX
    gps.begin(38400); 
}

void loop() {

while (gps.available()) {
      char c = gps.read();
      Serial.print(c);
}

}

Code:
sketch_feb11e.ino: In function 'void loop()':
sketch_feb11e:10: error: 'gps' was not declared in this scope
Logged

Singapore
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where do you do Serial.begin () ?

Thanx Nick and sorry for the copy-paste error. I actually tried to copy only relevant portion from my actual code which is a complete GSM/GPS tracker along with XBee comm for debugging. It was quite big, so I just stripped off the unnecessary part. If I could get the above code working (which works on hardware serial), i will be able to resolve the rest.

already modified above code, it should compile fine now .... apologies again
« Last Edit: February 11, 2013, 05:03:05 am by Kashif » Logged

Singapore
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the difference in output using hardware serial and software serial, both on Pro Mini (ATMega328) 3.3V

Output using NewSoftSerial
Code:
$GPG,23m9t9.737,,,\,0,0,\,,,M,,*lB
$G G“A,A\1,,,\,,,,,\,L,,,7T$GPGA,b3u949.x36,,\,,0\0L,,M\,M,l*45
$G G“A,A\1,,\,,,\,L,,,\,lCN
$GPGA,b3u949^9s7,,,\,0,`,L,M,\M,,*l5
LG°GSA\AL1,,\,,,\,L,,,\,L*10$GPGA,b3u950^036L,,,\0,0\,LM,,,,*l5
LGGSA\A,1L,,,\,,,\,l,,,\6,$GPGA,b3u950^136L,,,\0L0,,\M,,,,*l4
LGGSA\AL1,,\,,,\,L,,,\,L*10$GPGA,b3u950^2s7,,,\,0,0,\,M,\M,,*l6
$G GSA\AL1,,\,L,,,\,,,\,l*0N$GPG,23i950^3s6,,\,l0,0\,,M\,,,*l6
$G G“A,A\1,,\,L,,,\,L,,,\*0,$GPGA,b3u950^4s7,,,\,0,0,\,M,\M,,*l0
LGGSA\Al1,,\,L,,,\,,,\,l*00$GPG,23m950^5s6,,\,L0,0\,,M\,,,*l0
$G GSA\Al1,,\,L,,,\,L,,,\*N$GPG,23m9u0.6g6,,\,l0,0\,lM,,,,*l3
$G G³A,A\1,,\,L,,,\,l,,,\*6,$GPG,23m950^7s7,,\,l0,0\,,M,\M,,*l3
$G GSA\A,1,,\,L,,,\,,,\,l5T$GPG,23m950^8s6,,,\,0,0,\,Í,,M,,*lD
$G G³A,A\1,,\,L,,,\,L,,,\*,.$GPG,23m950^9s7,,,\,0,0,\,M,,,,*dD

Output using hardware serial
Code:
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGGA,235946.837,,,,,0,0,,,M,,M,,*4B
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,235946.837,V,,,,,0.00,0.00,050180,,,N*42
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGGA,235946.937,,,,,0,0,,,M,,M,,*4A
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,235946.937,V,,,,,0.00,0.00,050180,,,N*43
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGGA,235947.036,,,,,0,0,,,M,,M,,*43
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,235947.036,V,,,,,0.00,0.00,050180,,,N*4A
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGGA,235947.137,,,,,0,0,,,M,,M,,*43
$GPGSA,A,1,,,,,,,,,,,,,,,*1E

I have also tried different Pins, but same issue.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Recent versions of the IDE use SoftwareSerial. Why are you using NewSoftSerial?
Logged

Singapore
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Recent versions of the IDE use SoftwareSerial. Why are you using NewSoftSerial?

I was not aware of the fact.
I have downloaded the latest version now, Arduino 1.0.3

Modified the code to use "SoftwareSerial" ..... but still no luck .... exactly the same output as earlier.

Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 64
Posts: 6889
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you change the speed of your gps to something less fast, say 28800 or 14400? Arduino runs 16MHz crystal frequency so its 38400 is not exact when it uses its clock to time software serial inputs so lowering speed may help. If you're off by 10% then you get a wrong byte thus some special character.
Logged


Singapore
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you change the speed of your gps to something less fast, say 28800 or 14400? Arduino runs 16MHz crystal frequency so its 38400 is not exact when it uses its clock to time software serial inputs so lowering speed may help. If you're off by 10% then you get a wrong byte thus some special character.

Thanx liudr,
But I am using a non-branded GPS which doesn't even have an RX, only TX (3 wires, +, - and TX) so apparently there is no way I can write back to GPS.

I have another GPS module which is 5V, shall I switch to Pro mini 5V instead? I will still be needing at least 1 software serial as I need to connect a GPS and a GSM modem.

Thanx!
Logged

Pages: [1]   Go Up
Jump to: