Inspired by blog posts by two other people (Arduino and OpenWRT and Arduino + WR703N) I decided to experiment with having my own Arduino Uno R3 talk via the USB port to a TP-Link WR1043ND wireless Access Point running OpenWRT. So far I have the Uno R3 visible as
/dev/ttyACM0 inside the OpenWRT-powered WR1043ND. The key is to “
opkg install kmod-usb-acm” under OpenWRT to provide serial-over-USB support to match the Arduino Uno R3’s USB chip.
My TP-Link WR1043ND is currently running Attitude Adjustment (r29537) version of OpenWRT ( a 18.104.22.168 linux kernel, built with the DIFFUSE for OpenWRT project’s VirtualBox image dev environment). Since the current (June 2012) OpenWRT repositories have modules built for later kernels, I built the necessary
kmod-usb-acm package on my dev box and rsync’d it across the WR1043ND. No problem. Installation is then easy:
root@OpenWrtDisplayLink:/# opkg install kmod-usb-acm_22.214.171.124-1_ar71xx.ipk Multiple packages (kmod-usb-acm and kmod-usb-acm) providing same name marked HOLD or PREFER. Using latest. Installing kmod-usb-acm (126.96.36.199-1) to root... Multiple packages (kmod-usb-core and kmod-usb-core) providing same name marked HOLD or PREFER. Using latest. Configuring kmod-usb-acm. [ 1649.470000] usbcore: registered new interface driver cdc_acm [ 1649.470000] cdc_acm: v0.26:USB Abstract Control Model driver for USB modems and ISDN adapters root@OpenWrtDisplayLink:/#
Having installed the required USB driver, I plugged my Uno R3 into my WR1043ND and saw the following on console:
root@OpenWrtDisplayLink:/# [ 1708.920000] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0002 [ 1708.930000] ar71xx-ehci ar71xx-ehci: GetStatus port:1 status 001803 0 ACK POWER sig=j CSC CONNECT [ 1708.940000] hub 1-0:1.0: port 1, status 0101, change 0001, 12 Mb/s [ 1709.100000] hub 1-0:1.0: debounce: port 1: total 100ms stable 100ms status 0x101 [ 1709.160000] ar71xx-ehci ar71xx-ehci: port 1 high speed [ 1709.160000] ar71xx-ehci ar71xx-ehci: GetStatus port:1 status 001805 0 ACK POWER sig=j PE CONNECT [ 1709.230000] usb 1-1: new full speed USB device number 3 using ar71xx-ehci [ 1709.290000] ar71xx-ehci ar71xx-ehci: port 1 high speed [ 1709.290000] ar71xx-ehci ar71xx-ehci: GetStatus port:1 status 001805 0 ACK POWER sig=j PE CONNECT [ 1709.390000] usb 1-1: ep0 maxpacket = 8 [ 1709.390000] usb 1-1: skipped 3 descriptors after interface [ 1709.400000] usb 1-1: default language 0x0409 [ 1709.410000] usb 1-1: udev 3, busnum 1, minor = 2 [ 1709.410000] usb 1-1: New USB device found, idVendor=2341, idProduct=0043 [ 1709.420000] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=220 [ 1709.430000] usb 1-1: Manufacturer: Arduino (www.arduino.cc) [ 1709.430000] usb 1-1: SerialNumber: 649353435333518082B0 [ 1709.440000] usb 1-1: usb_probe_device [ 1709.440000] usb 1-1: configuration #1 chosen from 1 choice [ 1709.450000] usb 1-1: adding 1-1:1.0 (config #1, interface 0) [ 1709.460000] cdc_acm 1-1:1.0: usb_probe_interface [ 1709.460000] cdc_acm 1-1:1.0: usb_probe_interface - got id [ 1709.470000] cdc_acm 1-1:1.0: ttyACM0: USB ACM device [ 1709.480000] usb 1-1: adding 1-1:1.1 (config #1, interface 1) [ 1709.480000] drivers/usb/core/inode.c: creating file '003' root@OpenWrtDisplayLink:/#
Yay! We now have a relevant tty!
root@OpenWrtDisplayLink:/# ls -alt /dev/tty* [..] crw-rw-rw- 1 root root 166, 0 Jun 2 17:52 /dev/ttyACM0 [..] root@OpenWrtDisplayLink:/#
Now, fire up the AnalogReadSerial example program on the Arduino (see this blog post), which continuously sends out decimal numbers to the Uno’s serial port representing the analogue voltage on pin A0. I can now read this output stream simply by using:
root@OpenWrtDisplayLink:/# cat /dev/ttyACM0 [...lines of numbers which track the voltage on pin A0..]