"Int" and "Array[]"

I am trying to create a program that will read a 2.4ghz transmission from another Arduino unit that contains data from a GPS module stored in an array called DATA[3].

The transmitter code seems alright, or at least it compiles successfully. I haven't been able to test it yet because I keep getting errors in the code for the receiver.

This is a copy of the error screen:

In file included from C:\Users\DrMesa\Documents\Arduino\libraries\LiquidCrystal/LiquidCrystal_I2C.h:35:0,
from GPS_to_LCD_Receiver.ino:8:
C:\Users\DrMesa\Documents\Arduino\libraries\LiquidCrystal/LCD.h:133:33: error: expected unqualified-id before numeric constant
#define DATA 1
^
GPS_to_LCD_Receiver.ino:23:5: note: in expansion of macro 'DATA'
GPS_to_LCD_Receiver.ino: In function 'void loop()':
GPS_to_LCD_Receiver.ino:54:43: error: invalid conversion from 'int' to 'void*' [-fpermissive]
In file included from GPS_to_LCD_Receiver.ino:4:0:
C:\Users\DrMesa\Documents\Arduino\libraries\RF24/RF24.h:304:8: error: initializing argument 1 of 'bool RF24::read(void*, uint8_t)' [-fpermissive]
bool read( void* buf, uint8_t len );
^
GPS_to_LCD_Receiver.ino:56:11: error: invalid types 'int[int]' for array subscript
GPS_to_LCD_Receiver.ino:57:11: error: invalid types 'int[int]' for array subscript
GPS_to_LCD_Receiver.ino:58:11: error: invalid types 'int[int]' for array subscript
GPS_to_LCD_Receiver.ino:59:11: error: invalid types 'int[int]' for array subscript
Error compiling

Not sure why these errors are coming up, I don't know enough about programming to fix them myself.

Any ideas?

GPS_to_LCD_Receiver.ino (1.84 KB)

The errors are telling you that the LCD library already defines the name DATA which is causing confusion with your use of the same name.
Change all occurrences of DATA in your code to my_DATA.

Pete

Wow, that fixed everything immediately! I guess I was on the right track with the code, I just didn't realize that "DATA" was already used in that library.

THANKS!

If I could pick your brain again...

My transmitter code doesn't seem to be working and/or my receiver code isn't picking it up.

I'm getting, "No Radio Available" on the LCD readout, which is what it will read if there is no data.

I have confirmed via the serial monitor that the transmitter is collecting data from the GPS module, but I can't confirm if its actually broadcasting anything...

There are no compiling errors with either programs and I have double checked ALL hardware connections.

GPS_to_LCD_Transmitter.ino (5.33 KB)

GPS_to_LCD_Receiver.ino (1.75 KB)

arrays of size = 3 have three elements:

int MY_DATA[3];
MY_DATA[0]
MY_DATA[1]
MY_DATA[2]

Increased Array Size to 4, still no change.

Can you see any issues with the transmission/receiving aspects of the program?

This program is based on a similar program for transmitting Servo positions via wireless modules.

http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo

were you able to get the basic demo to communicate?

post your code, a lot of folks won't bother downloading...

Yes, I have used the demo code on numerous occasions without fail, but when I try to transmit this data it won't go.

Transmitter:

/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include <Wire.h>

SoftwareSerial mySerial(6, 7); // RX, TX
//Attach 20x4 LCD to Analog 4,5 "SDA,SCL"

TinyGPS gps;

void gpsdump(TinyGPS &gps);
float printFloat(double f, int digits = 2);
float mph;
float alt;
long lat, lon;
float flat, flon;
unsigned long age, date, time, chars;
byte month, day, hour, minute, second, hundredths;
int level;
int year;


/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   9
#define CSN_PIN 10


// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe


/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/

int GPSDATA[4];  // 2 element array holding Joystick readings
int MY_DATA[4];


void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);
  
  mySerial.begin(9600);
  
  radio.begin();
  radio.openWritingPipe(pipe);
  
  
}

void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  
  bool newdata = false;
  unsigned long start = millis();

  // Every 5 seconds we print an update
  while (millis() - start < 5000) {
    if (mySerial.available()) {
      char c = mySerial.read();
      //Serial.print(c);  // uncomment to see raw GPS data
      if (gps.encode(c)) {
        newdata = true;
         break;  // uncomment to print new data immediately!
      }
    }
  }
  
  if (newdata) {
    Serial.println("Acquired Data");
    Serial.println("-------------");
    gpsdump(gps);
    Serial.println("-------------");
    Serial.println();
  }
  
  GPSDATA[0] = MY_DATA[0];
  MY_DATA[0] = sizeof(mph);
  
  GPSDATA[1] = MY_DATA[1];
  MY_DATA[1] = sizeof(alt);  

  GPSDATA[2] = MY_DATA[2];
  MY_DATA[2] = sizeof(flon);

  GPSDATA[3] = MY_DATA[3];
  MY_DATA[3] = sizeof(flat);
  
  
  radio.write(MY_DATA, sizeof(MY_DATA));
  
  
}//--(end main loop )---



