Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

TinyGSM

> 编程语言
Open source

A small Arduino library for GSM modules, that just works

2.2K stars0 likes0 views
WebsiteGitHub

About

A small Arduino library for GSM modules, that just works

A small Arduino library for GSM modules, that just works. If you like TinyGSM - give it a star, or fork it and contribute! You can also join our chat:

  • Supported modems
    • Supported boards/modules
  • Features
  • Getting Started
    • First Steps
    • Writing your own code
    • If you have any issues
  • How does it work?
  • API Reference
  • Troubleshooting
    • Ensure stable data & power connection
    • Baud rates
    • Broken initial configuration
    • Failed connection or no data received
    • Diagnostics sketch
    • Web request formatting problems - "but it works with PostMan"
    • SoftwareSerial problems
    • ESP32 Notes
      • HardwareSerial
      • HttpClient
    • SAMD21
    • Goouuu Tech IOT-GA6 vs AI-Thinker A6 confusion
    • SIM800 and SSL
    • Which version of the SIM7000 code to use
  • License

Arduino Client interface support

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.

TinyGSM is tiny

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.

Supported modems

  • SIMCom SIM800 series (SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868)
  • SIMCom SIM900 series (SIM900A, SIM900D, SIM908, SIM968)
  • SIMCom WCDMA/HSPA/HSPA+ Modules (SIM5360, SIM5320, SIM5300E, SIM5300E/A)
  • SIMCom LTE Modules (SIM7100E, SIM7500E, SIM7500A, SIM7600C, SIM7600E)
  • SIMCom SIM7000E/A/G CAT-M1/NB-IoT Module
  • SIMCom SIM7070/SIM7080/SIM7090 CAT-M1/NB-IoT Module
  • SIMCom A7672X CAT-M1 Module
  • AI-Thinker A6, A6C, A7, A20
  • ESP8266/ESP32 (AT commands interface, similar to GSM modems)
  • Digi XBee WiFi and Cellular (using XBee command mode)
  • Neoway M590
  • u-blox 2G, 3G, 4G, and LTE Cat1 Cellular Modems (many modules including LEON-G100, LISA-U2xx, SARA-G3xx, SARA-U2xx, TOBY-L2xx, LARA-R2xx, MPCI-L2xx)
  • u-blox LTE-M/NB-IoT Modems (SARA-R4xx, SARA-N4xx, SARA-R5xx, but NOT SARA-N2xx)
  • Sequans Monarch LTE Cat M1/NB1 (VZM20Q)
  • Quectel BG96
  • Quectel BG95
  • Quectel M95
  • Quectel MC60 (alpha)

Supported boards/modules

  • EnviroDIY LTE Bee, WiFi Bee
  • Arduino MKR GSM 1400
  • Sodaq GPRSbee, uBee
  • Microduino GSM
  • Adafruit FONA Mini Cellular GSM Breakout, 800/808 Shield, FONA 3G
  • Industruino GSM
  • Dragino NB-IoT Bee
  • Digi XBee S6B, XBee LTE Cat 1, XBee3 LTE Cat 1, XBee3 CatM
  • Nimbelink Skywire/Airgain NL-SW-LTE-QBG96, NL-SW-LTE-QBG95
  • RAK WisLTE (alpha)
  • ... other modules, based on supported modems. Some boards require special configuration.

Watch this repo for new updates! And of course, contributions are welcome ;)

Features

Data connections

  • TCP (HTTP, MQTT, Blynk, ...)
    • ALL modules support TCP connections
    • Most modules support multiple simultaneous connections:
      • A6/A7 - 8
      • ESP8266 - 5
      • Neoway M590 - 2
      • Quectel BG96 - 12
      • Quectel BG95 - 12
      • Quectel M95 - 6
      • Quectel MC60/MC60E - 6
      • Sequans Monarch - 6
      • SIM 800/900 - 5
      • SIM 5360/5320/5300/7100 - 10
      • SIM7000 - 8 possible without SSL, only 2 with
      • SIM 7070/7080/7090 - 12
      • SIM 7500/7600/7800 - 10
      • SIM A7672X - 10
      • u-blox 2G/3G - 7
      • u-blox SARA R4/N4 - 7
      • Digi XBee - only 1 connection supported!
  • UDP
    • Not yet supported on any module, though it may be some day
  • SSL/TLS (HTTPS)
    • Supported on:
      • SIM800, SIM7000, A7672X, u-Blox, XBee cellular, ESP8266, Sequans Monarch and Quectel BG95 and BG96
      • Note: only some device models or firmware revisions have this feature (SIM8xx R14.18, A7, etc.)
    • Not yet supported on:
      • SIM 5360/5320/7100, SIM 7500/7600/7800
    • Not possible on:
      • SIM900, A6/A7, Neoway M590, XBee WiFi
    • Like TCP, most modules support simultaneous connections
    • TCP and SSL connections can usually be mixed up to the total number of possible connections

USSD

  • Sending USSD requests and decoding 7,8,16-bit responses
    • Supported on:
      • All SIMCom modems, Quectel modems, most u-blox
    • Not possible on:
      • XBee, u-blox SARA R4/N4, ESP8266 (obviously)

SMS

  • Only sending SMS is supported, not receiving
    • Supported on all cellular modules

