0

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.

4
  • Do you have something else plugged through USB in the PC where it does not work? Maybe the NodeMCU is ttyUSB1? – Edgar Bonet Apr 4 at 8:47
  • 1
    Does this answer your question? How to connect Arduino device to Linux? – Juraj Apr 4 at 8:51
  • 1
    Are you waiting a bit between opening the port and sending the data? The Arduino might not yet be ready to receive data directly after opening the port (since it resets) – chrisl Apr 4 at 8:55
  • Try executing: stty -F /dev/ttyUSB0 -hupcl – Majenko Apr 4 at 11:16
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 :/

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.