Serial communication using Rx/Tx pins

Hello!
I am a beginner and have understood and experimented the basic examples available on the site using an uno.
For my next project I have to send and receive data via the serial pins ( 0 and 1) from my uno.
I am using a D - SUN - V3.0 USB to TTL converter for my cause but for some strange cause my board will not listen to the data sent by the PC from the serial monitor.
Everything works fine when I use the USB cable and life is beautiful. Arduino can even send the data through the TTL converter so neither the component not the code is the problem.
for example

void setup() {
  Serial.begin(9600);
}

void loop() {
     Serial.println("Hello world!");
  
  
  delay(1000) ;
}

this works fine and prints a hello world after each second
but

char dummy ;

void setup() {
  Serial.begin(9600);
}

void loop() {
  if ( Serial.available() > 0) {
    dummy = Serial.read() ;
    Serial.println("Hello world!");
   
  }
  delay(1000) ;
}

this wont say hello to the world no matter what I send from the serial monitor
also wish to know if I can upload my code via the USB to TTL and if anyone has ever tried it instead of the safe USB cable method.
Google doesnt helps me anymore!

I'm confused: what EXACTLY is your setup?

Are you using serial comms between two Arduinos, or between an Arduino and a PC.
Can you post a hand drawn schematic and/or picture of your setup and connections?

Do you mean

Serial.println(dummy);

That will print what you send.
Leo..

Are you trying to use Pins 0 and 1 for two different purposes at the same time? Those pins are used when sending data with the USB cable. Maybe you need to create another serial port on different pins using SoftwareSerial for your USB to serial connection?

When using the USB-TTL converter have you a connection to Arduino GND as well as to the Tx and Rx pins?

...R

  1. I wish to communicate between arduino and PC
  2. I dont care what my arduino prints. I just want it to receive a string from the serial monitor and send a string to the serial monitor without using the USB cable using the pins instead.
    thats all I wish to do. Send and receive data between PC and arduino uno using Rx and Tx pins using a USB to TTL converter.

As of now I can send from Uno but i cant receive data and take decissions according to string recieved

  1. I am not using pins 0 and 1 for anything else. plus I am able to print "Hello world" as in the first code i submitted so i don't think software serial would solve my problem but I will try it never the less
    The ground is also common for arduino and TTL converter

I am open to any other suggestions or querries just help me get it working please!

Hi,
Have you got the Tx and Rx connections the right was around on your TTL to RS232 to USB adapter?
Have you got the right COM port selected for your adapter, it will be different to the RS232 to USB used to program the UNO.

Tom... :slight_smile:

If you write a short program that can "receive a string from the serial monitor and send a string to the serial monitor " using the regular USB cable and if you then disconnect the regular USB cable and power the Arduino through the power connector that EXACT SAME program will be able to communicate with the Serial Monitor using your USB-TTL converter connected to Pins 0 and 1. On your PC you will obviously have to select the correct serial port for the USB-TTL converter.

...R
Serial Input Basics

@Robin2 that is exactly what I am doing and not getting the expected result. That is what is bugging me so much that it is such a simple task and I am unable to accomplish it.
I run my program with the USB cable and works. Then I power my board externally and select the serial port corresponding to the converter and then arduino sends the data but doesn’t receives the data sent by the Serial monitor

@TomGeorge I connect Rx of uno to Tx of my connector and vice versa and also make sure to change the COM port to the relevant one.

Still stuck with the same problem. can print any pre declared line on the monitor but cannot receive a string and print the received string

Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

So we can see hw you have the comms connected please.

A picture of your project may also help.

Tom... :slight_smile:

Sure thing here is the simple code I use now and a USB cable connected which works and whatever I send is printed (zoom in the PC screen)

Then I show the connections between uno and TTL converter

Com ports are shown and selected
Uno powered by battery

but now nothing is printed on serial monitor no matter what I send

Here is the code

char dummy ;

void setup() {
  Serial.begin(9600);
  
}

void loop() {
  if ( Serial.available() ) {
    dummy = Serial.read() ;
    Serial.print(dummy);  
  }

}

hope this helps you help me :slight_smile:

1.jpg

3.jpg

4.jpg

5.jpg

6.jpg

Hi,
I think your problem is that when you plug your adapter in to Pins 0 and 1, the on board adapter is still connected, you cannot have two adapters connected to the 328 Tx/Rx and expect communication.

If the 328 was on its own without the onboard USB to RS232 adapter, then your config would work.

You will need to use SoftwareSerial library and connect your adapter to another pair of pins.

Tom.... :slight_smile:

Images from Reply #9 so we don’t have to download them. See this Image Guide

8b38583e076852d6aa3f4e471a999c6027d005cc.jpg

ee29176af0e7ff41ed0c33bbb4a602eb2bb41ab6.jpg

c270215d156d3a607f35649fde11e376bc0767f0.jpg

f73f1621b010b3b4cf0e1f6985ace7ab8e23a17d.jpg

32f74afcf7ad334a1137c757dc7b47083e4f1df2.jpg

4b2e319198250f321462482c51eac51b2d4ada45.jpg

…R

It's impossible to be sure how anything is connected from photos. Make a simple pencil drawing showing the connections and post a photo of the drawing. Please DO NOT use Fritzing.

Is that 9v battery new? Those little batteries are not adequate for powering an Arduino. Use a pack of 6 x AA cells.

...R

@TomGeorge Thanks! I think that is where I am going wrong and I am trying your approach right now.
but how was my Uno able to transmit data before via the converter remains a mystery.
I will let you know about the results as soon as possible