Dear members,
I have some problems in my RF-GPS-Display project and I sincerely need help. I would like to show the GPS time message in a display and transmit a receiving message indicator using a 433 MHz RF module to a receiver. I divided my code in two parts (GPS-Display and RF-transmission) for test purposes. Uploading separately the sketchs they work fine, but when I put them to work together the problems arise. Simply, nothing is shown on the display and nothing is received by the RF-receiver. Below it is possible to see the complete code. In advance thank you for help me!
#include <TinyGPS.h>
#include <VirtualWire.h>
#include <LiquidCrystal.h>
#include <NewSoftSerial.h>
const int ledPin = 8;
const int transmit_pin = 10;
//Define the pins and baud rates
#define RX 7 //RX signal
#define TX 6 //TX signal
#define GPSBAUD 4800
LiquidCrystal lcd( 12, 11, 5, 4, 3, 2 );
// Create an instance of the TinyGPS object
TinyGPS gps;
NewSoftSerial uart_gps(RX, TX);
void getgps(TinyGPS &gps);
void setup()
{
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
uart_gps.begin(GPSBAUD);
vw_set_tx_pin(transmit_pin) ;
vw_setup(2000);
lcd.begin(20, 2);
}
void getgps(TinyGPS &gps)
// The getgps function will display the required data on the LCD
{
int year;
byte month, day, hour, minute, seconde, hundredths;
//decode and display position data
gps.crack_datetime(&year,&month,&day,&hour,&minute,&seconde,&hundredths);
lcd.setCursor(0,0);
if(hour+2<10) {lcd.print('0');}
lcd.print((hour+2), DEC); lcd.print(":");
if(minute<10) {lcd.print('0');}
lcd.print(minute, DEC);lcd.print(":");
if(seconde<10) {lcd.print('0');}
lcd.print(seconde, DEC);lcd.print(" ");
if(day<10) {lcd.print('0');}
lcd.print(day, DEC);lcd.print("/");
if(month<10) {lcd.print('0');}
lcd.print(month, DEC);lcd.print("/");lcd.print(year, DEC);
lcd.setCursor(0, 1);
delay(10);
send("time message received");
}
void send (char *message)
{
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx(); // Wait until the whole message is gone
}
void loop()
{
if(uart_gps.available())
{
digitalWrite(ledPin, HIGH);
int a = uart_gps.read(); // get the byte of data
if(gps.encode(a)) // if there is valid GPS data...
{
getgps(gps); // grab the data and display it on the LCD
}
}
}