A small Arduino library for GSM modules, that just works.
If you like TinyGSM - give it a star, or fork it and contribute!
This library is easy to integrate with lots of sketches which use Ethernet or WiFi. PubSubClient (MQTT), Blynk, HTTP Client and File Download examples are provided.
The complete WebClient example for Arduino Uno (via Software Serial) takes little resources:
Sketch uses 15022 bytes (46%) of program storage space. Maximum is 32256 bytes.
Global variables use 574 bytes (28%) of dynamic memory, leaving 1474 bytes for local variables. Maximum is 2048 bytes.
Arduino GSM library uses 15868 bytes (49%) of Flash and 1113 bytes (54%) of RAM in a similar scenario. TinyGSM also pulls data gently from the modem (whenever possible), so it can operate on very little RAM. Now, you have more space for your experiments.
Feature \ Modem | SIM8xx | u-Blox | A6/A7/A20 | Neoway M590 | ESP8266 | Digi XBee | Quectel BG96 | Quectel M95 | Quectel MC60(E) | SIM7000 |
---|---|---|---|---|---|---|---|---|---|---|
Data connections | ||||||||||
TCP (HTTP, MQTT, Blynk, ...) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | |
UDP | ◌ | ◌ | ◌ | ◌ | ◌ | |||||
SSL/TLS (HTTPS) | ✔¹ | ✔ | x | x | ✔ | ✔ | ◌ | ◌ | ||
USSD | ||||||||||
Sending USSD requests | ✔ | ✔ | ✔ | x | ✔ | |||||
Decoding 7,8,16-bit response | ✔ | ✔ | ✔ | x | ✔ | |||||
SMS | ||||||||||
Sending | ✔ | ✔ | ✔ | ✔ | x | ✔ | ✔ | ✔ | ✔ | ✔ |
Sending Unicode | ✔ | ◌ | x | x | ✔ | ✔ | ✔ | ✔ | ||
Reading | x | |||||||||
Incoming message event | ? | x | ||||||||
Calls | ||||||||||
Dial, hangup | ✔ | ✔ | x | x | x | |||||
Receiving calls | ✔ | ✔ | x | x | x | |||||
Incoming event (RING) | ◌ | ◌ | x | x | x | |||||
DTMF sending | ✔ | ✔ | x | x | x | |||||
DTMF decoding | ◌ | x | x | x | x | |||||
Location | ||||||||||
GSM location service | ✔ | ✔ | x | x | x | x | x | ✔ | ✔ | |
GPS/GNSS | ✔¹ | x | ◌¹ | x | x | x | x | ✔ | ||
Credits | ||||||||||
Primary Author/Contributor | vshymanskyy | vshymanskyy | vshymanskyy | vshymanskyy | vshymanskyy | SRGDamia1 | vshymanskyy | replicadeltd | V1pr | captFuture |
✔ - implemented ◌ - planned x - not available on this modem ¹ - only some device models or firmware revisions have this feature (SIM8xx R14.18, A7, etc.)
- SIMCom SIM800 series (SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868)
- SIMCom SIM900 series (SIM900A, SIM900D, SIM908, SIM968)
- AI-Thinker A6, A6C, A7, A20
- ESP8266 (AT commands interface, similar to GSM modems)
- Digi XBee WiFi and Cellular (using XBee command mode)
- Neoway M590
- u-blox Cellular Modems (many modules including LEON-G100, LISA-U2xx, SARA-G3xx, SARA-U2xx, TOBY-L2xx, LARA-R2xx, MPCI-L2xx, SARA-R4xx, SARA-N4xx, but NOT SARA-N2xx)
- Quectel BG96 (alpha)
- Quectel M95 (alpha)
- Quectel MC60 (alpha)
- SIMCom SIM7000 series (alpha)
- Arduino MKR GSM 1400
- GPRSbee
- Microduino GSM
- Adafruit FONA (Mini Cellular GSM Breakout)
- Adafruit FONA 800/808 Shield
- Industruino GSM
- RAK WisLTE (alpha)
- ... other modules, based on supported modems. Some boards require special configuration.
More modems may be supported later:
- Sequans Monarch LTE Cat M1/NB1
- Quectel M10, UG95
- SIMCom SIM5320, SIM5360, SIM5216
- Telit GL865
- ZTE MG2639
- Hi-Link HLK-RM04
Watch this repo for new updates! And of course, contributions are welcome ;)
If you have found TinyGSM to be useful in your work, research or company, please consider making a donation to the project commensurate with your resources. Any amount helps! All donations will be used strictly to fund the development of TinyGSM:
- Covering cellular network expenses
- Buying new hardware and modems for integration
- Bounty Budget (to reward other developers for their contributions)
- Implementing new features
- Quality Assurance
- Using your phone: - Disable PIN code on the SIM card - Check your balance - Check that APN, User, Pass are correct and you have internet
- Ensure the SIM card is correctly inserted into the module
- Ensure that GSM antenna is firmly attached
- Check if serial connection is working (Hardware Serial is recommended)
Send an
AT
command using this sketch
If you have any issues:
- Read the whole README (you're looking at it!)
- Some boards require special configuration.
- Try running the Diagnostics sketch
- Check for highlighted topics here
- If you have a question, please post it in our Gitter chat
Many GSM modems, WiFi and radio modules can be controlled by sending AT commands over Serial. TinyGSM knows which commands to send, and how to handle AT responses, and wraps that into standard Arduino Client interface.
For GPRS data streams, this library provides the standard Arduino Client interface. For additional functions, please refer to this example sketch
Use this sketch to diagnose your SIM card and GPRS connection: File -> Examples -> TinyGSM -> tools -> Diagnostics
Most modules require up to 2A and specific voltage - according to the module documentation. So this actually solves stability problems in many cases:
- Provide a good stable power supply. Read about powering your module.
- Keep your wires as short as possible
- Consider soldering them for a stable connection
- Do not put your wires next to noisy signal sources (buck converters, antennas, oscillators etc.)
When using SoftwareSerial
(on Uno, Nano, etc), the speed 115200 may not work.
Try selecting 57600, 38400, or even lower - the one that works best for you.
In some cases 9600 is unstable, but using 38400 helps, etc.
Be sure to set correct TX/RX pins in the sketch. Please note that not every Arduino pin can serve as TX or RX pin.
Read more about SoftSerial options and configuration here and here.
When using ESP32 HardwareSerial
, you may need to specify additional parameters to the .begin()
call.
Please refer to this comment.
When using SAMD21-based boards, you may need to use a sercom uart port instead of Serial1
.
Please refer to this comment.
Sometimes (especially if you played with AT commands), your module configuration may become invalid. This may result in problems such as:
- Can't connect to the GPRS network
- Can't connect to the server
- Sent/received data contains invalid bytes
- etc.
To return module to Factory Defaults, use this sketch: File -> Examples -> TinyGSM -> tools -> FactoryReset
It turns out that Goouuu Tech IOT-GA6 is not the same as AI-Thinker A6. Unfortunately IOT-GA6 is not supported out of the box yet. There are some hints that IOT-GA6 firmware may be updated to match A6... See this topic.
This project is released under The GNU Lesser General Public License (LGPL-3.0)