Sunday, December 13, 2020

RaspberryPI 4B+ and GSM Dongles

I managed to run 4 GSM donlges on RaspberryPi 4B+ in a stable production eventually although it was not an easy process. I had four UMG1691 GSM dongles that I wanted to use with raspberry-asterisk.

-------

Update 4: 19/June/2021:

I noticed intermittent disconnects in the dongles, it was apparently due to weak 3g signal. I suppose the operator stopped one of the antennas it had in our region which caused the weak signal problem. (RSSI <15)

I had to switch the dongles to 2G (AT^SYSCFG=13,1,3FFFFFFF,0,2) to get a better signal however dongles keep resetting frequently and it was very unstable. I had DUB H7 D-Link hub which is recommended here however I was not able to get dongles working in 2G mode with this hub.

I ordered a TP-Link UH700 USB 3.0 hub and the dongles are now working in 2G mode and they are very stable (RSSI > 23). This USB hub uses VL812 chip which I think is the reason why its compatible with 2G dongles (needs to be verified). There are some other hubs with this chipset which can be tested to confirm this.



I think a better hub choice would be TP-Link UH720 which has two 2.4A ports which can be used the also power the raspberry pi. DUB-1370 may also be compatible, it needs testing. I had tested this "4 Port USB3.0 Transparent HUB" Orico hub  and it was not compatible with 2G dongles. 

I also found that the Mode / Submode values are not important, my dongles work fine in 2G with mode/submode 3/3 or 0/0, and in 3G with mode/submode 5/4 or 0/0 . I had a dongle that was not functioning properly even when it was shown as Free in asterisk, it was a E171 dongle with firmware v21.x . 

Update 3: 26/April/2021:

The four sim cards in the dongles were from 3 different network operators. I noticed that the simcards  from one of the network operators do not work stably and they reset frequently. I was getting 

ID           Group State      RSSI Mode Submode

dongle2      0     GSM not re 20   5    4 

I was getting Mode 5 Submode 4 on the dongle having the sim card. This was resolved by transferring the phone number to another network operator. Now asterisk shows a Mode 0 Submode 0 like the rest of the dongles and it is all stable.

ID           Group State      RSSI Mode Submode

dongle2      0     Free       25   0    0 

Update 2: 2/March/2021:

Although my setup from Update 1 was stable, the gsm dongles used to reset / disconnect every 10-60mins randomly, I had the following errors in dmesg: 

[14176.370665] usb 1-1.3.4-port4: Cannot enable. Maybe the USB cable is bad?

[14176.370984] hub 1-1.3:1.0: hub_ext_port_status failed (err = -110)

[14177.410797] usb 1-1.3.4-port4: cannot disable (err = -110)

[14054.689390] usb 1-1.3.4-port1: cannot reset (err = -110)

and even sometimes lsusb didnt show dongles after the above errors and a restart was required. 

I decided to try Ubuntu 20.04LTS for Raspberry PI + Asterisk 18 and it worked decently without even a single dongle disconnect / restart in 24 hours. I have published the instructions to install freepbx/asterisk 18/ ubuntu 20.04 LTS on Raspberry PI in my post here.


UPDATE 1: 23/Dec/2020:

The UMG1691 modems were not stable at all for production due to RF problems in 2G. 

I eventually dropped all these modems and went for four new 3G modems: E1550, E153, E173 and E171

They work pretty well with D-Link DUB-H7 port when set to 3G only mode :

^SYSCFG:14,2,3FFFFFFF,0,2

It is finally Stable :



-------

First, RaspberryPI 4B+ allows a Maximum total USB peripheral current draw of 1.2A. This is not enough if you are going to use four GSM dongles in which each dongle uses 0.5A, you would need a total USB current draw of 2A.

One might think to use a powered USB hub. I tried this Orico USB3 hub and this D-Link USB2 Hub however they did not work. There are some reports that GSM dongles might have problems with USB hubs and using 3G mode might fix it. In my experience, the GSM dongles got reset frequently and the OS reported errors like:

usb 1-1-port2: cannot reset (err = -110)

Second, the 4 USB ports on RaspberryPi are designed so close to each other that it makes it impossible to connect 4 dongles directly to the raspberry. You would need a USB cable extension. Casual USB2.0 extension cables won't work and it leads to 

usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?

errors in dmesg. You would need to use USB3.0 extension cables even for usb2 ports to connect your dongles.

Third, after connecting all GSM dongles to the raspberry, you may get

usb usb2-port1: over-current change #1

error in dmesg. I tried three things here :

- Add max_usb_current=1 to /boot/config.txt

- Use minicom or atinout to directly send AT commands to your GSM dongles and set SYSCFG on all your dongles to 2G only which uses less power than 3G

- Use a 5V 3A USB adapter on your raspberry and check that your raspberry is not undervoltaged :

/opt/vc/bin/vcgencmd get_throttled

and also check dmesg to ensure that the usb ports did not get overcurrent:

dmesg | grep -i curr

so my setup is now stable with the above precautions and everything seems to work fine, it took me 3 weeks for to figure out all the above

- Disable wifi and bluetooth modules if you don't need them, add dtoverlay=disable-wifi and dtoverlay=disable-bt to /boot/config.txt 

and finally reboot raspberry for the changes to apply.

- I had this problem that dongles stopped receiving SMS after some time. Whenever I inserted the sim card on a mobile phone, text messages were received fine. This problem is described here and the solution is to add a cronjob in your raspberry pi to delete SMS storage of the sim card / dongle periodically. 

2 comments:

  1. Thanks, Nice tuto, for the tplink usb hub , could you inform what hub version you have that has VIA VL812 chipset? As I understood there are some versions come with different chipset like V2 comes with RTS5411.

    ReplyDelete
    Replies
    1. I have tested v1 and v3 and dongles worked fine on both. However, the problem with v1 is that it does not turn on automatically when the power cable was disconnected and connected again, you always need to press the power button to turn it on each time it is connected to power

      Delete

How to disable Debian 12 sleep on production servers

 Debian 12 has power saver enabled by default which causes your server to go to sleep if there is no mouse / keyboard interaction. To resolv...