I am having quite a strange issue. Hardware serial through USB works without any problems, however when I connect with the D0/RX port I don't receive any data.
My test setup
I have connected a NEO6M GPS module to my hardware RX port on an Arduino nano clone (WAVGAT nano). The NEO6M GPS module is also connected to 5V Perhaps the problem is that it is a clone board. However, since the hardware serial does work through USB, I can't imagine that being the issue. (If it is, could you tell me why?) (I guess I was wrong)
here is an image of the clone board circuit if that helps
I have a Bluetooth module connected through Software Serial pins (8 and 9). The Bluetooth connection works fine without any issues.
The reason why I want to use hardware serial for the GPS module is that the reliability of software serial work
Test Code (Very straight forward)
#include "SoftwareSerial.h"
SoftwareSerial ss = SoftwareSerial(8, 9);
void setup() {
ss.begin(4800);
Serial.begin(9600);
}
void passThrough() {
int16_t byte;
while ((byte = Serial.read()) >= 0) {
ss.write(byte);
}
}
void sendByteCount() {
uint8_t bytes = 0;
while (Serial.read() >= 0) {
bytes++;
}
ss.print(F("Received "));
ss.print(bytes, 10);
ss.println(F(" bytes"));
}
void loop() {
// passThrough();
// wait a bit for data to be received
delay(100);
sendByteCount();
}
Observations
- I do receive data from the NEO6M module when using software serial.
- I do receive data from hardware Serial when using a USB connection.
- RX LED led is blinking when connected to RX, TX LED is blinking when connected to TX
What I have tried so far that hasn't worked
- Tried different baud rates (2400, 4800, 9600 (the default))
- Swapped RX, and TX wires to make sure that wasn't the issue.
I am quite good with software however, the hardware is still a challenge sometimes. So I genuinely hope someone can give me advice on what the problem could be because I have run out of ideas.
Solution:
The USB Controller and the NEO6M GPS module are fighting over the Serial connection, which caused conflict. Disabling the USB Controller's UART (Ripping off the RX and TX pins) solved this problem!