I am trying to use the serial port on my UNO without using any form of software serial solution.
The problem with the software solutions is there they seem to cause problems with my other sort of code using interrupts and also Wire.h for I2C communication.
As I understood it the pins 0 and 1 are connected to the serial port but if I connect my GPS module it seems that no data can be received from the UNO. I know that my GPS module is working because I tried it while using a SoftwareSerial and it worked... Also I can observe my received data by sending it via I2C so I see that nothing is read on the serial port.
My code is just like the standard code:
char inByte;
void setup{
Serial.begin(9600);
}
void loop{
if (Serial.available()) {
inByte = Serial.read();
doSomething(); // Part that does something with the receive data
}
}
Can somebody explain why I am not able to read data from the pins 0 and 1? Btw the uno reacts as expected if I send some data with the Serial Monitor...
You can't use a serial port for two things at the same time - such as the Serial Monitor and the GPS,
There are alternatives to the standard SoftwareSerial such as neoSWserial and altSoftSerial which may work.
And if you are prepared for a bit of effort my Yet Another Software Serial may be of interest. It uses Timer2, works at 9600 baud and requires certain I/O pins.
Or use a Mega or Leonardo or Micro which have spare HardwareSerial ports.
You can't use a serial port for two things at the same time - such as the Serial Monitor and the GPS
What I meant was that I have tested my I2C with the Serial Monitor so that I know if the rest of my code works and it does but thanks for your input!
That does not make sense to me.
In your Original Post you said
As I understood it the pins 0 and 1 are connected to the serial port but if I connect my GPS module it seems that no data can be received from the UNO.
ok how do I put this...
I disconnected my gps module from the uno and sent the data, which would has been sent by the gps module, with the serial monitor from my PC while being connected with USB. Then I processed the data and read it out over the I2C bus on my raspberry pi
As I would guess the behaviour should be the same weather the data is sent my PC connected with USB or the connected GPS module while USB is disconnected.
When I change from the hardware serial port on the pins 0 and 1 to any other pins working with SoftwareSerial the data will be processed correctly when the gps module is connected but not when it is connected to the original serial pins 0 and 1.
Is that a little more understandable as I have to admit that my former explaination is a little confusing
Yeah I thought that you would send me to your software serial solution...
But the point is that I want to have it working without any software solution when there is still a serial port that should work as I want it to do...
I came across your solution while searching online and in this forum but I want to use the pins 0 and 1 and the provided hardware serial port you know?
Yeah I thought that you would send me to your software serial solution...
I was pointing you to HardwareSerial choice (BEST), not a software serial solution.
I came across your solution while searching online and in this forum but I want to use the pins 0 and 1 and the provided hardware serial port you know?
Yes, just use pins 0 and 1 for the GPS device. Read bytes from Serial and pass them to the GPS parser. For NeoGPS,
void setup()
{
Serial.begin( 9600 ); // GPS Connection
}
void loop()
{
if (gps.available( Serial )) {
fix = gps.read();
// An I2C read from the RPi can use the values in the fix structure.