I have a strange problem. I am running Ubuntu and NodeMCU si plugged into USB. I have very simple sketch running on it, when it reads letter "R" on serial, it turns ON relay.
When I open Serial Monitor in Arduino IDE and I type letter "R" and send it, it works perfectly. However when I run commands below, it does nothing:
stty -F /dev/ttyUSB0 115200
echo "R" > /dev/ttyUSB0
I tried running the same commands on different PC with Ubuntu and these system commands work just fine.
I also tried copying exact same configuration from stty -a -F /dev/ttyUSB
from PC where it works to PC where it doesn't, but it didn't help either.
I don't think it's driver issue, because if it would, then I suppose it wouldn't work with Serial Monitor also.
Thank you for any help or hints in advance.
2 Answers 2
I had the same issue. After entering command that Majenko suggested:
stty -F /dev/ttyUSB0 -hupcl
I still wasn't able to send commands to Arduino nano. Strangely, when I open Arduino IDE Serial Monitor and send command it works. When I close it, I can send commands in terminal to Arduino for some time. Then it stops working again :/
OK, so I resolved this problem, but only half-way. I was using NodeMCU with CH340 ... and this controller worked only in Serial Monitor, not in command shell on one computer (it worked fine on other computer).
So I tried using different NodeMCU with CP2102 and it worked just fine. So I assume there must be some kind of issue with ch341 driver in my linux, I don't know.
stty -F /dev/ttyUSB0 -hupcl