hi, i have a question regarding nrf24. i want to send gps location through one ardunio to otherone using nrf24. but its not working because of "uint8_t data[] = " ";". its only allow me to send only string. is that possible i cant send a function like uint8_t data[] = tinyGPS.location.lat();
#include <TinyGPS++.h> // Include the TinyGPS++ library
TinyGPSPlus tinyGPS; // Create a TinyGPSPlus object
#include <SoftwareSerial.h>
SoftwareSerial ssGPS(2, 3); // Create a SoftwareSerial
#define SerialMonitor Serial
#include <SPI.h>
#include <RH_NRF24.h>
//const int trigPin = 7;
//const int echoPin = 9;
RH_NRF24 nrf24;
void setup()
{
SerialMonitor.begin(9600);
ssGPS.begin(9600);
Serial.begin(9600);
while (!Serial)
; // wait for serial port to connect. Needed for Leonardo only
if (!nrf24.init())
Serial.println("init failed");
// Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!nrf24.setChannel(1))
Serial.println("setChannel failed");
if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
Serial.println("setRF failed");
//pinMode(trigPin, OUTPUT);
//pinMode(echoPin, INPUT);
// "Smart delay" looks for GPS data while the Arduino's not doing anything else
smartDelay(100);
}
void loop()
{
printGPSInfo();
// Send a message to nrf24_server
uint8_t data[] = "gg";
nrf24.send(data, sizeof(data));
delay(200);
}
void printGPSInfo()
{
// Print latitude, longitude, altitude in feet, course, speed, date, time,
// and the number of visible satellites.
SerialMonitor.print("Lat: "); SerialMonitor.println(tinyGPS.location.lat(), 6);
SerialMonitor.print("Long: "); SerialMonitor.println(tinyGPS.location.lng(), 6);
SerialMonitor.print("Speed: "); SerialMonitor.println(tinyGPS.speed.kmph());
SerialMonitor.print("Date: "); printDate();
SerialMonitor.print("Time: "); printTime();
SerialMonitor.println();
}
// This custom version of delay() ensures that the tinyGPS object
// is being "fed". From the TinyGPS++ examples.
static void smartDelay(unsigned long ms)
{
unsigned long start = millis();
do
{
// If data has come in from the GPS module
while (ssGPS.available())
tinyGPS.encode(ssGPS.read()); // Send it to the encode function
// tinyGPS.encode(char) continues to "load" the tinGPS object with new
// data coming in from the GPS module. As full NMEA strings begin to come in
// the tinyGPS library will be able to start parsing them for pertinent info
} while (millis() - start < ms);
}
// printDate() formats the date into dd/mm/yy.
void printDate()
{
SerialMonitor.print(tinyGPS.date.day());
SerialMonitor.print("/");
SerialMonitor.print(tinyGPS.date.month());
SerialMonitor.print("/");
SerialMonitor.println(tinyGPS.date.year());
}
// printTime() formats the time into "hh:mm:ss", and prints leading 0's
// where they're called for.
void printTime()
{
SerialMonitor.print(tinyGPS.time.hour());
SerialMonitor.print(":");
if (tinyGPS.time.minute() < 10) SerialMonitor.print('0');
SerialMonitor.print(tinyGPS.time.minute());
SerialMonitor.print(":");
if (tinyGPS.time.second() < 10) SerialMonitor.print('0');
SerialMonitor.println(tinyGPS.time.second());
}