Serial connection dont display anything on bare bone arduino

I have an external device that is connected to arduino via rs232. The external device is powered by 3.7V battery, there are only two wires (TX, GND) going to arduino.

While i connect this device to arduino pro mini i get expected output like so…
image

So far so good… Now when i use the same code, the same bootloader, and the same pin on custom made pcb with atmega 328 i get output like this…
image

Here is the scheme of my PCB https://easyeda.com/jaka87/new-vetercek
I can seem to figure out why i cannot get data from the device while custom PCB is connected. Both Custom PCB and arduino pro mini use the same bootloader with internal oscillator (i have tried external aswell)

I can seem to figure out this issue for days. Any help is appretiated…

The code is as following…

#include <SoftwareSerial.h>
SoftwareSerial ultrasonic(11, 12); //RX, STX
String serialResponse = “”;

void setup()
{
Serial.begin(9600);
while (! Serial);
ultrasonic.begin(9600);
Serial.println(“start”);

}
void loop()
{
if ( ultrasonic.available()) {
Serial.println(“serial ok”);
serialResponse = ultrasonic.readStringUntil(’\r\n’);
Serial.println(serialResponse);
}
}

You need to separate the problem from your somewhat complicated project. Create some simple test sketches to exercise the serial port on your custom Arduino. Test that hardware separately from your project until you know for sure that it works.

Serial connections depend on accurate clocks, and according to your schematic, you forgot to add the required load capacitors on the 8 MHz crystal.

I’m surprised it works at all.

Your schematic shows an 8 MHz crystal. Are you using an 8MHz Pro Mini?

Are you using the same RS232 to TTL Serial adapter for both?

1 Like

Thank you all for your input.

@jremington I dont think this should matter since im using boatloader (minicore) with fuses set to internal oscillator right ? I added external oscilator as a backup and from what i understand is not used currently.

@johnwasser Yes. The arduino that is working as expected is in fact 8MHz Pro Mini. The non working one is also 8Mhz with internal oscillator. In both cases the same RS232 adapter is used

The 8 MHz internal oscillator is not accurate either, and often causes problems with serial connections due to inaccurate Baud rate. You might try calibrating the internal oscillator.

Run a simple LED blink program and verify that the timing is what you expect.

1 Like

@jremington you sir are a lifesaver! I have been figuring this out for days. After your tip it took me only half an hour of googling and experimenting with OSCCAL value. Finally i got it working…

I guess i should also consider fixing my PCB and using external oscillator in the future…

We might have gotten there sooner if you had not said:

This bit confused me to. About the 2 day ago i uploaded the pro mini with same bootloader to verify if this was the issue, yet it still worked fine compared to my PCB.

If I understand correctly it could be since pro mini uses voltage regulator to work at 3.3V while my PCB dont uses one and is powered by 3.7V

Thank you all for fast and useful responses, it would probably take me weeks to solve this by myself!

It might be the voltage or it might be that the internal clock of the Pro Mini was better calibrated.

1 Like