GPS + Radiation board does not work together

Everything about programming the platform and using the Waspmote API
BranoV
Posts: 21
Joined: Wed Mar 22, 2017 3:28 pm

GPS + Radiation board does not work together

Post by BranoV » Wed Mar 22, 2017 3:37 pm

Hello, I am new here and I would be grateful for your help. I trying to run GPS_01 example. If there is just GPS module attached, everything goes well. If radiation board is attached also, I am getting GPS timeout. Any suggestions?

Thanks

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

Re: GPS + Radiation board does not work together

Post by libelium-dev » Thu Mar 23, 2017 11:36 am

Hi,

Radiation board use the TXD1 pin and GPS also use the TXD1 pin so they can suffer interference. You should turn ON and turn OFF the GPS and radiation board in order to they aren't ON at the same time.

Code: Select all

RadiationBoard.ON();
radiation = RadiationBoard.getRadiation();
RadiationBoard.OFF();

delay(1000);

GPS.ON();
GPS.waitForSignal(TIMEOUT);
GPS.getPosition();
GPS.OFF();
Regards

BranoV
Posts: 21
Joined: Wed Mar 22, 2017 3:28 pm

Re: GPS + Radiation board does not work together

Post by BranoV » Thu Mar 23, 2017 1:51 pm

Hi, many thanks for your answer. Just as I have mentioned above, I am trying to run GPS_01 example, and here radiation board is not turned on. Should I turn radiationboard off, even it was not turned on?

Thanks

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

Re: GPS + Radiation board does not work together

Post by libelium-dev » Fri Mar 24, 2017 9:03 am

Hi,

Although you don't use the radiation board you should include its library in the code.

Code: Select all

#include "WaspSensorRadiation.h"
#include <WaspGPS.h>
Regards

BranoV
Posts: 21
Joined: Wed Mar 22, 2017 3:28 pm

Re: GPS + Radiation board does not work together

Post by BranoV » Fri Mar 24, 2017 2:20 pm

Thanks.

So just a repetition. I have radiation board,GPS and SX1272 attached to the main board. This is code I am trying to run. If I have everything attached I get no GPS signal. If radiation board is not attached, everything works.

Code: Select all

/*  
 *  ------ [GPS_01] - Getting basic data from GPS module -------- 
 *  
 *  Explanation: Set GPS module ON. Wait until it is connected to
 *  the satellites. Then information is requested. All data is stored
 *  in GPS attributes. Finally, a conversion to degrees is made in order
 *  to make easy to search positions in internet GPS websites.
 *  
 *  Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L. 
 *  http://www.libelium.com 
 *  
 *  This program is free software: you can redistribute it and/or modify 
 *  it under the terms of the GNU General Public License as published by 
 *  the Free Software Foundation, either version 3 of the License, or 
 *  (at your option) any later version. 
 *  
 *  This program is distributed in the hope that it will be useful, 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 *  GNU General Public License for more details. 
 *  
 *  You should have received a copy of the GNU General Public License 
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 *  
 *  Version:           0.1 
 *  Design:            David Gascón 
 *  Implementation:    Yuri Carmona
 */
#include <WaspSX1272.h>
#include <WaspGPS.h>
#include <WaspSensorRadiation.h>
// define GPS timeout when connecting to satellites
// this time is defined in seconds (240sec = 4minutes)
#define TIMEOUT 240

// define status variable for GPS connection
bool status;


void setup()
{
  // Open USB port
  sx1272.OFF();
  RadiationBoard.OFF();
  USB.ON();
  USB.println(F("GPS_01 example"));

  // Set GPS ON  
  GPS.ON();  
}




void loop()
{
  ///////////////////////////////////////////////////
  // 1. wait for GPS signal for specific time
  ///////////////////////////////////////////////////
  status = GPS.waitForSignal(TIMEOUT);
  
  if( status == true )
  {
    USB.println(F("\n----------------------"));
    USB.println(F("Connected"));
    USB.println(F("----------------------"));
  }
  else
  {
    USB.println(F("\n----------------------"));
    USB.println(F("GPS TIMEOUT. NOT connected"));
    USB.println(F("----------------------"));
  }

  ///////////////////////////////////////////////////
  // 2. if GPS is connected then get position
  ///////////////////////////////////////////////////
  if( status == true )
  {
    USB.println(F("\nGET POSITION:"));
    
    // getPosition function gets all basic data 
    GPS.getPosition();   

    // Time
    USB.print(F("Time [hhmmss.sss]: "));
    USB.println(GPS.timeGPS);

    // Date
    USB.print(F("Date [ddmmyy]: "));
    USB.println(GPS.dateGPS);

    // Latitude
    USB.print(F("Latitude [ddmm.mmmm]: "));
    USB.println(GPS.latitude);  
    USB.print(F("North/South indicator: "));
    USB.println(GPS.NS_indicator);

    //Longitude
    USB.print(F("Longitude [dddmm.mmmm]: "));
    USB.println(GPS.longitude);  
    USB.print(F("East/West indicator: "));
    USB.println(GPS.EW_indicator);

    // Altitude
    USB.print(F("Altitude [m]: "));
    USB.println(GPS.altitude);

    // Speed
    USB.print(F("Speed [km/h]: "));
    USB.println(GPS.speed);

    // Course
    USB.print(F("Course [degrees]: "));
    USB.println(GPS.course);    


    USB.println("\nCONVERSION TO DEGREES (USEFUL FOR INTERNET SEARCH):");
    USB.print("Latitude (degrees):");
    USB.println(GPS.convert2Degrees(GPS.latitude, GPS.NS_indicator));
    USB.print("Longitude (degrees):");
    USB.println(GPS.convert2Degrees(GPS.longitude, GPS.EW_indicator));

  }
  delay(5000);


}

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

