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

Re: GPS + Radiation board does not work together

Post by BranoV » Tue Jul 18, 2017 4:22 pm

Dear developers,
as I have proposed I tried to use all of the modules together. Here is my input:

Code: Select all

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


float radiationcpm;
float radiationusv;

char node_ID[] = "Node_01";
uint8_t rx_address = 3;
int8_t e;

#define GPS_TIMEOUT 120

// define status variable for GPS connection
bool status;

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

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

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

  GPS.ON();   

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

 delay(1000); 
}

void loop()
{
  ///////////////////////////////////////////
  // 1. Turn on the board
  /////////////////////////////////////////// 
   GPS.OFF();
  delay(1000);
  RadiationBoard.ON();
  delay(100);


  ///////////////////////////////////////////
  // 2. Read sensors
  ///////////////////////////////////////////  
  

  // 2. Measure radiation during 25 s
  radiationusv = RadiationBoard.getRadiationInt(25000);
  

  ///////////////////////////////////////////
  // 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, radiationusv);
  frame.addSensor(SENSOR_BAT, (uint8_t) PWR.getBatteryLevel());
    
  // Show the frame
  frame.showFrame();

 

//  SD.ON();
  delay(5000);
  GPS.ON();
 SD.ON();
 delay(3000);

            if( GPS.loadEphems() == 1 ) 
            {
                USB.println(F("Ephemeris loaded successfully"));
             }
            else 
            {
                USB.println(F("Ephemeris load failed"));
            }
  delay(1000);
SD.OFF();

  status = GPS.waitForSignal(GPS_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 )
  {
     // store ephemeris in "EPHEM.TXT"
        if( GPS.saveEphems() == 1 )
        {
            SD.ON();
            delay(1000);
            USB.println(F("Ephemeris stored successfully"));
            delay(1000);
            SD.OFF();
        }
        else 
        {
            USB.println(F("Ephemeris storing failed"));
        }
    
    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));

   frame.addSensor(SENSOR_GPS, 
                    GPS.convert2Degrees(GPS.latitude, GPS.NS_indicator),
                    GPS.convert2Degrees(GPS.longitude, GPS.EW_indicator) );
  
    //Add altitude [m]
    frame.addSensor(SENSOR_ALTITUDE,GPS.altitude);
    
    //Add speed [km/h]
    frame.addSensor(SENSOR_SPEED,GPS.speed);
    
    //Add course [degrees]
    frame.addSensor(SENSOR_COURSE,GPS.course);    

//    frame.addSensor(SENSOR_COURSE,GPS.EW_indicator); NEJDE!
    
    //Add time
    frame.addSensor(SENSOR_TIME,GPS.timeGPS);
    
    //Add date
    frame.addSensor(SENSOR_DATE,GPS.dateGPS);
    
    frame.showFrame();  

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

   ////////////////////////////////////////////////////////////////
  // 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(1000);

}


void deleteEnding()
{  
  char empty[]="                             ";
  SD.writeSD(filename, empty, SD.getFileSize(filename)-strlen(ENDING)-1);
}


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); 

}
and here is my output:

Code: Select all

E#
Waspmote Tracker
Connected
===============================
Current ASCII Frame:
Length: 46
Frame Type:  128
frame (HEX): 3C3D3E800223343033343539343834234E6F64655F30312330235241443A302E313735333932234241543A393323
frame (STR): <=>€#403459484#Node_01#0#RAD:0.175392#BAT:93#
===============================
Ephemeris load failed

----------------------
GPS TIMEOUT. NOT connected
----------------------
Frame Utility Example for Radiation Board
----------------------------------------
Setting configuration:
----------------------------------------
Setting Channel CH_10_868.	 state 0
Setting Header ON.		 state 0
Setting Mode '2'.		 state 0
Setting CRC ON.			 state 0
Setting Power to 'H'.		 state 0
Setting Node Address to '2'.	 state 0

Packet sent OK

===============================
Current ASCII Frame:
Length: 46
Frame Type:  128
frame (HEX): 3C3D3E800223343033343539343834234E6F64655F30312331235241443A302E313136393238234241543A393323
frame (STR): <=>€#403459484#Node_01#1#RAD:0.116928#BAT:93#
===============================
Ephemeris load failed

----------------------
GPS TIMEOUT. NOT connected
----------------------
Frame Utility Example for Radiation Board
----------------------------------------
Setting configuration:
----------------------------------------
Setting Channel CH_10_868.	 state 0
Setting Header ON.		 state 0
Setting Mode '2'.		 state 0
Setting CRC ON.			 state 0
Setting Power to 'H'.		 state 0
Setting Node Address to '2'.	 state 0

