In the previous tutorial, we learned how to use Raspberry Pi’s (RPi) serial hardware port for serial data communication over the universal asynchronous receiver/transmitter (UART) protocol. Most of the embedded devices have the UART port for exchanging console data. In fact, most of the sensor modules that are designed for peer communication with controllers/computers have the UART port for data communication. So, there are several sensor modules that can be interfaced with Raspberry Pi using its UART port.
Remember that RPi’s UART port is 3.3V and it should be connected with the compatible serial port. If the other device has a different UART voltage level, the suitable voltage level shift or serial adaptor must be used. For example, a device with the 5V TTL UART port can connect to RPi’s serial port of using a 5 to 3.3V TTL Logic Shifter.
Similarly, RPi’s UART port can be connected to the USB interface of a device using a USB-serial board. It can also be connected to the RS-232 port of a device using the RS-232-serial converter.
The serial ports of sensors and modules can be directly or indirectly interfaced with those of Raspberry Pi and to any desktop computer using a USB-serial board.
As Python is platform-independent, the script that works on RPi to receive serial data from a sensor can be used on any desktop computer by simply changing the serial port name.
In this tutorial, we’ll learn how to interface a SIM900A GSM-GPRS modem with Raspberry Pi and with any desktop computer. We’ll also discuss how to hack an ordinary earphone to make and receive voice calls over a SIM900A modem.
Wireless modems
Wireless connectivity is a widely accepted solution for data communication over long distances. For M2M IoT solutions, mobile connectivity is the only resort to guarantee data transfer with mobile devices and remotely-deployed “Things.” There are many wireless modules available from different vendors that can be used for data communication over a mobile network. These wireless modules are generally classified by the mobile network technology (2G, 3G, 4G, or 5G) or by the technology platform they use (GSM/GPRS, GSM/GPRS+GNSS, WCDMA/HSPA/HSPA+, LTE, NB-IoT, or GNSS).
These wireless modules are capable of communicating data in the form of voice calls, SMS, GPRS, faxes, and the Internet (TCP/IP, IP, HTTP, and FTP protocols).
SIMCOM is one of the largest vendors of wireless modules. Different wireless modems available from SIMCOM Limited for mobile connectivity are listed in this table:
On the basis of the technology platform, the SIMCOM modules are listed in this table:
Although 4G and 5G wireless modules are advanced modems offering the high speeds and features of 4G and 5G technologies, 2G wireless modules are still widely used in embedded applications. The 2G wireless modules are less costly and offer an optimum wireless solution where speed and latency are not an issue.
The SIM900A GSM-GPRS modem
SIM900 is a 2G wireless module that offers a Quad-Band 850/900/1800/1900 MHz GSM-GPRS solution. The modem features GPRS multi-slot class 10/class 8 (optional) and supports CS-1, CS-2, CS-3, and CS-4 GPRS encoding schemes.
This ultra-compact modem requires a supply voltage of 3.2 to 4.8V. It can be controlled via AT commands (GSM 07.07, 07.05, and SIMCOM enhanced AT Commands), which can be communicated through the serial interface (UART), I2C, and SPI.
It also has a single interface to an external SIM 3V/1.8V in which the Mini-SIM (2FF Form Factor), Micro-SIM (3FF Form Factor) and, NanoSIM (4FF Form Factor) can be plugged in.
The modem is equipped with a GPIO, PWM, ADC, and an analog audio interface so that it can have a MIC and audio and speaker input, as well as a display and keypad interface. It also comes with a built-in RTC.
Some of the prominent features of SIM900A modem are listed here:
The SIM900A modem has this pin diagram:
The SIM900A modem has this pin configuration:
Hardware & wiring
It’s fairly easy to wire the modem.
- The power supply pins 57, 56, and 55 should be connected to a 5V DC supply that’s capable of 2A bursts.
- The ground can be provided at pin 54 of the modem.
- The SIM card slot should be wired to pins 30 (the voltage supply for SIM card), 31 (the SIM data output), 32 (the SIM clock), 33 (the SIM reset), and 34 (the SIM detect).
The connections to the SIM card slot will depend on the type of SIM cardholder used for assembling the module. The image below shows the reference circuit for connections between SIM900A and an 8-pin SIM cardholder.
Now, the antenna must be connected to pin 60. To power ON/OFF the modem, a push button can be interfaced between pin 1 (PWRKEY) and pin 2 (PWRKEY_OUT). For the MIC input, pins 19 (microphone positive) and 20 (microphone negative) should be connected to a header.
Similarly, for speaker connections, pins 21 (speaker positive) and 22 (speaker negative) should also be connected to a header. For communicating with the modem over the UART protocol, pin 9 (serial transmission), 10 (serial receive), and 17 (ground) should be connected to a header.
The Txd and Rxd of SIM900A must connect to the Rxd and Txd of the controller/computer, respectively. The headers for serial communication over other protocols (I2C and SPI) can also be provided similarly. Additionally, the circuit connections for the UART hardware and software flow control can be provided through a header if required.
A reference circuit for SIM900A module is shown here:
You can design your own SIM900A module. The SIM900 Reference Design Guide is quite useful for this process. There are several ready-to-use modules for the SIM900A GSM-GPRS modem available in the market.
Here’s one example:
Note that this module has:
- A power supply socket that can be connected to an AC-to-DC adapter
- A SIM cardholder at its back
- Headers for the UART communication
- A MIC and speaker input, as well as serial modem lines.
- Also, the status LEDs and buzzer are connected in the module.
Interfacing the SIM900A GSM-GPRS module
It’s easy to interface the SIM900A module with Raspberry Pi, microcontrollers, and even desktop computers. You can use the UART, I2C, or SPI interfaces to connect the module serially with a controlling device.
For communicating over the UART protocol, simply connect the Txd and Rxd of the module with RPi’s Rxd and Txd using a 5 to 3.3V TTL Logic Shifter.
Remember that SIM900A is a 5V device with a 5V UART port. So, its UART port cannot be directly interfaced with RPi’s serial hardware port. But a simple 5V-3V3 Voltage Shifter can be designed using a 1N4148 diode.
Here’s a circuit diagram:
For making and receiving voice calls, the MIC and speaker input can be used…
Next, insert a SIM card in the SIM cardholder, power the module with an adapter, and it’s ready to operate.
For connecting the module with Arduino or any other 5V microcontroller, the UART port of the SIM900A modem can be directly connected to Arduino’s serial port (or a 5V controller).
It’s also possible to interface the modem with any desktop computer. It can be serially connected to any desktop system using a USB-serial board. However, the board must be configured to use 5V UART signals
Hacking earphones to receive/make voice calls
A typical earphone can serve as the MIC and speaker input for the SIM900A modem.
This image shows the pin configuration of common headset connectors:
For both MIC and speaker input, a headset or earphones with a microphone and speakers are required. The standard (Apple) connector is quite common in headsets and earphones for computers and mobile phones.
The microphone and speaker are internally connected to the connector like this:
- Solder two wires/jumper wires to the ground of the connector (for the MIC negative and speaker negative)
- Short the right and left audio of the connector (as there’s only one speaker input on the header)
- Solder a wire/jumper wire (for the speaker positive) to the shorted right and left audio of the connector
- Solder a wire/jumper wire (for the MIC positive) to the microphone of the connector.
For a clean solder, the connector can be stripped from the headset/earphone wire and the jumper wires can be directly soldered to the respective wires of microphone and speaker connections.
Typically, the headset/earphone cable will have this color coding:
After soldering the jumper wires to the headset/earphone, it should appear similar to this:
Most of the computer/mobile headsets and earphones draw low current and are already 5V TTL compatible.
Any 8-ohm speakers can also be connected to the SIM900A. However, to hack and connect the headset/earphone to the SIM900A, it must have an 8-ohm impedance.
For a better audio experience, the headset reference circuit or 1-Watt audio power amplifier is recommended (and supported in the SIM900A Reference Design Guide).
How the SIM900A modem works
The SIM900A GSM-GPRS modem can be controlled over the UART, I2C, or SPI interfaces. It simply needs to be serially connected to a controlling device, which can be RPi, Arduino, a microcontroller, or any desktop computer (via the USB-serial board).
The modem understands AT commands that can be passed to it through the UART, I2C, or SPI protocol. The controlling device is called terminal equipment (TE) or data terminal equipment (DTE). The modem may be referred to as mobile equipment (ME), mobile station (MS), terminal adapter (TA), or data communication equipment (DCE).
With the help of the AT commands, the modem can be checked, configured, and operated for making and receiving voice calls, faxes, GPRS data (SMS), MMS, as well as data over TCP/IP, IP, HTTP, and FTP protocols.
In the next tutorial, we’ll cover many of the AT commands for the SIM900A GSM-GPRS modem.
Filed Under: Raspberry pi
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.