Jasper
Jasper

Reputation: 719

Serial communication with Arduino only works while the screen is running

I'm on Linux and for some reason I can only use the serial port while screen is monitoring it. When screen is not running, the Python code doesn't crash or something. The Arduino just doesn't respond. Is there something I'm missing?

pi@raspberrypi ~ $ screen "/dev/ttyACM0" 115200

pi@raspberrypi ~ $ sudo python
>>> import serial
>>> s = serial.Serial("/dev/ttyACM0", 115200)
>>> s.write("EXP\n")
4

Upvotes: 6

Views: 442

Answers (2)

Christian Thieme
Christian Thieme

Reputation: 1124

In examples, you see other options. Especially timeout seems to be used always:

s = serial.Serial("/dev/ttyACM0", 115200, timeout=2)

Upvotes: 0

Eric Fossum
Eric Fossum

Reputation: 2462

Are you sure it's not asleep?

Some machines disable things like USB when it's in low power mode (which screen savers could be).

Upvotes: 1

Related Questions