SerialIP Library for Arduino Author: Adam Nielsen Contact: email@example.com
1.0 2010-02-28: Proof of concept
SerialIP is a port of the uIP TCP/IP stack to the Arduino. It allows a stock Arduino (with no shields) to access the Internet and to run Internet accessible servers.
It works by using SLIP to route TCP/IP data over the serial port, just like a dialup Internet connection (only in this case it's the Arduino "dialling up" to your PC, and there are no modems or telephone calls involved.)
Because all traffic is routed over the serial port, it means you can get network access without needing the Ethernet shield. However unlike the Ethernet shield which handles the TCP/IP protocol for you, SerialIP implements the entire TCP/IP stack (courtesy of the fine uIP project.) This has a couple of downsides, the main one being size. It takes up around 9kB of flash space and enough RAM that you can easily run out of memory (which normally results in the Arduino rebooting unexpectedly.)
However it is possible to work within these limitations, and with no additional purchase beyond the Arduino itself it's certainly a cheap introduction to the world of embedded networking!
Unzip the file into the
arduino-0017/hardware/libraries/ folder. You should end up with a
SerialIP folder created inside the
For Arduino 1.0+: Change line 24 in 'SerialIP.h' from '#include <WProgram.h>' to '#include <Arduino.h>'
Perhaps the most difficult part of using this library is figuring out how to establish the SLIP connection to the Arduino.
The SLIP connection needs two IP addresses assigned to it. One for the PC's end and one for the Arduino's end. These two addresses must not be in use elsewhere on your network or it will cause problems with packets being sent to the wrong place and getting lost.
The defaults of 192.168.5.x will work for most people, except for those who already have devices starting with 192.168.5. on their network. If you change the addresses, remember to edit the code appropriately and reflash as the Arduino's IP is hard coded.
Under Linux, this is fairly easy if you have SLIP support compiled into your kernel: (you will need two terminal windows for this)
$ sudo modprobe slip
$ sudo slattach -L -s 115200 -p slip /dev/ttyUSB0
$ sudo ifconfig sl0 192.168.5.1 dstaddr 192.168.5.2
Under Windows, you'll have to figure it out yourself and update this page :-) You should be able to use a Direct Cable Connection on XP and older, however this has apparently been removed in Vista and Win7 Home Premium. You will have to upgrade to Win7 Professional and then run in XP mode in order to use SLIP.
Setting up SLIP in XP: http://www.sics.se/~bg/telos/slipintro.pdf
Until the library interface has settled down, please see the examples for the few commands that are specific to SerialIP.
For the rest of the commands, see the uIP-1.0 documentation.
There are currently two examples:
HelloWorldServerlistens for TCP connections on port 1000 and greets any incoming connections.
SendEMailconnects to an SMTP server and sends an e-mail
Ping it. The uIP stack will respond to pings. If you look at your routing table the Arduino's IP address should be sent out of the SLIP connection (as opposed to being sent out your Internet connection instead.)
You can also watch the serial RX/TX LEDs on the Arduino while you're pinging it. The RX LED should flash once a second or so when the PC is sending a ping packet, and the TX LED should flash a moment later when the Arduino responds.
The rest of these FAQs assume you can successfully ping the Arduino.
Make sure you're not running a firewall that is blocking connections to your PC. Under Linux, you can give the SLIP connection full access like this:
# iptables -I INPUT 1 -i sl0 -j ACCEPT
The Arduino is only capable of talking to whatever is on the other end of the serial cable - which will usually be your desktop PC. Your PC will have to be configured to take the Arduino's packets and route them out to the Internet if you wish to connect to remote hosts.
Under Windows this is probably done by sharing the Internet connection over the SLIP interface, under Linux you can do the same probably by setting up iptables rules to masquerade (use NAT) data coming out of the SLIP interface.
More detailed instructions will be added when someone eventually tries to achieve this :-)
Last Modified: July 08, 2012, at 07:58 PM by doggenj