Arduino Leonardo + Xbee shield sending command problem

Good morning!

Recently I bought Arduino Leonardo Board and XBee Shield (v 2.2 seeed studio) and GPS Bee module (v1.3 seeed studio).

Now I'm trying to recive data and send commands. Reciving and parsing data is going fine, but when I'm trying to send some command to my shield it does not response in any way.

I'm using NMEA lib to recieve data (http://www.maartenlamers.com/nmea/) and here is my code:

#include <SoftwareSerial.h>
#include <string.h> 
#include <nmea.h>

SoftwareSerial SoftSerial(10,11);
NMEA gps(GPRMC);

void setup()
{
  delay(3000);
 Serial.begin(9600);
 Serial1.begin(9600);
 SoftSerial.begin(9600);
 
 pinMode(11, OUTPUT);
 pinMode(10, INPUT);
 
 delay(3000);
 SoftSerial.println("$PMTK300,500,0,0,0,0*28<CR><LF>");
 delay(3000);
}
 
void loop(){
  if (SoftSerial.available() > 0 ) {
    // read incoming character from GPS and feed it to NMEA type object
    if (gps.decode(SoftSerial.read())) {
      // full sentence received
      
      Serial.print ("Sentence = ");
      Serial.println (gps.sentence());
      Serial.print("Speed:");
      Serial.println(gps.gprmc_speed(MPS));
      Serial.print("Longtitude:");
      Serial.println(gps.gprmc_longitude());
      Serial.print("Latitude:");
      Serial.println(gps.gprmc_latitude());

I guess there is some problem with RX and TX, but I'm not sure. I also tried to replace "SoftSerial.println" with "SoftSerial.write" and "" with "/r/n"

I also tried to exchange pints for 0,1 and use Serial1 instead of just Serial.

So now I'm stuck.

Will appreciate any advice!

 SoftSerial.println("$PMTK300,500,0,0,0,0*28<CR><LF>");

The string "" likely doesn't mean anything to the device. The println() method is already sending a carriage return and line feed, so just lose that part.

 pinMode(11, OUTPUT);
 pinMode(10, INPUT);

You told the SoftwareSerial instance that these were its pins. Quit f**king with them.

I don't understand your problem. If you can receive data, from the GPS using the SoftwareSerial instance, but the GPS does not appear to recognize what you are sending it, the problem is with what you are sending it, not the failure to send it.

It is not clear what the XBee(s) have to do with anything.

PaulS:

 SoftSerial.println("$PMTK300,500,0,0,0,0*28<CR><LF>");

The string "" likely doesn't mean anything to the device. The println() method is already sending a carriage return and line feed, so just lose that part.

I also tried to send without , but it didn't help

pinMode(11, OUTPUT);
 pinMode(10, INPUT);

This is not a problem, this is one of my tries to solve it. I read, that not every Leonardo pin supports RX, so I tried to make this pins work as input and output, It didnt help too

So my question is - If my code is wrong or I have to use some other pins or, maybe, some other suggestions. I'm pretty noob with arduino, so I may not see something obvious [/code]

I read, that not every Leonardo pin supports RX, so I tried to make this pins work as input and out

Pins that don't work for SoftwareSerial are those that do not support pin change interrupts. Declaring a pin that does not support pin change interrupts OUTPUT won't make the hardware suddenly support pin change interrupts. Declaring a pin that does not support pin change interrupts INPUT won't make the hardware suddenly support pin change interrupts.

So my question is - If my code is wrong

The only thing that might be wrong with your code is how it is sending information to the GPS. You have posted only a vague description of what GPS you have, so you can't expect us to know what you need to send it, or how to send it that.

What output do you see on the Serial Monitor application?

PaulS:
Pins that don't work for SoftwareSerial are those that do not support pin change interrupts. Declaring a pin that does not support pin change interrupts OUTPUT won't make the hardware suddenly support pin change interrupts. Declaring a pin that does not support pin change interrupts INPUT won't make the hardware suddenly support pin change interrupts.

Hmm, well, my bad, it looks like obvious one now

PaulS:
The only thing that might be wrong with your code is how it is sending information to the GPS. You have posted only a vague description of what GPS you have, so you can't expect us to know what you need to send it, or how to send it that.

Sorry, I guess I should do this form the very beggining:

My GPS

My shield

PaulS:
What output do you see on the Serial Monitor application?

I made it to output only GPRMC data, because I only need this one. But I have no any response from my GPS while I'm sending commands there.

 SoftSerial.println("$PMTK300,500,0,0,0,0*28<CR><LF>");

How did you decide that this was the command to change the fix interval? Why did you decide that this needed to be changed?

I made it to output only GPRMC data

How?

PaulS:

 SoftSerial.println("$PMTK300,500,0,0,0,0*28<CR><LF>");

How did you decide that this was the command to change the fix interval? Why did you decide that this needed to be changed?

Well, this is my first goal, to send command to output data twice a second.
I found this command here

PaulS:
How?

Olright:

NMEA gps(GPRMC);

Here I crate class

void loop(){

if (SoftSerial.available() > 0 ) {
    // read incoming character from GPS and feed it to NMEA type object
    if (gps.decode(SoftSerial.read()))




Here I decode my GPS data



Serial.print ("Sentence = ");
      Serial.println (gps.sentence());




And here it recognises what data is GPRMC and output only it

Well, this is my first goal, to send command to output data twice a second.
I found this command here

It appears that that last field (28) is a checksum. How did you decide that 28 is the proper value?

Could you try setting the refresh rate to 250 (4 times per second) using the values at that site, to see if the last value IS a checksum?

Olright:
Well, this is my first goal, to send command to output data twice a second.
I found this command here

Yup, this is a checksum. I calculated it with formula, however, if I calculated wrong, there should be response from my board, that it recived command, but didin't understand it.

PaulS:
Could you try setting the refresh rate to 250 (4 times per second) using the values at that site, to see if the last value IS a checksum?

I can, but, as I mentioned before, it will be no any response, so it would be useless to try.

For now, I have an idea, but I have to do other work now, so, I will try it later

I can, but, as I mentioned before, it will be no any response, so it would be useless to try.

If the value on the end IS a checksum, and the value that you have is not the proper checksum for the data that you have, the entire request will be discarded.

I presume that the values given on the web site ARE valid, and that they have been proven to work. I know that that might not be a valid assumption, but it can't hurt to test that assumption.

The alternative is to just accept that the GPS will output what it wants when it wants at the speed that it wants. If that's fine with you, it doesn't bother me.