Packet sent OK

E#
E#
Waspmote Tracker
Connected
===============================
Current ASCII Frame:
Length: 46
Frame Type:  128
frame (HEX): 3C3D3E800223343033343539343834234E6F64655F30312330235241443A302E313735333932234241543A393423
frame (STR): <=>€#403459484#Node_01#0#RAD:0.175392#BAT:94#
===============================
Ephemeris load failed

----------------------
GPS TIMEOUT. NOT connected
----------------------
Frame Utility Example for Radiation Board
----------------------------------------
Setting configuration:
----------------------------------------
Setting Channel CH_10_868.	 state 0
Setting Header ON.		 state 0
Setting Mode '2'.		 state 0
Setting CRC ON.			 state 0
Setting Power to 'H'.		 state 0
Setting Node Address to '2'.	 state 0

Packet sent OK

===============================
Current ASCII Frame:
Length: 46
Frame Type:  128
frame (HEX): 3C3D3E800223343033343539343834234E6F64655F30312331235241443A302E303937343430234241543A393423
frame (STR): <=>€#403459484#Node_01#1#RAD:0.097440#BAT:94#
===============================
Ephemeris load failed

----------------------
GPS TIMEOUT. NOT connected
----------------------
Frame Utility Example for Radiation Board
----------------------------------------
Setting configuration:
----------------------------------------
Setting Channel CH_10_868.	 state 0
Setting Header ON.		 state 0
Setting Mode '2'.		 state 0
Setting CRC ON.			 state 0
Setting Power to 'H'.		 state 0
Setting Node Address to '2'.	 state 0

Packet sent OK
As you can see I am not able to run everything correctly even I am not turning off the LORA module. Please do you have any advises?

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 Jul 20, 2017 12:59 pm

Hi,

Did you reset Waspmote manually or a spontaneous reset occurs? Please check the battery level.
Packet sent OK

E#
E#
Waspmote Tracker
The first waitForSignal() function works, so please try to perform it in the same way as it

Code: Select all

