Serial connection on UNO without any software serial?

Hey there,

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...

Thanks in advance

It will work for you if you disconnect the USB cable going to your PC.

Paul

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.

...R

Paul_KD7HB:
It will work for you if you disconnect the USB cable going to your PC.

Paul

Well I have forgotten to mention that I already did that and it didnt work...

Robin2:
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!

karnschi1:

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.

...R

This will help.

Robin2:
That does not make sense to me.

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

-dev:
This will help.

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?

karnschi1:
Is that a little more understandable as I have to admit that my former explaination is a little confusing

A little, but still not sufficient.

Am I correct to think that this is what you want to do ...

  • The Arduino will NOT be connected to your PC using USB
  • Connect your Arduino to a RaspberryPi using I2C
  • Connect the Arduino to a GPS using HardwareSerial
  • Collect GPS data on the Arduino and send it to the RPi.

That should be perfectly feasible.

If I am wrong (very possible) please provide the correct description.

...R

Robin2:
If I am wrong (very possible) please provide the correct description.

yes now you got it
but by the time I have found my mistake and it works as I wanted it to do

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.