A guide to cellular connectivity on resin.io devices

⚠️ Update 2016 Nov 28: WARNING!!! A lot has changed on resin.io since publishing this post- please do not use the setup outlined in this post! For wireless connectivity- we recommend using resinOS 2.0- which is currently in beta on our staging environment at dashboard.resinstaging.io [https://dashboard.resinstaging.io/]. The plan is to release resinOS2.0 as production ready…

⚠️ Update 2016 Nov 28: WARNING!!! A lot has changed on resin.io since publishing this post, please do not use the setup outlined in this post! For wireless connectivity, we recommend using resinOS 2.0, which is currently in beta on our staging environment at dashboard.resinstaging.io. The plan is to release resinOS2.0 as production ready around the middle of March 2017.

~~Let’s face it, an IoT device isn’t cool until you make it wireless, sure you can add WiFi – but what if you want to take your IoT box on a road trip?~~

Resin_car.png

~~Enter USB cellular modems – those nifty little things we carried around before mobile phones could be WiFi HotSpots.~~

USB_Modems.png

~~The Ingredients~~

~~Resin supports most USB modems that run on Linux. That said, the Cellular modem market is flooded with devices with the same name and minor version number differences that might not necessarily work with Linux, I spent a considerable amount of time while writing this post because of one such Huawei variant.~~

~~A quick checklist to help you choose a modem:~~

  • ~~Supports Linux without custom compiled drivers~~
  • ~~Supports the Cellular frequency bands of your network provider~~
  • ~~A powered USB hub if the power requirement from the modem is greater than what your device can provide from its USB ports~~
  • ~~Pick a modem with publicly available wvdial configurations.~~
  • ~~Choose a NDIS based modem, if you don’t want to do any connection setup from your resin powered device. This makes the modem appear as a USB Ethernet device and no further configuration is needed~~

~~The Recipe~~

  • ~~Connect your device to resin.io, detailed instructions can be found here~~

  • ~~Clone the cellular-modem example:~~

      git clone https://github.com/resin-io-projects/cellular-modem.git
    
  • ~~Edit the init.sh and change the usb_modeswitch line to work with your modem~~

    • ~~For ZTE Modems~~

        usb_modeswitch -v 19d2 -p fff5 --verbose -K
      
    • ~~For Huawei Modems~~

        usb_modeswitch -v 12d1 -p 14fe --verbose -J
      

      ~~The vendor and product IDs above should match your modem – don’t worry about getting it wrong on first run, this example prints all the connected USB vendor and product IDs to resin log when pushed to your device.~~

  • ~~Edit wvdial.conf to match the settings from your cellular provider~~

    • The following are the settings for the EVDO modem from Tata Photon+ [Indian cellular broadband provider]

        [Dialer Defaults]
        Modem = /dev/ttyUSB0
        Init1 = ATZ
        Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
        Init3 = AT+CRM=1
        Stupid Mode = 1
        ISDN = 0
        Modem Type = Analog Modem
        Phone = #777
        Password = internet
        Username = internet
      
    • ~~If your provider requires you to use an APN, Init3 is usually replaced with:~~

        Init3 = AT+CGDCONT=1,"IP","APN",,0,0
      
    • ~~wvdial’s config varies depending on your modem’s make and model. We have noted that a majority of the changes are in Init3, Username, Password, Phone sections of the file~~

  • ~~Commit your changes and push to your application on Resin with Ethernet connected, instructions here~~

  • ~~Check your dashboard to see the additional IP from the USB modem or the logs if you missed anything~~

  • ~~Disconnect Ethernet and reboot~~

  • ~~Profit!~~

Caution

We should note that since the primary connectivity to your device is through your application, you could potentially brick a device by pushing code that disables the modem. We advice testing any new changes with a Ethernet connected device or with the device in reach before deploying to a larger fleet.

If you have any questions or you’d just like to say hi, find us on our community forum?

notes:
  • \~~ usb__modeswitch – Most USB Cellular modems have proprietary Windows drivers and when plugged in the modems show up as USB storage devices. On linux most of these drivers are provided as kernel modules, usb__modeswitch helps us send a message to the USB device asking it to switch from the USB storage mode into modem mode \~~
  • \~~ wvdial.conf – wvdial is the dialer that helps us make USB modem connections to the Internet. It initializes the modem with relevant settings (APN etc.) and starts pppd to connect to the Internet\~~


Posted

in

Tags: