Arduino Yun – conexión 3G (módem usb HUAWEI E220)

ACTUALIZADO 19/02/2015 el método aquí descrito sigue siendo válido, pero para las versiones más recientes de openwrt se pueden seguir las instrucciones de los siguientes sitios:

  • http://wiki.linino.org/doku.php?id=wiki:lininousbmodem
  • https://github.com/pictux/Yun_3g

FIN ACTUALIZACION 19/02/2015

Para nuestro prototipo necesitaremos conectividad móvil.

Tenemos un módem de pruebas, el clásico “pincho” usb: HUAWEI E220:

IMG_20140221_173703

Lo primero es enchufarlo al Yun y ver que pasa, el log del kernel dice lo siguiente:

[   11.540000] usb 1-1.1: new full-speed USB device number 5 using ehci-platform
[   11.670000] usb 1-1.1: New USB device found, idVendor=12d1, idProduct=1004
[   11.670000] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[   11.670000] usb 1-1.1: Product: HUAWEI Mobile
[   11.670000] usb 1-1.1: Manufacturer: HUAWEI Technologies

Googleeando un poco encontramos la siguiente entrada referida a OpenWRT:

http://josefsson.org/openwrt/dongle.html

Basándonos en ella, ajustando idProduct y sobre todo eliminando maxSize=4096, que no permitía cargar el módulo y configurando /etc/config/network del siguiente modo:


config interface '3g'
option ifname 'ppp0'
option proto '3g'
#       option device '/dev/usb/tts/0'
option device '/dev/ttyUSB0'
option apn 'movistar.es'

Al reiniciar y enchufar el módulo tenemos lo siguiente:

[   41.150000] usbcore: registered new interface driver usbserial
[   41.150000] usbcore: registered new interface driver usbserial_generic
[   41.160000] usbserial: USB Serial support registered for generic
[   41.160000] usbserial_generic 1-1.1:1.0: The "generic" usb-serial driver is only for testing and one-off prototypes.
[   41.160000] usbserial_generic 1-1.1:1.0: Tell linux-usb@vger.kernel.org to add your device to a proper driver.
[   41.170000] usbserial_generic 1-1.1:1.0: generic converter detected
[   41.170000] usb 1-1.1: generic converter now attached to ttyUSB0
[   41.170000] usbserial_generic 1-1.1:1.1: The "generic" usb-serial driver is only for testing and one-off prototypes.
[   41.180000] usbserial_generic 1-1.1:1.1: Tell linux-usb@vger.kernel.org to add your device to a proper driver.
[   41.180000] usbserial_generic 1-1.1:1.1: generic converter detected
[   41.190000] usb 1-1.1: generic converter now attached to ttyUSB1
[   41.190000] usbserial_generic 1-1.1:1.2: The "generic" usb-serial driver is only for testing and one-off prototypes.
[   41.190000] usbserial_generic 1-1.1:1.2: Tell linux-usb@vger.kernel.org to add your device to a proper driver.
[   41.200000] usbserial_generic 1-1.1:1.2: generic converter detected
[   41.200000] usb 1-1.1: generic converter now attached to ttyUSB2
[   41.200000] usbserial_generic 1-1.1:1.3: The "generic" usb-serial driver is only for testing and one-off prototypes.
[   41.210000] usbserial_generic 1-1.1:1.3: Tell linux-usb@vger.kernel.org to add your device to a proper driver.
[   41.210000] usbserial_generic 1-1.1:1.3: generic converter detected
[   41.220000] usb 1-1.1: generic converter now attached to ttyUSB3

A continuación intentaremos conectar y FUNCIONA!!!!

root@yunadan:~# logread |grep 3g
Feb 19 21:49:14 yunadan daemon.notice netifd: Interface '3g' is now down
Feb 21 16:50:24 yunadan daemon.notice netifd: 3g (4234): Trying to set mode
Feb 21 16:50:40 yunadan daemon.notice netifd: 3g (4234): Timeout setting WWAN mode!
Feb 21 16:50:42 yunadan daemon.info pppd[4298]: Using interface 3g-3g
Feb 21 16:50:42 yunadan daemon.notice pppd[4298]: Connect: 3g-3g <--> /dev/ttyUSB0
Feb 21 16:50:45 yunadan daemon.notice netifd: Interface '3g' is now up
root@yunadan:~# ifconfig
3g-3g     Link encap:Point-to-Point Protocol
inet addr:80.27.220.187  P-t-P:10.64.64.64  Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
RX packets:31 errors:0 dropped:0 overruns:0 frame:0
TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:1474 (1.4 KiB)  TX bytes:1754 (1.7 KiB)

eth1      Link encap:Ethernet  HWaddr 90:A2:DA:F9:06:23
UP BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
Interrupt:4

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
UP LOOPBACK RUNNING  MTU:65536  Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1500 (1.4 KiB)  TX bytes:1500 (1.4 KiB)

wlan0     Link encap:Ethernet  HWaddr 90:A2:DA:F1:06:23
inet addr:192.168.1.111  Bcast:192.168.1.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:1222 errors:0 dropped:0 overruns:0 frame:0
TX packets:693 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:32
RX bytes:128320 (125.3 KiB)  TX bytes:199206 (194.5 KiB)

Sin filtrar la salida de logread:


Feb 21 16:50:40 yunadan daemon.notice pppd[4298]: pppd 2.4.5 started by root, uid 0
Feb 21 16:50:41 yunadan local2.info chat[4305]: abort on (BUSY)
Feb 21 16:50:41 yunadan local2.info chat[4305]: abort on (NO CARRIER)
Feb 21 16:50:41 yunadan local2.info chat[4305]: abort on (ERROR)
Feb 21 16:50:41 yunadan local2.info chat[4305]: report (CONNECT)
Feb 21 16:50:41 yunadan local2.info chat[4305]: timeout set to 10 seconds
Feb 21 16:50:41 yunadan local2.info chat[4305]: send (AT&F^M)
Feb 21 16:50:41 yunadan local2.info chat[4305]: expect (OK)
Feb 21 16:50:41 yunadan local2.info chat[4305]: AT&F^M^M
Feb 21 16:50:41 yunadan local2.info chat[4305]: OK
Feb 21 16:50:41 yunadan local2.info chat[4305]:  -- got it
Feb 21 16:50:41 yunadan local2.info chat[4305]: send (ATE1^M)
Feb 21 16:50:41 yunadan local2.info chat[4305]: expect (OK)
Feb 21 16:50:41 yunadan local2.info chat[4305]: ^M
Feb 21 16:50:41 yunadan local2.info chat[4305]: ATE1^M^M
Feb 21 16:50:41 yunadan local2.info chat[4305]: OK
Feb 21 16:50:41 yunadan local2.info chat[4305]:  -- got it
Feb 21 16:50:41 yunadan local2.info chat[4305]: send (AT+CGDCONT=1,"IP","movistar.es"^M)
Feb 21 16:50:41 yunadan local2.info chat[4305]: timeout set to 30 seconds
Feb 21 16:50:41 yunadan local2.info chat[4305]: expect (OK)
Feb 21 16:50:41 yunadan local2.info chat[4305]: ^M
Feb 21 16:50:41 yunadan local2.info chat[4305]: AT+CGDCONT=1,"IP","movistar.es"^M^M
Feb 21 16:50:41 yunadan local2.info chat[4305]: OK
Feb 21 16:50:41 yunadan local2.info chat[4305]:  -- got it
Feb 21 16:50:41 yunadan local2.info chat[4305]: send (ATD*99***1#^M)
Feb 21 16:50:41 yunadan local2.info chat[4305]: expect (CONNECT)
Feb 21 16:50:41 yunadan local2.info chat[4305]: ^M
Feb 21 16:50:41 yunadan local2.info chat[4305]: ATD*99***1#^M^M
Feb 21 16:50:41 yunadan local2.info chat[4305]: CONNECT
Feb 21 16:50:41 yunadan local2.info chat[4305]:  -- got it
Feb 21 16:50:41 yunadan local2.info chat[4305]: send ( ^M)
Feb 21 16:50:42 yunadan daemon.info pppd[4298]: Serial connection established.
Feb 21 16:50:42 yunadan daemon.info pppd[4298]: Using interface 3g-3g
Feb 21 16:50:42 yunadan daemon.notice pppd[4298]: Connect: 3g-3g <--> /dev/ttyUSB0
Feb 21 16:50:45 yunadan daemon.warn pppd[4298]: Could not determine remote IP address: defaulting to 10.64.64.64
Feb 21 16:50:45 yunadan daemon.notice pppd[4298]: local  IP address 80.27.220.187
Feb 21 16:50:45 yunadan daemon.notice pppd[4298]: remote IP address 10.64.64.64
Feb 21 16:50:45 yunadan daemon.notice pppd[4298]: primary   DNS address 80.58.61.250
Feb 21 16:50:45 yunadan daemon.notice pppd[4298]: secondary DNS address 80.58.61.254
Feb 21 16:50:45 yunadan daemon.notice netifd: Interface '3g' is now up
Feb 21 16:52:12 yunadan daemon.info dnsmasq[1681]: reading /tmp/resolv.conf.auto
Feb 21 16:52:12 yunadan daemon.info dnsmasq[1681]: using nameserver 192.168.1.1#53
Feb 21 16:52:12 yunadan daemon.info dnsmasq[1681]: using nameserver 80.58.61.250#53
Feb 21 16:52:12 yunadan daemon.info dnsmasq[1681]: using nameserver 80.58.61.254#53
Feb 21 16:52:12 yunadan daemon.info dnsmasq[1681]: using local addresses only for domain lan

Deja un comentario