I am working on a project where I am using a Raspberry Pi and an Arduino together via USB. On the Arduino, I have my code setup to where I send it a letter over serial and it will do something (for example, if I send 'A' over serial, it will turn on a LED. B will turn it off, etc.). I have already tested all of the commands with the serial monitor, so I know my Arduino code works. On the Raspberry Pi, I want to be able to run a .sh file and have it send a letter over serial to the Arduino. In trying to do this, I have looked at many forums (including the one here: http://playground.arduino.cc/Interfacing/LinuxTTY) and every time I try to send something, the lights on the Arduino flash and it basically produces the same result as pressing the reset button. So, how do I write a .sh file to send commands to my Arduino? Thank you in advance! -Ethan
2
votes
"send it a letter over serial" -- A USB connection should not be referred to as "serial" as if it were a simple communications link. USB is a bus, and has a bus protocol. If you use the RPi as the USB host, then the Arduino has to identify itself as some kind of USB slave device (e.g. CDC/ADM gadget which would be accessed as /dev/ttyACM0 on the RPi).
– sawdust
1 Answers
1
votes
I believe there is a difference in the voltages used on the ardino (5V) vs the raspberry pi (3.3V), so you cant just directly connected them up.
Instead, you need to use a voltage divider/converter so that is has the correct voltages.
This is explained in detail at this website: https://oscarliang.com/raspberry-pi-and-arduino-connected-serial-gpio/