Re: GPS + Radiation board does not work together

Post by libelium-dev » Fri Mar 24, 2017 2:54 pm

Hi,

What API are you using? Please try with the last API v027?

Regards

BranoV
Posts: 21
Joined: Wed Mar 22, 2017 3:28 pm

Re: GPS + Radiation board does not work together

Post by BranoV » Tue Apr 04, 2017 8:21 am

Hello again,

Now I am using the last API and basic GPS examples work right now. But, I am trying to run the code attached. What I can see, is that my SD card communication does not work and I can get GPS signal really rarely. Please, am I doing something wrong?

Code: Select all

#include <WaspSensorRadiation.h>
#include <WaspFrame.h>
#include <WaspSX1272.h>
#include <WaspGPS.h>


float radiationcpm;
float radiationusv;
char node_ID[] = "Node_01";

// define the destination address to send packets
uint8_t rx_address = 3;

// status variable
int8_t e;

#define GPS_TIMEOUT 240

// define status variable for GPS connection
bool status;
// define variable
uint8_t sd_answer;

// define file name: MUST be 8.3 SHORT FILE NAME
char filename[]="track.kml";
// char filename2[]="FILE.TXT";

// ending string for KML file
char ENDING[]="</gx:Track></Placemark></kml>";



void setup()
{
  // Open USB port
  USB.ON();
  USB.println(F("Waspmote Tracker"));

  // Set GPS ON  
  GPS.ON();   

  // wait for GPS signal for specific time
  status = GPS.waitForSignal(GPS_TIMEOUT);
  
  if( status == true )
  {    
    USB.println(F("Connected"));
  }
  else
  {
    USB.println(F("GPS TIMEOUT. NOT connected"));
  }


  // Set SD ON
  SD.ON(); 
//  SD.ls();  
  // Create file
  if(SD.create(filename))
  {
    USB.println(F("file created"));
    SD.appendln(filename,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    SD.appendln(filename,"<kml xmlns=\"http://www.opengis.net/kml/2.2\"");
    SD.appendln(filename," xmlns:gx=\"http://www.google.com/kml/ext/2.2\">");
    SD.appendln(filename,"<Placemark>");
    SD.appendln(filename,"\t<gx:Track>"); 
    SD.appendln(filename,ENDING); 
  }
  else 
  {
    USB.println(F("file NOT created"));  
  } 
}




void loop()
{

  // wait for GPS signal for specific time
  status = GPS.waitForSignal(GPS_TIMEOUT);

  if( status == true )
  {
    USB.println(F("Connected"));
    if( GPS.saveEphems() == 1 )
        {
            USB.println(F("Ephemeris stored successfully"));
        }
        else
        {
         USB.println(F("Ephemeris NOT stored successfully"));
        }
    // getPosition function gets all basic data );
    GPS.getPosition(); 

    // Write log to SD card while Red LED is ON
    Utils.setLED(LED0,LED_ON);
    deleteEnding();
    appendTime();
    appendCoord();   
    SD.appendln(filename,ENDING);     
    Utils.setLED(LED0,LED_OFF);
  }
  else
  {
    USB.println(F("GPS TIMEOUT. NOT connected"));
  }

  delay(1000);
  GPS.OFF();
  delay(5000);

  RadiationBoard.ON();
  delay(100);


  ///////////////////////////////////////////
  // 2. Read sensors
  ///////////////////////////////////////////  
  
  // Measure radiation in cpm, during 5s
  // Read radiation for 5 secs
  radiationcpm = RadiationBoard.getCPM(5000);
  // 2. Measure radiation during 2.5 s
  radiationusv = RadiationBoard.getRadiationInt(2500);
  

  ///////////////////////////////////////////
  // 3. Turn off the sensors
  /////////////////////////////////////////// 
  // Power off the board
  RadiationBoard.OFF();


  ///////////////////////////////////////////
  // 4. Create ASCII frame
  /////////////////////////////////////////// 

  // Create new frame (ASCII)
  frame.createFrame(ASCII);

  // Add temperature
  frame.addSensor(SENSOR_RAD, radiationcpm);
  frame.addSensor(SENSOR_RAD, radiationusv);
  frame.addSensor(SENSOR_BAT, (uint8_t) PWR.getBatteryLevel());

  // Show the frame
  frame.showFrame();

   ////////////////////////////////////////////////////////////////
  // 2. Send Frame to another Waspmote
  ////////////////////////////////////////////////////////////////
  USB.println(F("Frame Utility Example for Radiation Board"));

  // Set the Waspmote ID
  frame.setID(node_ID); 
  
  USB.println(F("----------------------------------------"));
  USB.println(F("Setting configuration:")); 
  USB.println(F("----------------------------------------"));

  // Init SX1272 module
  sx1272.ON();

  // Select frequency channel
  e = sx1272.setChannel(CH_10_868);
  USB.print(F("Setting Channel CH_10_868.\t state ")); 
  USB.println(e);

  // Select implicit (off) or explicit (on) header mode
  e = sx1272.setHeaderON();
  USB.print(F("Setting Header ON.\t\t state "));  
  USB.println(e); 

  // Select mode: from 1 to 10
  e = sx1272.setMode(1);  
  USB.print(F("Setting Mode '2'.\t\t state "));
  USB.println(e);  

  // select CRC on or off
  e = sx1272.setCRC_ON();
  USB.print(F("Setting CRC ON.\t\t\t state "));
  USB.println(e);  

  // Select output power (Max, High or Low)
  e = sx1272.setPower('H');
  USB.print(F("Setting Power to 'H'.\t\t state "));  
  USB.println(e); 

  // Select the node address value: from 2 to 255
  e = sx1272.setNodeAddress(2);
  USB.print(F("Setting Node Address to '2'.\t state "));
  USB.println(e);
  USB.println();

  // Sending packet
//  e = sx1272.sendPacketTimeout( rx_address, "Testovacia sprava");
  e = sx1272.sendPacketTimeout( rx_address, frame.buffer, frame.length);

  // Check sending status
  if( e == 0 ) 
  {
    USB.println(F("Packet sent OK"));     
  }
  else 
  {
    USB.println(F("Error sending the packet"));  
    USB.print(F("state: "));
    USB.println(e, DEC);
  } 

  USB.println();
  sx1272.OFF();
  delay(2000);


  GPS.ON();
    if( GPS.loadEphems() == 1 ) 
            {
                USB.println(F("Ephemeris loaded successfully"));
                 }
                        else
        {
         USB.println(F("Ephemeris NOT loaded successfully"));
        }
}

/*
 *  deleteEnding - Deletes the last KML file line
 *  in order to write new Data instead of the ending line
 */
 
void deleteEnding()
{  
  char empty[]="                             ";
  SD.writeSD(filename, empty, SD.getFileSize(filename)-strlen(ENDING)-1);
}


/*
 *  appendTime - append Timestamp to KML file
 */
void appendTime()
{
  char time[100];

  // create timestamp for KML format: <when>yyyy-mm-ddThh:mm:ssZ</when>
  sprintf(time,"<when>20%c%c-%c%c-%c%cT%c%c:%c%c:%c%cZ</when>",  
   GPS.dateGPS[4],
   GPS.dateGPS[5],
   GPS.dateGPS[2],
   GPS.dateGPS[3],
   GPS.dateGPS[0],
   GPS.dateGPS[1],
   GPS.timeGPS[0],
   GPS.timeGPS[1],
   GPS.timeGPS[2],
   GPS.timeGPS[3],
   GPS.timeGPS[4],
   GPS.timeGPS[5]);
  SD.appendln(filename, time);    

}


/*
*  appendCoord - appends coordinates and altitude to KML file
 */
void appendCoord()
{

  char coord[100];
  char latitude_str[30];
  char longitude_str[30];

  float latitude=GPS.convert2Degrees(GPS.latitude, GPS.NS_indicator);
  float longitude=GPS.convert2Degrees(GPS.longitude, GPS.EW_indicator);

  Utils.float2String(latitude, latitude_str, 6);
  Utils.float2String(longitude, longitude_str, 6);  

  sprintf(coord,"<gx:coord>%s %s %s</gx:coord>", longitude_str, latitude_str, GPS.altitude);

  SD.appendln(filename, coord); 

}


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

Re: GPS + Radiation board does not work together

Post by libelium-dev » Tue Apr 04, 2017 11:52 am

Hi,

Does the SD card work without the LoRa module connected? LoRa module and SD card use SPI communication protocol, maybe there is a issue related to SPI interferences. Please test if turning ON the LoRa module the SD works.

Regards

BranoV
Posts: 21
Joined: Wed Mar 22, 2017 3:28 pm

Re: GPS + Radiation board does not work together

Post by BranoV » Sat Jun 17, 2017 9:01 pm

Hello I am very sorry for late response, I had serious health issues. For testing I have used GPS_02 example. Everything works smooth if I use just

Code: Select all

#include <WaspSensorRadiation.h>
#include <WaspFrame.h>
#include <WaspGPS.h>
libraries. If

Code: Select all

#include <WaspSX1272.h>
is added, the communication with SD card does not work anymore. So as you have proposed, there is some kind of interference between SX1272 module and SD card. I would be grateful for any help.

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

Re: GPS + Radiation board does not work together

Post by libelium-dev » Mon Jun 19, 2017 3:28 pm

Hi,

The SD card and the SX1272 module use the SPI communication protocol. So make sure the SD is OFF when the SX1272 module is ON and vice versa.

Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest