Martin's corner on the web

TCP/IP over RFM12B and Raspberry Pi as gateway

I have always wanted to connect my remote RFM12B -based nodes to the Internet, I have finally managed to do so. It was relatively easy, based on the excellent work of Adam Neilsen with his SerialIP library

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.)


and Steve Marple’s serial emulation layer for RFM12B

Arduino library to provide a software emulation of a transparent serial link using the HopeRF RFM12B transceiver modules. The library extends the Arduino stream class so the user is able to access the RFM12B as a serial device in much the same way as the Arduino environment enables access to the hardware UART(s). ACKs and retransmissions are employed to prevent losing data from dropped packets. A packet number is included to prevent duplicated data, which could otherwise occur for the case when the ACK is not received and a packet is retransmitted.


I had to port Adam’s library a bit and make the serial read and serial write procedures custom assignable, so I could assign Steve’s RFM12B serial emulation R/W code there.

So I uploaded the SerialStream example (slightly modded for LED pin number) on a RFM2Pi v2 board plugged on my Raspberry Pi and uploaded a modified “Hello World Server” example on a Funky v2. On my Raspberry Pi I entered the following commands to get SLIP going:

 sudo modprobe slip
 sudo slattach -L -s 38400 -p slip /dev/ttyAMA0 &    
 sudo ifconfig sl0 dstaddr

And tested out icmp and telnet to the Funky v2:




So, it works nicely. The SerialIP library also includes a SMTP example that I didn’t port yet, but that will be fairly easy to do. Overall the opportunities are great, interesting example with lots of potential to use.

Unfortunately, there is only one node per serial port support using this method, so you can have at most 3 remote nodes with TCP/IP connectivity (the GPIO header serial + 2 for the USB) on a Raspberry Pi

My code and modified SerialIP library are available on github.


One thought on “TCP/IP over RFM12B and Raspberry Pi as gateway

  1. ben

    This looks great! I’d love to try using slip on on a microchip pic board that I’m using in school!

    Should any a linux virtual machine distro work with slip? Can a usb/rs232 cable be used, or does the vm have only rs232 com port drivers?