I have the RS232 shield working perfectly with UNO ,
I am having problem with the same code same pins attaching to the MEGA2560.
What would I be missing?
Here is the code
#include <SoftwareSerial.h>
#include <Wire.h>
#include <NMEA0183.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
// matches Zihatec RS422/RS485 shield
SoftwareSerial gps(2, 3);
NMEA0183 nmea;
void setup()
{
// Start Serial
while (!Serial);
Serial.begin(4800);
gps.begin(4800);
Serial.println("NMEA0183 parser test");
// Start LCD
lcd.begin();
lcd.backlight();
}
void loop()
// Reveive data from GPS
{
if (gps.available())
{
char c = gps.read();
if (nmea.update(c))
{
Serial.print("NMEA0183 sentence accepted (");
Serial.print(nmea.getFields());
Serial.print(" fields): ");
Serial.write(nmea.getSentence());
Serial.println();
// Display Data from GPS
lcd.clear();//Clean the screen
lcd.setCursor(0,0);
lcd.print(nmea.getFields());
lcd.setCursor(3,0);
lcd.print(" data received ");
lcd.setCursor(0,1);
lcd.print(nmea.getSentence());
// Receive data from load cell - to understand the max load on the line
// Receive data from AMPmeter - to understand the dc load
// Receive data from Rotation meter to calculate the revolutions of the reel
// Send and Receive commands from Bluetooth
}
}
}
Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).
You will have to find out which pins the LCD uses so as not to conflict.
thanks for the suggestions,
I have an humminbird gps in the boat , it is connected to the autopilot radar and the VHF ,
it is broadcasting 5V rs232 signals of NMEA .
I had connected several devices before without an issue.
Can i connect this +5 volt with its ground to any port without RS232 ?
Do you mean port 14 15 16 17 18 19 as hardware ports?
Yes, those pins are the extra hardware serial ports.
it is broadcasting 5V rs232 signals of NMEA .
If the output of the GPS is 5V TTL serial you do not need the RS232 shield for that. 5V TTL signals can be connected directly to one of the extra hardware serial ports, GPS TX to Serial port RX. The GPS RX to Serial port TX is only required if you will be changing GPS configuration settings form your code.
I have the shield out , bought a simple rs232toTTL with GND-TX-RX-VCC ,
connected the RX to TX3-14 Pin and TX to RX3-15 pin
with MEGA I am missing something ,no sign of receiving data?????
#include <Wire.h>
#include <NMEA0183.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
// matches Zihatec RS422/RS485 shield
SoftwareSerial gps(15, 14); // RX, TX
NMEA0183 nmea;
void setup()
{
// Start Serial
while (!Serial);
Serial.begin(4800);
gps.begin(4800);
Serial.println("NMEA0183 parser test");
// Start LCD
lcd.begin();
lcd.backlight();
}
void loop()
// Reveive data from GPS
{
lcd.clear();//Clean the screen
lcd.setCursor(0,0);
lcd.print(" no data received ");
if (gps.available())
{
char c = gps.read();
if (nmea.update(c))
{
Serial.print("NMEA0183 sentence accepted (");
Serial.print(nmea.getFields());
Serial.print(" fields): ");
Serial.write(nmea.getSentence());
Serial.println();
// Display Data from GPS
lcd.clear();//Clean the screen
lcd.setCursor(0,0);
lcd.print(nmea.getFields());
lcd.setCursor(3,0);
lcd.print(" data received ");
lcd.setCursor(0,1);
lcd.print(nmea.getSentence());
// Receive data from load cell - to understand the max load on the line
// Receive data from AMPmeter - to understand the dc load
// Receive data from Rotation meter to calculate the revolutions of the reel
// Send and Receive commands from Bluetooth
}
}
}
groundFungus:
Yes, those pins are the extra hardware serial ports.
If the output of the GPS is 5V TTL serial you do not need the RS232 shield for that. 5V TTL signals can be connected directly to one of the extra hardware serial ports, GPS TX to Serial port RX. The GPS RX to Serial port TX is only required if you will be changing GPS configuration settings form your code.
Finally solved, I have no idea what what the problem but gave from software serial and used "AltSoftSerial".
It was perfectly working, finally finished my first task. below I am sharing the code.
#include <AltSoftSerial.h>
#include <Wire.h>
#include <NMEA0183.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
// matches Zihatec RS422/RS485 shield
AltSoftSerial gps;
NMEA0183 nmea;
void setup() {
Serial.begin(4800);
gps.begin(4800);
Serial.println("AltSoftSerial Test Begin");
// Start Serial
while (!Serial);
Serial.println("NMEA0183 parser test");
// Start LCD
lcd.begin();
lcd.backlight();
}
void loop()
// Reveive data from GPS
{
lcd.setCursor(0,0);
if (gps.available())
{
char c = gps.read();
if (nmea.update(c))
{
Serial.print("NMEA0183 sentence accepted (");
Serial.print(nmea.getFields());
Serial.print(" fields): ");
Serial.write(nmea.getSentence());
Serial.println();
// Display Data from GPS
lcd.clear();//Clean the screen
lcd.setCursor(0,0);
lcd.print(nmea.getFields());
lcd.setCursor(3,0);
lcd.print(" data received ");
lcd.setCursor(0,1);
lcd.print(nmea.getSentence());
// Receive data from load cell - to understand the max load on the line
// Receive data from AMPmeter - to understand the dc load
// Receive data from Rotation meter to calculate the revolutions of the reel
// Send and Receive commands from Bluetooth
}
}
}