....

 GPS.ON();
 SD.ON();
 delay(3000);

  status = GPS.waitForSignal(GPS_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 )
  {
     // store ephemeris in "EPHEM.TXT"
        if( GPS.saveEphems() == 1 )
        {
            USB.println(F("Ephemeris stored successfully"));
        }
        else 
        {
            USB.println(F("Ephemeris storing failed"));
        }
        
        ....
Regards

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

Re: GPS + Radiation board does not work together

Post by BranoV » Tue Aug 01, 2017 11:48 am

So I tried again,result is the same. If the problem with lora library from previous case in not solved, we can probably not move further.

Code: Select all

E#
Waspmote Tracker
Connected
===============================
Current ASCII Frame:
Length: 46
Frame Type:  128
frame (HEX): 3C3D3E800223343033343539343834234E6F64655F30312330235241443A302E303937343430234241543A393523
frame (STR): <=>€#403459484#Node_01#0#RAD:0.097440#BAT:95#
===============================
Ephemeris load failed

----------------------
GPS TIMEOUT. NOT connected
----------------------
Frame Utility Example for Radiation Board
----------------------------------------
Setting configuration:
----------------------------------------
Setting Channel CH_10_868.	 state 0
Setting Header ON.		 state 0
Setting Mode '2'.		 state 0
Setting CRC ON.			 state 0
Setting Power to 'H'.		 state 0
Setting Node Address to '2'.	 state 0

Packet sent OK

===============================
Current ASCII Frame:
Length: 46
Frame Type:  128
frame (HEX): 3C3D3E800223343033343539343834234E6F64655F30312331235241443A302E313336343136234241543A393523
frame (STR): <=>€#403459484#Node_01#1#RAD:0.136416#BAT:95#
===============================
Ephemeris load failed

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

Re: GPS + Radiation board does not work together

Post by libelium-dev » Wed Aug 02, 2017 9:37 am

Hi Brano,

We have slightly modified your code with next changes.

There is no need to turn on or off the SD manually. It is managed by the GPS library.
Due to you don't turn off the LoRa module, the configuration can be moved to the setup()
We see no need to use the GPS in the setup.

Please try the dice again and let us know if ephems loads ok. However, first loop they won't because they aren't stored yet.

Code: Select all

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


float radiationcpm;
float radiationusv;

char node_ID[] = "Node_01";
uint8_t rx_address = 3;
int8_t e;

#define GPS_TIMEOUT 120

// define status variable for GPS connection
bool status;

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

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

void setup()
{
  USB.ON();
  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();


  // Open USB port
  //  USB.ON();
  USB.println(F("Waspmote Tracker"));
  //
  //  GPS.ON();
  //
  //  // wait for GPS signal for specific time
  //  status = GPS.waitForSignal(GPS_TIMEOUT);
  //
  //  if ( status == true )
  //  {
  //    USB.println(F("Connected"));
  //    Utils.blinkLEDs(3000);
  //  }
  //  else
  //  {
  //    USB.println(F("GPS TIMEOUT. NOT connected"));
  //  }

  delay(1000);
}

void loop()
{
  ///////////////////////////////////////////
  // 1. Turn on the board
  ///////////////////////////////////////////
  GPS.OFF();
  delay(1000);
  RadiationBoard.ON();
  delay(100);


  ///////////////////////////////////////////
  // 2. Read sensors
  ///////////////////////////////////////////


  // 2. Measure radiation during 25 s
  radiationusv = RadiationBoard.getRadiationInt(25000);


  ///////////////////////////////////////////
  // 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, radiationusv);
  frame.addSensor(SENSOR_BAT, (uint8_t) PWR.getBatteryLevel());

  // Show the frame
  frame.showFrame();



  //  SD.ON();
  delay(5000);
  GPS.ON();
  //SD.ON();
  delay(3000);

  if ( GPS.loadEphems() == 1 )
  {
    USB.println(F("Ephemeris loaded successfully"));
  }
  else
  {
    USB.println(F("Ephemeris load failed"));
  }
  delay(1000);
  //SD.OFF();

  status = GPS.waitForSignal(GPS_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 )
  {
    // store ephemeris in "EPHEM.TXT"
    if ( GPS.saveEphems() == 1 )
    {
      //SD.ON();
      delay(1000);
      USB.println(F("Ephemeris stored successfully"));
      delay(1000);
      //SD.OFF();
    }
    else
    {
      USB.println(F("Ephemeris storing failed"));
    }

    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));

    frame.addSensor(SENSOR_GPS,
                    GPS.convert2Degrees(GPS.latitude, GPS.NS_indicator),
                    GPS.convert2Degrees(GPS.longitude, GPS.EW_indicator) );

    //Add altitude [m]
    frame.addSensor(SENSOR_ALTITUDE, GPS.altitude);

    //Add speed [km/h]
    frame.addSensor(SENSOR_SPEED, GPS.speed);

    //Add course [degrees]
    frame.addSensor(SENSOR_COURSE, GPS.course);

    //    frame.addSensor(SENSOR_COURSE,GPS.EW_indicator); NEJDE!

    //Add time
    frame.addSensor(SENSOR_TIME, GPS.timeGPS);

    //Add date
    frame.addSensor(SENSOR_DATE, GPS.dateGPS);

    frame.showFrame();

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

  ////////////////////////////////////////////////////////////////
  // 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(1000);

}


//void deleteEnding()
//{
//  char empty[] = "                             ";
//  SD.writeSD(filename, empty, SD.getFileSize(filename) - strlen(ENDING) - 1);
//}
//
//
//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);
//
//}
You can easily see the differences with a text compare tool: https://www.diffchecker.com/

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

Re: GPS + Radiation board does not work together

Post by BranoV » Mon Aug 07, 2017 2:21 pm

Dear developers, many thanks for your help. I uploaded the code you suggested to me and here is the result:

Code: Select all

E#
Setting Channel CH_10_868.	 state 0
Setting Header ON.		 state 0
Setting Mode '2'.		 state 0
Setting CRC ON.			 state 0
Setting Power to 'H'.		 state 0
Setting Node Address to '2'.	 state 0

Waspmote Tracker
===============================
Current ASCII Frame:
Length: 46
Frame Type:  128
frame (HEX): 3C3D3E800223343033343539343834234E6F64655F30312330235241443A302E313336343136234241543A393223
frame (STR): <=>€#403459484#Node_01#0#RAD:0.136416#BAT:92#
===============================
Ephemeris load failed

----------------------
GPS TIMEOUT. NOT connected
----------------------
Frame Utility Example for Radiation Board
----------------------------------------
Setting configuration:
----------------------------------------
Packet sent OK

