Extracting data from arduino without usb cable,using only usb-ttl converter

Hello community, I have a question , i have programmed my arduino uno to print "hello" on a loop,then opening the serial monitor, it displays "hello".
My problem is when I unplug the usb cable that powers and connect arduino to pc serially and replace it with usb-ttl converter, connecting both rx,tx and gnd on both device, and powering my arduino with wall charger, and using python serial.readline() in port ttyUSB0, I cant see print "hello", Can someone point me on this?

This is a good explanation:

https://forum.arduino.cc/t/using-arduino-uno-rx-and-tx-pins-while-comport-through-usb/487318/2

I assume you have the Arduino tx-> USB interface rx and the Arduino rx-> USB interface tx connected.

When the onboard USB interface is used the Arduino is reset so the setup() code is run. If you just hook up the rx,tx, and ground the Arduino will be reset on power on only. Depending on when your Python program is started and the timeout on the serial read it may miss the message.

Power up the Arduino, then start your Python program then immediately press the reset button on the Arduino. You should see the message if the Python serial timeout is long enough.

You didn't show any code, so here is what I did (note the 2 second timeout in the Python code).

"""
Remember that Python 3 strings use Unicode so the data transfered must
use byte arrays or strings must be encoded and decoded
"""

i

mport serial
import serial.tools.list_ports

#
# Find the USB port the Arduino is on
#
commports = serial.tools.list_ports.comports() # get possible ports 
numPorts = len(commports)
if (numPorts == 0):
    print("No serial ports available\n\n")
    exit()
if (numPorts>1):
    # Have user pick one
    portNum = 0
    for port in commports:
        print("port number ",portNum)
        print(port)
        portNum = portNum+1
    usePort = int(input('enter port number to use 0-'+str(numPorts-1)+':'))
else:
    usePort = 0
    
thePort = commports[usePort][0]
print('using ',thePort)

# Remember every time you connect to the Arduino it
# resets (Unless you disconnect DTR)
# open serial port 
device = serial.Serial(thePort, 9600, timeout=2)



startData = (device.readline().decode())

print(startData) 

device.close()
void setup() {
  //Initialize serial 
  Serial.begin(9600);

  Serial.println("Hello World");
}
void loop() {
 }

@Max2p, your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem :wink:

It would be advisable to post the code for both the Arduino and the PC.

Actually, it's used to invoke the boot loader.

Look at the schematic, the USB interface is connected to the reset pin. Which invokes the boot loader (if there is one), which cleverly throws away the cause of the reset.

I have edited my question , I haven't specified it that the Serial.println("hello") is on the loop, still is it needed to press the reset button on arduino to see the printed mssge on python ide? Thanks for a quick reply.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.