void gpsdump(TinyGPS &gps)
{
  //long lat, lon;
  //float flat, flon;
  //unsigned long age, date, time, chars;
  //int year;
  //byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;

  gps.get_position(&lat, &lon, &age);
  Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon); 
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");
  
  //   On Arduino, GPS characters may be lost during lengthy Serial.print()
  //   On Teensy, Serial prints to USB, which has large output buffering and
  //   runs very fast, so it's not necessary to worry about missing 4800
  //   baud GPS characters.

  gps.f_get_position(&flat, &flon, &age);
  Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.get_datetime(&date, &time, &age);
  Serial.print("Date(ddmmyy): "); Serial.print(date); Serial.print(" Time(hhmmsscc): ");
    Serial.print(time);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  Serial.print("Date: "); Serial.print(static_cast<int>(month)); Serial.print("/"); 
    Serial.print(static_cast<int>(day)); Serial.print("/"); Serial.print(year);
  Serial.print("  Time: "); Serial.print(static_cast<int>(hour)); Serial.print(":"); 
    Serial.print(static_cast<int>(minute)); Serial.print(":"); Serial.print(static_cast<int>(second));
    Serial.print("."); Serial.print(static_cast<int>(hundredths));
  Serial.print("  Fix age: ");  Serial.print(age); Serial.println("ms.");

  Serial.print("Alt(cm): "); Serial.print(gps.altitude()); Serial.print(" Course(10^-2 deg): ");
    Serial.print(gps.course()); Serial.print(" Speed(10^-2 knots): "); Serial.println(gps.speed());
  Serial.print("Alt(float): "); printFloat(gps.f_altitude()); Serial.print(" Course(float): ");
    printFloat(gps.f_course()); Serial.println();
  Serial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); Serial.print(" (mph): ");
    printFloat(gps.f_speed_mph());
  Serial.print(" (mps): "); printFloat(gps.f_speed_mps()); Serial.print(" (kmph): ");
    printFloat(gps.f_speed_kmph()); Serial.println();
    
    mph=printFloat(gps.f_speed_mph());
    alt=printFloat(gps.f_altitude());
    

  gps.stats(&chars, &sentences, &failed);
  Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: ");
    Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed);
}

float printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0) {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 

  // Extract digits from the remainder one at a time
  while (digits-- > 0) {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint;
  }
}

Receiver:

/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#include <Wire.h>

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);


/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   9
#define CSN_PIN 10

// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe


/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int MY_DATA[4]; 

void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);
  
  lcd.begin(20, 4);   // start the library 
  
  delay(1000);
  Serial.println("Nrf24L01 Receiver Starting");
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();;
  
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  if ( radio.available() )
  {
    // Read the data payload until we've received everything
    bool done = false;
    while (!done)
  {
    // Fetch the data payload
    done = radio.read( MY_DATA, sizeof(MY_DATA) );

    lcd.setCursor(11,2);
    lcd.print("Speed");
    lcd.setCursor(12,3);
    
    lcd.print(MY_DATA[0]);
    
    lcd.setCursor(17,3);
    lcd.print("MPH");
  
    lcd.setCursor(0,2);            
    lcd.print("Altitude"); 
    lcd.setCursor(2,3); 
    
    lcd.print(MY_DATA[1],4);
    
    lcd.setCursor(9,3);
    lcd.print("m");
  
    lcd.setCursor(0,0);            
    lcd.print("Long ");
    
    lcd.print(MY_DATA[2],6);
    
    lcd.setCursor(0,1);            
    lcd.print("Lat ");
    lcd.setCursor(6,1);
    
    lcd.print(MY_DATA[3],6);  
    
    
  }
  }
  else
  {    
      lcd.println("No radio available");
  }

}//--(end main loop )---

You don't seem to be storing any data in MY_DATA in the transmitter code so if it transmits at all it will be sending null bytes.
You haven't set a payload size for the transmission and reception. You are sending a fixed number of bytes anyway so it might work better if you do that. In both sketches, before opening the pipe, add this:

radio.setPayloadSize(sizeof(MY_DATA));

Pete

int GPSDATA[4];  // 2 element array holding Joystick readings

What a stupid comment.

