That’s not how it works. It’s not a normal file or FIFO.
Use py-serial, py3-serial, miniterm, cu, tip, perl-serial, or something like that.
If you want a CLI tool to use for piping data, I’ve used perl’s IPC::Open2 to pipe commands (and get replies). You can find examples with google. Thousands.
echo status | python foo.py will then do the trick.
You just need to add pi to dialout group BTW.
Here’s a Python 3 example I found. Adjust it to take STDIN as data to send. Scrap the rest.
——— foo.py ———
# Change this to your serial port if needed - you can see the correct port in Arduino IDE
serialPort = '/dev/ttyUSB0'
serialSpeed = 9600 # ~960 bytes per second, a good default
txString = b'PING!\r\n'
rxString = b''
serialObj = serial.Serial(
baudrate = serialSpeed,
parity = 'N',
stopbits = 1,
print( "ERROR: Could not set up serial connection on %s - exiting!" % serialPort )
exit( 1 )
print ( "Connected to %s at %i baud. Hit CTRL+C to exit at any time ..." % ( serialPort, serialSpeed ) )
if serialObj.write( txString ):
print( "[*] Sent 'PING!', waiting for reply..." ) ;
rxString = serialObj.readline()
rxString = rxString.rstrip()