Voice Calls

  • Supported on:
    • SIM800/SIM900, SIM7600, A6/A7, Quectel modems, u-blox
  • Not yet supported on:
    • SIM7000, SIM5360/5320/7100, SIM7500/7800, VZM20Q (Monarch)
  • Not possible on:
    • XBee (any type), u-blox SARA R4/R5/N4, Neoway M590, ESP8266 (obviously)
  • Functions:
    • Dial, hangup
    • DTMF sending

Location

  • GPS/GNSS
    • SIM808, SIM7000, SIM7500/7600/7800, BG96, BG95, u-blox
    • NOTE: u-blox chips do NOT have embedded GPS - this functionality only works if a secondary GPS is connected to primary cellular chip over I2C
  • GSM location service
    • SIM800, SIM7000, Quectel, u-blox

Credits

  • Primary Authors/Contributors:
    • vshymanskyy
    • SRGDamia1
  • SIM7000:
    • captFuture
    • FStefanni
  • Sequans Monarch:
    • nootropicdesign
  • Quectel M9C60
    • V1pr
  • Quectel M95
    • replicadeltd
  • UBLOX SARA-R5
    • Sebastian Bergner
  • SIMCOM A7672X
    • Giovanni de Rosso Unruh
  • Other Contributors:
    • https://github.com/vshymanskyy/TinyGSM/graphs/contributors

Getting Started

First Steps

  1. Using your phone: - Disable PIN code on the SIM card - Check your balance - Check that APN, User, Pass are correct and you have internet
  2. Ensure the SIM card is correctly inserted into the module
  3. Ensure that GSM antenna is firmly attached
  4. Ensure that you have a stable power supply to the module of at least 2A.
  5. Check if serial connection is working (Hardware Serial is recommended) Send an AT command using this sketch
  6. Try out the WebClient example

Writing your own code

The general flow of your code should be:

  • Define the module that you are using (choose one and only one)
    • ie, #define TINY_GSM_MODEM_SIM800
  • Included TinyGSM
    • #include <TinyGsmClient.h>
  • Create a TinyGSM modem instance
    • TinyGsm modem(SerialAT);
  • Create one or more TinyGSM client instances
    • For a single connection, use
      • TinyGsmClient client(modem);

      or TinyGsmClientSecure client(modem); (on supported modules)

    • For multiple connections (on supported modules) use:
      • TinyGsmClient clientX(modem, 0);, TinyGsmClient clientY(modem, 1);, etc or
      • TinyGsmClientSecure clientX(modem, 0);, TinyGsmClientSecure clientY(modem, 1);, etc
    • Secure and insecure clients can usually be mixed when using multiple connections.
    • The total number of connections possible varies by module
  • Begin your serial communication and set all your pins as required to power your module and bring it to full functionality.
    • The examples attempt to guess the module's baud rate. In working code, you should use a set baud.
  • Wait for the module to be ready (could be as much as 6s, depending on the module)
  • Initialize the modem
    • modem.init() or modem.restart()
    • restart generally takes longer than init but ensures the module doesn't have lingering connections
  • Unlock your SIM, if necessary:
    • modem.simUnlock(GSM_PIN)
  • If using WiFi, specify your SSID information:
    • modem.networkConnect(wifiSSID, wifiPass)
    • Network registration should be automatic on cellular modules
  • Wait for network registration to be successful
    • modem.waitForNetwork(600000L)
  • If using cellular, establish the GPRS or EPS data connection after your are successfully registered on the network
    • modem.gprsConnect(apn, gprsUser, gprsPass) (or simply modem.gprsConnect(apn))
    • The same command is used for both GPRS or EPS connection
    • If using a Digi brand cellular XBee, you must specify your GPRS/EPS connection information before waiting for the network. This is true ONLY for Digi cellular XBees! For all other cellular modules, use the GPRS connect function after network registration.
  • Connect the TCP or SSL client client.connect(server, port)
  • Send out your data.

If you have any issues

  1. Read the whole README (you're looking at it!), particularly the troubleshooting section below.
  2. Some boards require special configuration.
  3. Try running the Diagnostics sketch
  4. Check for highlighted topics here
  5. If you have a question, please post it in our Gitter chat

How does it work?

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.

This library is "blocking" in all of its communication. Depending on the function, your code may be blocked for a long time waiting for the module responses. Apart from the obvious (ie, waitForNetwork()) several other functions may block your code for up to several minutes. The gprsConnect() and client.connect() functions commonly block the longest, especially in poorer service regions. The module shutdown and restart may also be quite slow.

This libary does not support any sort of "hardware" or pin level controls for the modules. If you need to turn your module on or reset it using some sort of High/Low/High pin sequence, you must write those functions yourself.

API Reference

For GPRS data streams, this library provides the standard Arduino Client interface. For additional functions, please refer to this example sketch

Troubleshooting

Ensure stable data & power connection

Most modules require as much as 2A to properly connect to the network. This is 4x what a "standard" USB will supply! Improving the power supply actually solves stability problems in many cases!

  • Read about [powering your module](https://github.com/vshymanskyy/TinyGSM/wiki/Pow

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •Supported modems
  • •Supported boards/modules
  • •Features
  • •Getting Started
  • •First Steps
  • •Writing your own code
  • •If you have any issues
  • •How does it work?
  • •API Reference
  • •Troubleshooting

> Tags

C++a6a7arduinoblynk

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言