I don't understand why MY_DATA[0] would always equal 4. When I had this setup on one unit and was transmitting data from the GPS module to the LCD screen I could get the values of "mph" to show up.

It pulls the "mph" values from a mathematical translation from the strings of raw data coming out of the GPS module. I'm not 100% sure how that happens but was described in the code example for the GPS module.

I am wanting to store whatever value "mph" has at that particular moment and send it to the receiver. I tried, and apparently failed, to mimic the structure of the original code examples from both programs and Frankenstein them together to suit my needs.

I am open to any better suggestions to achieve this. Like I said in the beginning, I'm not good at programming.

As for that comment "2 element array holding Joystick readings" that was just leftover from the example program and I didn't delete it. I suppose it would be a 4 element array at this point...

I suppose it would be a 4 element array at this point...

How the heck would anyone assume that a variable called GPSDATA is where joystick data is stored?

If this ever worked, the code was different.

GPSDATA[0] = MY_DATA[0];
MY_DATA[0] = sizeof(mph);

GPSDATA[1] = MY_DATA[1];
MY_DATA[1] = sizeof(alt);

GPSDATA[2] = MY_DATA[2];
MY_DATA[2] = sizeof(flon);

GPSDATA[3] = MY_DATA[3];
MY_DATA[3] = sizeof(flat);

And then you send MY_DATA via RF.

So MY_DATA is a 4 element array. First element is set to sizeof(mph). mph is a variable of type float, so sizeof(mph) is 4, since a float is 4 bytes in size. Hence MY_DATA[0] is 4. Same goes for the other three elements.

Nowhere are you actually sending mph, or alt, or flat or flon. You're just sending the size of the variables, which is 4 for all four of the variables in question.

I've changed up the code a little and added a part to print the values stored in the array MY_DATA.

I'm getting values out in the serial monitor on the transmitter, but still nothing is coming up on the receiver screen.

I also removed the GPSDATA array, it seemed redundant.

Any idea why the reciever is still only showing "No Radio Available"

The updated Transmitter Program:

/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include <Wire.h>

SoftwareSerial mySerial(6, 7); // RX, TX
//Attach 20x4 LCD to Analog 4,5 "SDA,SCL"

TinyGPS gps;

void gpsdump(TinyGPS &gps);
float printFloat(double f, int digits = 2);
float mph;
float alt;
long lat, lon;
float flat, flon;
unsigned long age, date, time, chars;
byte month, day, hour, minute, second, hundredths;
int level;
int year;


/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   9
#define CSN_PIN 10


// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe


/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/

int MY_DATA[4];


void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);
  
  mySerial.begin(9600);
  
  radio.begin();
  radio.setPayloadSize(sizeof(MY_DATA));
  radio.openWritingPipe(pipe);
  
  
}

void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  
  bool newdata = false;
  unsigned long start = millis();

  // Every 5 seconds we print an update
  while (millis() - start < 5000) {
    if (mySerial.available()) {
      char c = mySerial.read();
      //Serial.print(c);  // uncomment to see raw GPS data
      if (gps.encode(c)) {
        newdata = true;
         break;  // uncomment to print new data immediately!
      }
    }
  }
  
  if (newdata) {
    Serial.println("Acquired Data");
    Serial.println("-------------");
    gpsdump(gps);
    Serial.println("-------------");
    Serial.println();
  }
  
  MY_DATA[0] = mph;
  MY_DATA[1] = alt;  
  MY_DATA[2] = flon;
  MY_DATA[3] = flat;
  
  Serial.println(mph);
  Serial.println(alt);
  Serial.println(flon);
  Serial.println(flat);
  
    
  radio.write(MY_DATA, sizeof(MY_DATA));
  
  
}//--(end main loop )---



