Hi all.
Having failed with my previous post, I have decided to start a fresh from the beginning, as with the amount of replies Info sketches and ebook's I was reading, I was only getting more and more confused. Thank you for all of your Input.
With starting again I first tested the radios with a test sketch, TMRh20's random numbers to check they both work.
All works fine.
I have a few questions I would like to ask before I go any further with the code, but will ask one at a time.
static const int RXPin =10, TXPin =11; //gps channels
const uint64_t pipe = 0xF0F0F0F0E1LL; //radio channel
static const uint32_t GPSBaud = 9600; //gps baud rate/quote]
Can I do this? A static const + a const and a static const int? I also thought that the int should be a char and only for the RXPin =10?
Please, don't forget I'm a newbie and trying to learn, mostly from mistakes.Dizzwold
TX
#include <SPI.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include "nRF24L01.h"
#include "RF24.h"
static const int RXPin =10, TXPin =11; //gps channels
const uint64_t pipe = 0xF0F0F0F0E1LL; //radio channel
static const uint32_t GPSBaud = 9600; //gps baud rate
TinyGPSPlus gps;
RF24 radio(49,53); //radio pins on mega 2560
SoftwareSerial ss(RXPin, TXPin); //software serial pins a above to 10,11
unsigned long startTime = millis();
unsigned long updateInterval = 5000UL; //send gps coordinates every 5 seconds
void setup(void) {
Serial.begin(115200); //view in serial monitor
ss.begin(GPSBaud);
radio.begin();
//radio.setRetries(15,15);
radio.openWritingPipe(pipe);
Serial.println();
Serial.println("Dizzwold's GPS.");
}
void loop () {
unsigned int random_Number = random(0,255); //ignore the random numbers part of the code for now
Serial.print("Sending: ");
Serial.println(random_Number);
while (ss.available() > 0)
if (gps.encode(ss.read()))
if (millis() > 5000 && gps.charsProcessed() < 10)
Serial.println(F("No GPS detected: check wiring."));
radio.stopListening();
boolean ok = radio.write( &random_Number, sizeof(random_Number) );
if (ok) Serial.println("ok...");
else Serial.print(F("INVALID"));
delay(1000);
}
/code]