===============================
Current ASCII Frame:
Length: 46
Frame Type:  128
frame (HEX): 3C3D3E800223343033343539343834234E6F64655F30312331235241443A302E313336343136234241543A393223
frame (STR): <=>€#403459484#Node_01#1#RAD:0.136416#BAT:92#
===============================
Ephemeris load failed

----------------------
GPS TIMEOUT. NOT connected
----------------------
Frame Utility Example for Radiation Board
----------------------------------------
Setting configuration:
----------------------------------------
Packet sent OK

===============================
Current ASCII Frame:
Length: 46
Frame Type:  128
frame (HEX): 3C3D3E800223343033343539343834234E6F64655F30312332235241443A302E303937343430234241543A393223
frame (STR): <=>€#403459484#Node_01#2#RAD:0.097440#BAT:92#
===============================
Ephemeris load failed
As I have found, if the Empheris loading procedure fails, it is not possible to connect to the GPS. Therefore I made just a small change to control if Empheris was successfully stored in the previous case. If not, I am not trying to load these data. Here is the slightly modified code:

Code: Select all

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


float radiationcpm;
float radiationusv;

char node_ID[] = "Node_01";
uint8_t rx_address = 3;
int8_t e;

#define GPS_TIMEOUT 120
// variable to store running time
unsigned long previous=0;
// define status variable for GPS connection
bool status;
bool ok = 0;
// define file name: MUST be 8.3 SHORT FILE NAME
char filename[] = "track.kml";

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

void setup()
{
  USB.ON();
  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();


  // Open USB port
  //  USB.ON();
  USB.println(F("Waspmote Tracker"));
  //
  //  GPS.ON();
  //
  //  // wait for GPS signal for specific time
  //  status = GPS.waitForSignal(GPS_TIMEOUT);
  //
  //  if ( status == true )
  //  {
  //    USB.println(F("Connected"));
  //    Utils.blinkLEDs(3000);
  //  }
  //  else
  //  {
  //    USB.println(F("GPS TIMEOUT. NOT connected"));
  //  }

  delay(1000);
}

void loop()
{
  ///////////////////////////////////////////
  // 1. Turn on the board
  ///////////////////////////////////////////
  GPS.OFF();
  delay(1000);
  RadiationBoard.ON();
  delay(100);


  ///////////////////////////////////////////
  // 2. Read sensors
  ///////////////////////////////////////////


  // 2. Measure radiation during 25 s
  radiationusv = RadiationBoard.getRadiationInt(25000);


  ///////////////////////////////////////////
  // 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, radiationusv);
  frame.addSensor(SENSOR_BAT, (uint8_t) PWR.getBatteryLevel());

  // Show the frame
  frame.showFrame();



  //  SD.ON();
  delay(5000);
    previous=millis();
  GPS.ON();
  //SD.ON();
  delay(3000);

if (ok == 1)
 {
  if ( GPS.loadEphems() == 1 )
  {
    USB.println(F("Ephemeris loaded successfully"));
  }
  else
  {
    USB.println(F("Ephemeris load failed"));
  }
  delay(1000);
  //SD.OFF();
 }
else
{
    USB.println(F("Ephemeris nenacitavam"));
} 
  status = GPS.waitForSignal(GPS_TIMEOUT);

  if ( status == true )
  {
    USB.print(F("Time elapsed to connect GPS (ms): "));
    USB.println(millis()-previous,DEC);
    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 )
  {
    // store ephemeris in "EPHEM.TXT"
    if ( GPS.saveEphems() == 1 )
    {
      //SD.ON();
      delay(1000);
      USB.println(F("Ephemeris stored successfully"));
      ok = 1;
      delay(1000);
      //SD.OFF();
    }
    else
    {
      USB.println(F("Ephemeris storing failed"));
    ok = 0;
    }
    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));

    frame.addSensor(SENSOR_GPS,
                    GPS.convert2Degrees(GPS.latitude, GPS.NS_indicator),
                    GPS.convert2Degrees(GPS.longitude, GPS.EW_indicator) );

    //Add altitude [m]
    frame.addSensor(SENSOR_ALTITUDE, GPS.altitude);

    //Add speed [km/h]
    frame.addSensor(SENSOR_SPEED, GPS.speed);

    //Add course [degrees]
    frame.addSensor(SENSOR_COURSE, GPS.course);

    //    frame.addSensor(SENSOR_COURSE,GPS.EW_indicator); NEJDE!

    //Add time
    frame.addSensor(SENSOR_TIME, GPS.timeGPS);

    //Add date
    frame.addSensor(SENSOR_DATE, GPS.dateGPS);

    frame.showFrame();

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

  ////////////////////////////////////////////////////////////////
  // 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(1000);

}


