Introduction: Raspberry PI USB Vs SERIAL Communication With Gsm Shield (itbrainpower.net A-gsm Shield)
About this how to
This how to refers to the itbrainpower.net a-gsm shield, having following main features:
- Worldwide compatibility - quad band module
- GSM / GPRS / SMS / DTMF supported
- Two SIM sockets (single SIM active)
- combo Integrated GSM antenna and uFL connector for external antenna (as standard)
- Integrated uSD(TF) socket
- Micro-USB interface for communication and powering
- 3-5V serial interface (auto)
- 5-38V wide voltage switching power supply
- ARDUINO & RASPERRY PI direct compatibility
- Windows and Linux PC connectivity
- Audio jacks (high power audio out-700 mW RMS, in- capacitor MIC)
- Ideal for small-medium series gadget / project integration
More about a-gsm shield >> presentation and features, documentation and more.
RaspberryPI and a-gsm shield can communicate together in TWO ways: using the RPI serial port (TXD0 + RXD0) or via the USB connection. The second one is quite useful when the RPI serial port it is not available (Eg. it's designated to support serial communication with other shields). IMPORTANT: This tutorial it's based on RPI B/RPI B+/RPI2 usage, but can be easy ported to RPI A or RPI A+ or RPI Zero. You must identify the RPI A pin configuration. For RPI Zero you can use the same pin-out as for RPI B+/RPI2 model B.
See in picture up there, the top picture off a-gsm shield with details description.
What you will need
- Raspberry PI model B+ or Raspberry PI2 model B (Raspberry PI A+ can be used. You must hack the wiring. Also RPI ZERO can be used!) 1 pcs http://raspberrypi.org
- power supply for Raspberry PI 1 pcs
- a-gsm shield v2.064 1 pcs. a-gsm shield distributors
- GSM (2G) SIM card, for a-gsm 1 pcs
- optional (read bellow) power supply for the a-gsm shield (5V, ~1A... any decent Android phone/iPhone power adapter with uUSB type B connector) or external 6->38V, ~1A(recommended) for powering via a-gsm pin Vin 1 pcs
- USB cable and connection wires
General considerations and references
All shell commands must be run as root or using roots right. "sudo your_command"
Step 1: Wiring (logical and Powering) Reference
The drawings up here may be used as general wiring guidelines, but in order to chose your final configuration you must read the sections bellow.
IMPORTANT! Mandatory for RPi serial for connection with a-gsm (you can skip this for USB connection usage).
You may like to have available the RPI serial line >> use vi or mcedit or any other editor at your convenience. Comment last "/etc/inittab" line:
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
then, reboot your RPi: "reboot" or "restart now".
Step 2: SERIAL Wiring for Raspberry PI and A-gsm Shield * Serial, Power and Modem Control (logical)
RPI a-gsm shield serial and modem control description
can be seen in picture up-there
POWER using via a-gsm Vin PIN for serial connection
You can use any good quality external power adapter providing a voltage between 5.125V and 38V and supporting a current bigger than 1 A. Connect spare GND PIN located on "Arduino power in connector" on a-gsm shield with the GND pin on your external power adapter. Connect the Vin PIN located on "Arduino power in connector" on a-gsm shield with the Vout pin on your external power adapter. The a-gsm's POWER supply input selector must be in "use Vin" position.
Power via USB variant for serial connection
Power the a-gsm board over USB, using a good quality power adaptor (eg. your Arduino/iPhone power adapter). The a-gsm's POWER supply input selector must be in "use USB" position.
Power using the RPI 5V PIN for serial connection
Connect PIN 02/04 on Raspberry PI B+ extension connector with 5V PIN on "Arduino power in connector" on a-gsm shield. The a-gsm's POWER supply input selector must be in "use 5V" position.
IMPORTANT!!! The RPI power supply adapter must be rated for a minimum 2A sustained load without decrease supplied voltage under 5.05-5.10 V, in order to cover powering need for both boards regardless application, location, time...
Step 3: USB Wiring for Raspberry PI and A-gsm Shield * Serial, Power and Modem Control (logical)
Power using via a-gsm Vin PIN for USB connection
You can use any good quality external power adapter providing a voltage between 5.125V and 38V and supporting a current bigger than 1 A. Connect spare GND PIN located on "Arduino power in connector" on a-gsm shield with the GND pin on your external power adapter. Connect the Vin PIN located on "Arduino power in connector" on a-gsm shield with the Vout pin on your external power adapter. The a-gsm's POWER supply input selector must be in "use Vin" position.
Power via USB variant for USB connection
YOU MUST use a special USB Y adapter cable! Power the a-gsm board over USB, using a good quality power adaptor (eg. your Arduino/iPhone power adaptor), using "POWER ONLY" end of your USB Y adapter cable. The "DATA ONLY" end of your USB Y adapter cable, must be connected to any RPI USB port. The a-gsm's POWER supply input selector must be in "use USB" position.
Power using the RPI 5V PIN for USB connection
Connect PIN 02/04 on Raspberry PI B+ extension connector with 5V PIN on "Arduino power in connector" on a-gsm shield. The a-gsm's POWER supply input selector must be in "use 5V" position.
WARNING: Regardless the powering schema variant chosen, be sure than you check twice the wiring and be warned regarding the GROUND possible voltage differences(when use external power adapter), before you power the RPI a-gsm bundle.
RPI a-gsm USB connection, software setup considerations
USB connectivity has been tested using 2015-02-16-raspbian-wheezy on RPI2
After USB cabling you will notice in the /var/syslog:
... raspberrypi kernel: [ 2481.862240] usb 1-1.3: cp210x converter now attached to ttyUSB0
In our Python example files (can be downloaded from here - your email address and the modem IMEI are required) and in your custom Python files, you must set:
agsm = serial.Serial("/dev/ttyUSB0", serialSpeed, timeout=1)
instead of
agsm = serial.Serial("/dev/ttyAMA0", serialSpeed, timeout=1)
We suggest to you to use the newest RASPBIAN versions https://www.raspberrypi.org/downloads/. As backup, if something goes wrong, you can still use the 2015-02-16 version, used by us for testing. You can download it from here: http://itbrainpower.net/a-gsm/downloadables/2015-...
That's all you need in order to be able to use directly the Raspberry PI and a-gsm shield with communication via USB.
The a-gsm shield can be ordered online via itbrainpower.net distributors.
Originally published by me in 2015, on itbrainpower.net projects and how to section.