void gpsdump(TinyGPS &gps)
{
  //long lat, lon;
  //float flat, flon;
  //unsigned long age, date, time, chars;
  //int year;
  //byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;

  gps.get_position(&lat, &lon, &age);
  Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon); 
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");
  
  //   On Arduino, GPS characters may be lost during lengthy Serial.print()
  //   On Teensy, Serial prints to USB, which has large output buffering and
  //   runs very fast, so it's not necessary to worry about missing 4800
  //   baud GPS characters.

  gps.f_get_position(&flat, &flon, &age);
  Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.get_datetime(&date, &time, &age);
  Serial.print("Date(ddmmyy): "); Serial.print(date); Serial.print(" Time(hhmmsscc): ");
    Serial.print(time);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  Serial.print("Date: "); Serial.print(static_cast<int>(month)); Serial.print("/"); 
    Serial.print(static_cast<int>(day)); Serial.print("/"); Serial.print(year);
  Serial.print("  Time: "); Serial.print(static_cast<int>(hour)); Serial.print(":"); 
    Serial.print(static_cast<int>(minute)); Serial.print(":"); Serial.print(static_cast<int>(second));
    Serial.print("."); Serial.print(static_cast<int>(hundredths));
  Serial.print("  Fix age: ");  Serial.print(age); Serial.println("ms.");

  Serial.print("Alt(cm): "); Serial.print(gps.altitude()); Serial.print(" Course(10^-2 deg): ");
    Serial.print(gps.course()); Serial.print(" Speed(10^-2 knots): "); Serial.println(gps.speed());
  Serial.print("Alt(float): "); printFloat(gps.f_altitude()); Serial.print(" Course(float): ");
    printFloat(gps.f_course()); Serial.println();
  Serial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); Serial.print(" (mph): ");
    printFloat(gps.f_speed_mph());
  Serial.print(" (mps): "); printFloat(gps.f_speed_mps()); Serial.print(" (kmph): ");
    printFloat(gps.f_speed_kmph()); Serial.println();
    
    mph=printFloat(gps.f_speed_mph());
    alt=printFloat(gps.f_altitude());
    

  gps.stats(&chars, &sentences, &failed);
  Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: ");
    Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed);
}

float printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0) {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 

  // Extract digits from the remainder one at a time
  while (digits-- > 0) {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint;
  }
}

The Receiver Program:

/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#include <Wire.h>

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);


/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   9
#define CSN_PIN 10

// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe


/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int MY_DATA[4]; 

void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);
  
  lcd.begin(20, 4);   // start the library 
  
  delay(1000);
  Serial.println("Nrf24L01 Receiver Starting");
  radio.begin();
  radio.setPayloadSize(sizeof(MY_DATA));
  radio.openReadingPipe(1,pipe);
  radio.startListening();;
  
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  if ( radio.available() )
  {
    // Read the data payload until we've received everything
    bool done = false;
    while (!done)
  {
    // Fetch the data payload
    done = radio.read( MY_DATA, sizeof(MY_DATA) );

    lcd.setCursor(11,2);
    lcd.print("Speed");
    lcd.setCursor(12,3);
    
    lcd.print(MY_DATA[0]);
    
    lcd.setCursor(17,3);
    lcd.print("MPH");
  
    lcd.setCursor(0,2);            
    lcd.print("Altitude"); 
    lcd.setCursor(2,3); 
    
    lcd.print(MY_DATA[1],4);
    
    lcd.setCursor(9,3);
    lcd.print("m");
  
    lcd.setCursor(0,0);            
    lcd.print("Long ");
    
    lcd.print(MY_DATA[2],6);
    
    lcd.setCursor(0,1);            
    lcd.print("Lat ");
    lcd.setCursor(6,1);
    
    lcd.print(MY_DATA[3],6);  
    
    
  }
  }
  else
  {    
      lcd.println("No radio available");
  }

}//--(end main loop )---

A float is 4 bytes. You have to break it into the 4 individual bytes and send them.

No, you don't.

float myData[4] = { mph, alt, flon, flat };
  radio.write(myData, sizeof(myData));

will send all 16 bytes of the array.

I made that change you suggested PaulS, but it didn't seem to work. However there is a new development, for the first time I actually got something on the LCD other than "No Radio Available".

It printed some nonsense values (like Speed 253444 MPH) along with the units of measure and variable descriptions in the first part of the IF/ELSE statement on the receiver code. It only printed them once and then resumed its "No Radio Available" phase again, but the values remained on the screen because they weren't cleared or anything.

I suppose its a step in the right direction?

This is what the Serial Monitor reads when the Transmitter is hooked up to the PC:

Acquired Data

Lat/Long(10^-5 deg): 3774353, -8705312 Fix age: 47ms.
Lat/Long(float): 37.74353, -87.05313 Fix age: 66ms.
Date(ddmmyy): 140116 Time(hhmmsscc): 23420000 Fix age: 138ms.
Date: 1/14/2016 Time: 23:42:0.0 Fix age: 203ms.
Alt(cm): 14310 Course(10^-2 deg): 0 Speed(10^-2 knots): 4
Alt(float): 143.10 Course(float): 0.00
Speed(knots): 0.04 (mph): 0.05 (mps): 0.02 (kmph): 0.07
0.05143.10Stats: characters: 927 sentences: 4 failed checksum: 3

0.10
0.50
-87.05
37.74

The 4 Values at the very bottom are the result of my little "verification code" I added to see what those variables where reading at the time.

