2

I have a raspberry pi b+ running raspbian jessie, and I want to use the command line to send strings to the arduino, I don't need to receive anything though. I have found a couple of ways of doing this, but there are no files in /dev/ called ttyS. I have used the arduino with the official serial monitor that comes with the ide, and it works perfectly. I have tried echo "Hello World!" >/dev/ttyAMA0 but it says permission denied

I am loged in as pi over ssh, as suggested in deacs answer, I did sudo usermod -a -G dialout pi and it's not saying permission denied, but nothing is being recieved by the arduino. it is the only thing plugged into usb.

The output of groups is:

pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi
  • Hello and welcome. Please not that you can always edit your original question to provide additional information as requested in comments (to the question or to answers). This way all readers will easily catch all relevant information without parsing through multiple comments. Thanks. – Ghanima Oct 24 '16 at 8:03
  • ... and sorry about the mistake in my edit (looks I am blind this morning). Thanks for the correction! – Ghanima Oct 24 '16 at 8:07
3

You need to do a few things before being able to use /dev/ttyAMA0

  1. Add your user (that will use ttyAMA0) to the dialout group:

    • sudo usermod -a -G dialout pi (pi is the user here)
  2. Disable linux using the serial port as a terminal:

    • sudo raspi-config

    • Select Advanced Options

    • Select Serial

    • "Would you like a login shell to be accessible over serial?" Select <No>

    • "The serial interface is disabled" <Ok>

    • Select <Finish> and select <Yes> when asked "Would you like to reboot now"

  3. After reboot, edit the /boot/config.txt file to enable uart on boot:

    • sudo nano /boot/config.txt

    • change enable_uart = 0 to enable_uart = 1

    • save file and reboot again sudo reboot

After reboot you should be able to send commands over /dev/ttyAMA0.

1

The UART connected to GPIO 14/15 (pins 8/10) is normally named /dev/ttyAMA0.

Only the Pi3 defaults to using /dev/ttyS0 as a different UART is connected.

So to talk to the Arduino try

echo "Hello World!" >/dev/ttyAMA0
  • it says permission denied – Hazzdood Oct 22 '16 at 22:47
  • sorry, i'm not very good with chmod – Hazzdood Oct 22 '16 at 22:48
0

On all recent Raspbian The default serial is /dev/serial0. This is actually a link to the actual device, which can vary.

  • yours works too, but it still still says permission denied. @Milliways – Hazzdood Oct 23 '16 at 1:55
  • What user are you logged in as? What does groups show? – Milliways Oct 23 '16 at 4:59
  • Do NOT post extra detail into Comments, put in your answer. There is no need to use @ when responding. Based on your response pi is a member of dialout which should be the group of the serial port, so it should work, but as you have not specified exactly what you have tried no one can be sure. – Milliways Oct 23 '16 at 6:17
0

As Johns answer sudjested from here, I used the command:

stty -F /dev/ttyUSB0 9600 cs8 -cstopb

then opened /dev/ttyUSB0 with by doing

screen /dev/ttyUSB0

and it works perfectly.

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.