//void deleteEnding()
//{
//  char empty[] = "                             ";
//  SD.writeSD(filename, empty, SD.getFileSize(filename) - strlen(ENDING) - 1);
//}
//
//
//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);
//
//}
With this small change, everything works smooth right now. I think that Empheris loading procedure should be modified to not block the GPS connectivity in case of loading failure. So finally here is the output:

Code: Select all

E#
Setting Channel CH_10_868.	 state 0
Setting Header ON.		 state 0
Setting Mode '2'.		 state 0
Setting CRC ON.			 state 0
Setting Power to 'H'.		 state 0
Setting Node Address to '2'.	 state 0

Waspmote Tracker
===============================
Current ASCII Frame:
Length: 46
Frame Type:  128
frame (HEX): 3C3D3E800223343033343539343834234E6F64655F30312330235241443A302E313336343136234241543A393123
frame (STR): <=>€#403459484#Node_01#0#RAD:0.136416#BAT:91#
===============================
Ephemeris nenacitavam
Time elapsed to connect GPS (ms): 32440

----------------------
Connected
----------------------

Ephemeris stored successfully

GET POSITION:
Time [hhmmss.sss]: 121711.831
Date [ddmmyy]: 070817
Latitude [ddmm.mmmm]: 4809.1554
North/South indicator: N
Longitude [dddmm.mmmm]: 01704.3929
East/West indicator: E
Altitude [m]: -22.2
Speed [km/h]: 0.27
Course [degrees]: 318.31

CONVERSION TO DEGREES (USEFUL FOR INTERNET SEARCH):
Latitude (degrees):48.1525917053
Longitude (degrees):17.0732154846
===============================
Current ASCII Frame:
Length: 139
Frame Type:  128
frame (HEX): 3C3D3E800823343033343539343834234E6F64655F30312330235241443A302E313336343136234241543A3931234750533A34382E3135323539323B31372E30373332313523414C543A2D32322E322353504545445F4F473A302E323723434F555253455F4F473A3331382E33312354494D453A3132313731312E38333123444154453A30373038313723
frame (STR): <=>€#403459484#Node_01#0#RAD:0.136416#BAT:91#GPS:48.152592;17.073215#ALT:-22.2#SPEED_OG:0.27#COURSE_OG:318.31#TIME:121711.831#DATE:070817#
===============================
Frame Utility Example for Radiation Board
----------------------------------------
Setting configuration:
----------------------------------------
Packet sent OK

===============================
Current ASCII Frame:
Length: 46
Frame Type:  128
frame (HEX): 3C3D3E800223343033343539343834234E6F64655F30312331235241443A302E303737393532234241543A393123
frame (STR): <=>€#403459484#Node_01#1#RAD:0.077952#BAT:91#
===============================
Ephemeris loaded successfully
Time elapsed to connect GPS (ms): 13578

----------------------
Connected
----------------------

Ephemeris stored successfully

GET POSITION:
Time [hhmmss.sss]: 121817.589
Date [ddmmyy]: 070817
Latitude [ddmm.mmmm]: 4809.1640
North/South indicator: N
Longitude [dddmm.mmmm]: 01704.3926
East/West indicator: E
Altitude [m]: -37.2
Speed [km/h]: 0.62
Course [degrees]: 192.02

CONVERSION TO DEGREES (USEFUL FOR INTERNET SEARCH):
Latitude (degrees):48.1527328491
Longitude (degrees):17.0732097625
===============================
Current ASCII Frame:
Length: 139
Frame Type:  128
frame (HEX): 3C3D3E800823343033343539343834234E6F64655F30312331235241443A302E303737393532234241543A3931234750533A34382E3135323733333B31372E30373332313023414C543A2D33372E322353504545445F4F473A302E363223434F555253455F4F473A3139322E30322354494D453A3132313831372E35383923444154453A30373038313723
frame (STR): <=>€#403459484#Node_01#1#RAD:0.077952#BAT:91#GPS:48.152733;17.073210#ALT:-37.2#SPEED_OG:0.62#COURSE_OG:192.02#TIME:121817.589#DATE:070817#
===============================
So now I think it is solved, many thanks for your help. Without you I will be lost. Thank you!

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 Aug 08, 2017 10:12 am

Hi,

We are glad to hear that you solved the issue. We will study if perform any modification in the library or examples codes to avoid this issue.

Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest