Arduino Communications Using the netcat(nc) Utility
Welcome to Combustory
Any questions or comments:
- Send them to - email@example.com
Why reinvent the wheel. I have seen very complicated methods for communicating with the Arduino, Including some I have made on my own. What I have recently found out is that the easiest way to communicate to the Arduino is using the existing tool netcat. It is soooooo simple and super powerful. You can send the output to a Network port and access the communications from literally any place in the world.
- You have basic knowledge of command line usage
- You know how to load a program to the Arduino
Mini2440 or Embedded Systems
Embedded systems like the Mini2440, use Busy Box as a small utility package that includes a version of nc that makes communications to Arduino a breeze. All you have to do is go to a terminal and use these two commands after you plug in the Arduino.
stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts nc -f /dev/ttyUSB0
You should now have a terminal session that is communicating with the Arduino. Of course you should have a program that responds to serial communication on the Arduino, or nothing will be happening. How this works is the nc command has redirected the input and output streams of the /dev/ttyUSB0, which is the Arduino terminal and the stty command sets the serial communication parameters. To exit out of the program, just use ^C (ctrl-c)
Now we expand on this idea and we send the Arduino serial port to a network port with this command.
nc -ll -p 2111 -e nc -f /dev/ttyUSB0
This is where it gets interesting. Now you can access your Arduino from anywhere on the planet, or space if you still have a good satellite connection `,~) Use this command from any other computer that has netcat.
nc 192.168.30.206 2111
Use the ip of your Mini2440 of course.