GPS and Xbee802

Questions about the Waspmote v15 and its modules
Post Reply
david_saiani
Posts: 4
Joined: Wed Jun 21, 2017 12:03 pm

GPS and Xbee802

Post by david_saiani » Wed Jun 21, 2017 12:17 pm

Hi ,

I use a GPS and a XBEE802 card sharing the same UART(uart1).
I can easly get position from GPS or send string on the Xbee if i swith ON OFF the GPS and switch ON OFF the Xbee802.
The problem is switch ON the GPS takes time and I can only get and send the gps position through the Xbee evrey 5 seconds.
If i switch ON the GPS and the Xbee in the void setup and swicth the Uart1 with SetMuxGPS and SetMuxSocket1 in the void loop nothing works.
My question is:
can I switch ON both cards at the begining and switch only the UART with setMux fonction or do i have to switch on off each time the GPS and the Xbee?
I didn't find some exemple code for multiplexing the Uart with SetMux.

Regards

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: GPS and Xbee802

Post by libelium-dev » Thu Jun 22, 2017 1:01 pm

Hi David,

You can set the UART1's multiplexer using this functions

Code: Select all

  Utils.setMuxAux1(); // set Auxiliar1 socket
  Utils.setMuxAux2(); // set Auxiliar2 socket
  Utils.setMuxGPS();  // set GPS socket
  Utils.setMuxSocket1(); // set Socket1
The baudrate of the GPS and the XBee is different so maybe you have to configure it after select the uart.

Don't hesitate to ask if you have more doubts.
Regards

david_saiani
Posts: 4
Joined: Wed Jun 21, 2017 12:03 pm

Re: GPS and Xbee802

Post by david_saiani » Thu Jun 22, 2017 1:54 pm

Hi,

I Know that I have to use those functions.
How you configure the uart1 ?
regards,

david_saiani
Posts: 4
Joined: Wed Jun 21, 2017 12:03 pm

Re: GPS and Xbee802

Post by david_saiani » Thu Jun 22, 2017 3:03 pm

Hi,

Ok I found the solution.

Regards,

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: GPS and Xbee802

Post by libelium-dev » Fri Jun 23, 2017 9:53 am

Hi David,

Glad to hear that you solved the issue! :D

Regards

jburgues
Posts: 25
Joined: Tue Jul 23, 2019 10:47 am
Company: IBEC

Re: GPS and Xbee802

Post by jburgues » Mon Dec 02, 2019 12:03 am

Hello,

I have a similar issue than David, that I am unable to solve.

I want to read the GPS from the 4G module and then interact with an Arduino board that I have connected to UART1 (Baud rate = 600).

When I run the 4G_gps_autonomous_mode_example, I correctly get the GPS data. However, when I embed that example into the code that also uses UART1 for Arduino communication, I don't get any data from the GPS. I don't know if the prolbem is the different baud rate between the Arduino and the 4G module, or that I am missing some step that must be done to make both systems work together. See my code below:

-----------------------------------------------------------------------------------------------------------------------------------------
void setup()
{
///////////////////////////////////////////
// Turn on GPS
///////////////////////////////////////////
error = _4G.ON(); // Switch on the 4G module

if (error == 0)
{
// init GPS feature
gps_status = _4G.gpsStart();

// check answer
if (gps_status == 0)
{
USB.print(F("2. GPS started in Autonomous (Standalone) mode "));
}
else
{
USB.print(F("2. Error calling the 'gpsStart' function. Code: "));
USB.println(gps_status, DEC);
}
}
else
{
// Problem with the communication with the 4G module
USB.println(F("1. 4G module not started"));
USB.print(F("Error code: "));
USB.println(error, DEC);
}
return error;
}

///////////////////////////////////////////
// Iniatilize UART
///////////////////////////////////////////
uart.setBaudrate(600);
uart.setUART(SOCKET1);
uart.beginUART();
uart._buffer = example_buffer;
uart._bufferSize = EXAMPLE_UART_SIZE;
Utils.setMuxAux1();
}


void loop()
{
///////////////////////////////////////////
// Read Arduino
///////////////////////////////////////////
Utils.setMuxAux1();
serialFlush(1); // Flush buffer
uart.sendCommand((uint8_t*) "R", (uint16_t) 1);
if (serialAvailable(1))
{
uart.readBuffer(EXAMPLE_UART_SIZE);
}

///////////////////////////////////////////
// Read GPS
///////////////////////////////////////////
error = _4G.waitForSignal(20000);
if (error == 0)
{
// get degrees
gps_latitude = _4G.convert2Degrees(_4G._latitude, _4G._latitudeNS);
gps_longitude = _4G.convert2Degrees(_4G._longitude, _4G._longitudeEW);
}
}
-----------------------------------------------------------------------------------------------------------------------------------------

Can you provide any help on how to to get GPS data and send/receive commands thru the UART in the same program?

Thanks in advance,
Javier.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: GPS and Xbee802

Post by libelium-dev » Mon Dec 02, 2019 9:26 am

Hi,

The 4G module uses the UART1 too. When the UART is configured to communicate with Arduino it loses the above configuration and can't communicate with the 4G module. Please try to use the function _4G.ON() before using the waitForSignal() function, it will configure the UART to communicate with the 4G module.

Regards

jburgues
Posts: 25
Joined: Tue Jul 23, 2019 10:47 am
Company: IBEC

Re: GPS and Xbee802

Post by jburgues » Mon Dec 02, 2019 4:36 pm

Thanks for the answer.

But, switching ON and OFF the 4G module in every iteration would be very slow...and even slower if gpsStart() has to be called after switching on the 4G module (is this the case?)

Do you think it will work if, instead of switching ON the 4G module every time, I simply call the lines of code inside 4G._ON() that configure the UART (baud rate, multiplexer, etc)?

Or is it mandatory to execute the entire 4G._ON() function?

Thanks,
Javier.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: GPS and Xbee802

Post by libelium-dev » Tue Dec 03, 2019 12:07 pm

Hi,

Yes, you can try to configure the uart without using the ON() function. This is the configuration:

Code: Select all

	// set UART1 multiplexer to Socket1
	Utils.setMuxSocket1();

	// Set UART
	beginUART(115200, 1);

It may necessary to clean the buffer or send some commands before using the GPS function due to weird characters could have sent to the module when the multiplexer changes the position.

Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest