I'm currently using USB to communicate with my PC. I can send data just fine and change values on my Uno. All was working until I started to run into issues because every time I connected to the serial port (COM4 on my PC), the setup() function was called in my script. This seemed odd to me, but I had read that it had do with using the same port as the uploader.
I then connected a separate UART device to the RX/TX and GND pins and ran a second USB cable to my PC form that port. I can connect to that port (COM5). It connected just fine,
port.on("open", () => {
console.log('serial port open');
});
That will print!
but no data is able to be sent unlike COM4. Furthermore, when I have the RX/RX pins all connected, I can no longer upload scripts to my Uno on COM4.
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
I'm wondering how the RX/TX pins are supposed to be used or configured.
The USB interface is connected to the tx and rx pins. If you want to use some other serial device the USB cable must be disconnected. I the USB cable is not disconnected if will fight with the other device and the results will not be good.
Opening the serial port activates the DTR signal which results in a reset; it's the design of the boards that don't have native USB (e.g. Uno, Nano, Mega).
Are you connecting RX to TX and TX to RX?
Which language is that? On Windows, you can de-activate the reset bahaviour if the language supports it. Check if your port class has functionality related to DTR and/or RTS.
Yes, I suppose connecting to the serial port restarts the device and good to know!
Sorry, I was vague about my app. Its JS running on Nodejs/Electron using the serialport package. I'll check and see if it has anything about reset behavior.
I did not realize the USB + TX/RX could not be used at the same time. I did not have a power supply so that's why I couldn't try anything else, but sounds like I need to get one.
Don't search for reset in the docs, search for DTR and RTS as they influence the behaviour.
It depends on the board. TX and RX are used for Serial on boards without native USB. It does not apply to e.g. 32U4 based boards like Leonardo, Micro or SparkFun ProMicro; the RX and TX pins are in that case Serial1.