Serial.println(mph);
  Serial.println(alt);
  Serial.println(flon);
  Serial.println(flat);

Is there a way to transmit a large number of decimals? You can see that Latitude is "37.74353". Can't I just send THAT number somehow?

New Code:
Transmitter:

/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include <Wire.h>

SoftwareSerial mySerial(6, 7); // RX, TX
//Attach 20x4 LCD to Analog 4,5 "SDA,SCL"

TinyGPS gps;

void gpsdump(TinyGPS &gps);
float printFloat(double f, int digits = 2);
float mph;
float alt;
long lat, lon;
float flat, flon;
unsigned long age, date, time, chars;
byte month, day, hour, minute, second, hundredths;
int level;
int year;

/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   9
#define CSN_PIN 10

// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe

/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/

float my_data[4] = { mph, alt, flon, flat };


void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);
  
  mySerial.begin(9600);
  
  radio.begin();

  radio.openWritingPipe(pipe);
}

void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  
  bool newdata = false;
  unsigned long start = millis();

  // Every 5 seconds we print an update
  while (millis() - start < 5000) {
    if (mySerial.available()) {
      char c = mySerial.read();
      //Serial.print(c);  // uncomment to see raw GPS data
      if (gps.encode(c)) {
        newdata = true;
         break;  // uncomment to print new data immediately!
      }
    }
  }
  
  if (newdata) {
    Serial.println("Acquired Data");
    Serial.println("-------------");
    gpsdump(gps);
    Serial.println("-------------");
    Serial.println();
    
  my_data[0] = mph;
  my_data[1] = alt;  
  my_data[2] = flon;
  my_data[3] = flat;
  
  Serial.println(mph);
  Serial.println(alt);
  Serial.println(flon);
  Serial.println(flat);
  Serial.println();
  Serial.println(my_data[0]);
  Serial.println(my_data[1]);
  Serial.println(my_data[2]);
  Serial.println(my_data[3]);
  
  radio.write(my_data, sizeof(my_data));

  }
  
}//--(end main loop )---

void gpsdump(TinyGPS &gps)
{
  //long lat, lon;
  //float flat, flon;
  //unsigned long age, date, time, chars;
  //int year;
  //byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;

  gps.get_position(&lat, &lon, &age);
  Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon); 
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");
  
  //   On Arduino, GPS characters may be lost during lengthy Serial.print()
  //   On Teensy, Serial prints to USB, which has large output buffering and
  //   runs very fast, so it's not necessary to worry about missing 4800
  //   baud GPS characters.

  gps.f_get_position(&flat, &flon, &age);
  Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.get_datetime(&date, &time, &age);
  Serial.print("Date(ddmmyy): "); Serial.print(date); Serial.print(" Time(hhmmsscc): ");
    Serial.print(time);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  Serial.print("Date: "); Serial.print(static_cast<int>(month)); Serial.print("/"); 
    Serial.print(static_cast<int>(day)); Serial.print("/"); Serial.print(year);
  Serial.print("  Time: "); Serial.print(static_cast<int>(hour)); Serial.print(":"); 
    Serial.print(static_cast<int>(minute)); Serial.print(":"); Serial.print(static_cast<int>(second));
    Serial.print("."); Serial.print(static_cast<int>(hundredths));
  Serial.print("  Fix age: ");  Serial.print(age); Serial.println("ms.");

  Serial.print("Alt(cm): "); Serial.print(gps.altitude()); Serial.print(" Course(10^-2 deg): ");
    Serial.print(gps.course()); Serial.print(" Speed(10^-2 knots): "); Serial.println(gps.speed());
  Serial.print("Alt(float): "); printFloat(gps.f_altitude()); Serial.print(" Course(float): ");
    printFloat(gps.f_course()); Serial.println();
  Serial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); Serial.print(" (mph): ");
    printFloat(gps.f_speed_mph());
  Serial.print(" (mps): "); printFloat(gps.f_speed_mps()); Serial.print(" (kmph): ");
    printFloat(gps.f_speed_kmph()); Serial.println();
    
    mph=printFloat(gps.f_speed_mph());
    alt=printFloat(gps.f_altitude());

  gps.stats(&chars, &sentences, &failed);
  Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: ");
    Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed);
}

float printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0) {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 

  // Extract digits from the remainder one at a time
  while (digits-- > 0) {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint;
  }
}
float my_data[4] = { mph, alt, flon, flat };

There is NO reason for this to be global. It was NOT in my example.

I don't know what you mean by "Global" PaulS. Did you not want me to try to use it the way I did?

How would I "cast the float pointer to a byte pointer" and why would that help Delta_G?

Global is declared outside a function. Local is inside a function.