Skip to content

class_tiny_gsm_sim70xx

Sara Damiano edited this page Sep 11, 2026 · 2 revisions

title: TinyGsmSim70xx

TinyGsmSim70xx (class)

Module: TinyGsmSim70xx

Parent class for the SIMCom SIM70xx family of modems.

#include <src/TinyGsmClientSIM70xx.h>

Inherits from TinyGsmModem<SIM70xxType, SIM70xxModemConfig>, TinyGsmGPRS<SIM70xxType>, TinyGsmGPS<SIM70xxType>

Public Types

Name
typedef SIM70xxModemConfig ModemConfig
typedef typename ModemConfig::RegStatus regStatusType

Basic functions

Public Functions

Name
bool begin(const char * pin = nullptr)
Sets up the GSM module.
bool init(const char * pin = nullptr)
Sets up the GSM module.
void sendAT(Args... cmd)
Recursive variadic template to send AT commands.
bool setBaud(uint32_t baud)
Set the module baud rate.
bool setDefaultBaud(uint32_t baud)
Set the default baud rate for the modem, ie, the baud rate that the modem will use after a reset or power cycle.
bool forceModemBaud(StreamObject & at_serial, uint32_t targetBaud)
Attempt to set the modem baud rate by trying set the command to change the baud rate to various common baud rates and seeing if the modem responds to AT commands at that baud rate.
bool testAT(uint32_t timeout_ms = 10000L)
Test response to AT commands.
int8_t waitResponse(uint32_t timeout_ms, String & data, GsmConstStr r1 = ModemConfig::GSM_OK, GsmConstStr r2 = ModemConfig::GSM_ERROR, GsmConstStr r3 = nullptr, GsmConstStr r4 = nullptr, GsmConstStr r5 = nullptr, GsmConstStr r6 = nullptr, GsmConstStr r7 = nullptr, GsmConstStr r8 = nullptr)
Listen for responses to commands and handle URCs.
String getConfiguredModem()
Gets the configured modem manufacture and model based on the compile-time traits.
String getModemInfo()
Asks for modem information via the 3GPP TS 27.007 standard ATI command.
String getModemName()
Get the modem name - a combination of the manufacturer and model, as the modem calls itself.
String getModemManufacturer()
Get the modem manufacturer.
String getModemModel()
Get the modem model.
String getModemRevision()
Get the modem revision information.
String getModemSerialNumber()
Get the modem serial number.
bool factoryDefault()
Reset the module to factory defaults.

Power functions

Public Functions

Name
bool restart(const char * pin = nullptr)
Restart the module.
bool poweroff()
Power off the module.
bool powerOff()
Power off the module.
bool radioOff()
Turn off the module radio.
bool sleepEnable(bool enable = true)
Enable sleep on the module.
bool setPhoneFunctionality(uint8_t fun, bool reset = false)
Set the phone functionality.

Generic network functions

Public Functions

Name
regStatusType getRegistrationStatus()
Get the modem registration status on the network.
bool isNetworkConnected()
Confirm whether the module is currently connected to the GSM/GPRS/LTE network.
bool waitForNetwork(uint32_t timeout_ms = 60000L, bool check_signal = false)
Wait until the module has connected to the network.
int16_t getSignalQuality()
Get the signal quality report.
String getLocalIP()
Get the Local IP address assigned to the module by the network as a String.
IPAddress localIP()
Get the Local IP address assigned to the module by the network as an IPAddress object.

Utilities

Public Functions

Name
void streamWrite(T last)
Write a value to the modem stream.
void streamClear()
Clear the modem stream attempting to parse any URC's in it.
void streamDump(int16_t expected_len)
Dump the modem stream, completely discarding any data in it without attempting to parse any URC's in it.

SIM card functions

Public Functions

Name
bool simUnlock(const char * pin)
Unlock the SIM card with a PIN code.
String getSimCCID()
Get the SIM card's CCID via AT+CCID.
String getIMEI()
Get the modem's TA Serial Number Identification (IMEI) via AT+GSN.
String getIMSI()
Get the modem's International Mobile Subscriber Identity (IMSI) via AT+CIMI.
SimStatus getSimStatus(uint32_t timeout_ms = 10000L)
Get the SIM card status.

GPRS functions

Public Functions

Name
bool gprsConnect(const char * apn, const char * user = nullptr, const char * pwd = nullptr)
Connect to a GPRS network.
bool gprsDisconnect()
Disconnect from the GPRS network.
bool isGprsConnected()
Check if currently attached to GPRS/EPS service.
String getOperator()
Get the current network operator.
String getProvider()
Get the current network provider.

GPS (GNSS, GLONASS) functions

Public Functions

Name
bool enableGPS()
Enable the GPS module.
bool disableGPS()
Disable the GPS module.
String getGPSraw()
Get the raw GPS data string.
bool getGPS(float * lat, float * lon, float * speed = 0, float * alt = 0, int * vsat = 0, int * usat = 0, float * accuracy = 0, int * year = 0, int * month = 0, int * day = 0, int * hour = 0, int * minute = 0, int * second = 0)
Get the GPS location data.
bool getGPSTime(int * year, int * month, int * day, int * hour, int * minute, int * second)
Get the time associated with the GPS data.
String setGNSSMode(uint8_t mode, bool dpo)
Set the GNSS mode.
uint8_t getGNSSMode()
Get the current GNSS mode.

Public Functions

Name
String getNetworkModes()
Get the available network modes of the modem.
int16_t getNetworkMode()
Get the current network mode of the modem.
bool setNetworkMode(uint8_t mode)
Set the network mode of the modem.
String getPreferredModes()
Get the available preferred network modes of the modem.
int16_t getPreferredMode()
Get the current preferred network mode of the modem.
bool setPreferredMode(uint8_t mode)
Set the preferred network mode of the modem.
bool getNetworkSystemMode(bool & n, int16_t & stat)
Get the network system mode of the modem.
bool setNetworkSystemMode(bool n)
Set the network system mode of the modem.

Public Attributes

Name
Stream & stream
Stream used to communicate with the modem.

Public Types Documentation

typedefModemConfig

;

typedefregStatusType

;

Public Functions Documentation

functiongetNetworkModes

String getNetworkModes()
  • Return: A string representing the available network modes.

functiongetNetworkMode

int16_t getNetworkMode()
  • Return: The current network mode as an integer.

functionsetNetworkMode

bool setNetworkMode(uint8_t mode)
  • Parameters:
    • mode The network mode to set.
  • Return: True if the operation was successful, false otherwise.

functiongetPreferredModes

String getPreferredModes()
  • Return: A string representing the available preferred network modes.

functiongetPreferredMode

int16_t getPreferredMode()
  • Return: The current preferred network mode as an integer.

functionsetPreferredMode

bool setPreferredMode(uint8_t mode)
  • Parameters:
    • mode

      The preferred network mode to set.

      • 1 CAT-M
      • 2 NB-IoT
      • 3 CAT-M and NB-IoT
  • Return: True if the operation was successful, false otherwise.

functiongetNetworkSystemMode

bool getNetworkSystemMode(bool & n, int16_t & stat)
  • Parameters:
    • n A reference to a boolean that will be set to true if the modem is in automatic reporting mode, false otherwise.
    • stat A reference to an integer that will be set to the current service status. 0 if not connected.
  • Return: True if the operation was successful, false otherwise.

functionsetNetworkSystemMode

bool setNetworkSystemMode(bool n)
  • Parameters:
    • n A boolean indicating whether to enable automatic reporting of the system mode info.
  • Return: True if the operation was successful, false otherwise.

Public Attributes Documentation

variablestream

Stream & stream;

Public Functions Documentation

Basic functions

functionbegin

bool begin(const char * pin = nullptr)
  • Parameters:
    • pin A pin code to unlock the SIM, if necessary
  • Return: True if the module was set up as expected, false otherwise.

functioninit

bool init(const char * pin = nullptr)
  • Parameters:
    • pin A pin code to unlock the SIM, if necessary
  • Return: True if the module was set up as expected, false otherwise.

functionsendAT

void sendAT(Args... cmd)
  • Parameters:
    • cmd The commands to send

functionsetBaud

bool setBaud(uint32_t baud)

Note

After setting and applying the new baud rate, you will have to end() and begin() the serial object.

  • Parameters:
    • baud The baud rate to use
  • Return: True if the baud rate was set successfully, false otherwise.

functionsetDefaultBaud

bool setDefaultBaud(uint32_t baud)
  • Parameters:
    • baud The baud rate to set the modem to use after a reset or power cycle.
  • Return: True if the command was successful, false otherwise.

functionforceModemBaud

bool forceModemBaud(StreamObject & at_serial, uint32_t targetBaud)

Unlike TinyGsmAutoBaud, this function will try to set the baud rate on the modem and will attempt to communicate with the modem at the new baud rate whether or not it gets a response at the old baud rate. This is useful in cases where the modem is set to a baud rate that is just a little too fast for the processor, where you might get a response but it will be garbled and not recognized as a response, because in this case you still want to try to set the baud rate.

Note

After setting and applying the new baud rate, you will have to end() and begin() the serial object.

  • Parameters:
    • at_serial The serial object to use for communicating with the modem
    • targetBaud The final baud rate to try to set the modem to
  • Return: True if the modem responded after the baud rate was set, false otherwise.

functiontestAT

bool testAT(uint32_t timeout_ms = 10000L)
  • Parameters:
    • timeout_ms the amount of time to test for; optional with a default value of 10s.
  • Return: True if the module responded to AT commands, false otherwise.

functionwaitResponse

int8_t waitResponse(uint32_t timeout_ms, String & data, [GsmConstStr](../files/_tiny_gsm_common_8h.md#a9c8c9c8249f99863e157f8fae76e7cab) r1 = ModemConfig::GSM_OK, [GsmConstStr](../files/_tiny_gsm_common_8h.md#a9c8c9c8249f99863e157f8fae76e7cab) r2 = ModemConfig::GSM_ERROR, [GsmConstStr](../files/_tiny_gsm_common_8h.md#a9c8c9c8249f99863e157f8fae76e7cab) r3 = nullptr, [GsmConstStr](../files/_tiny_gsm_common_8h.md#a9c8c9c8249f99863e157f8fae76e7cab) r4 = nullptr, [GsmConstStr](../files/_tiny_gsm_common_8h.md#a9c8c9c8249f99863e157f8fae76e7cab) r5 = nullptr, [GsmConstStr](../files/_tiny_gsm_common_8h.md#a9c8c9c8249f99863e157f8fae76e7cab) r6 = nullptr, [GsmConstStr](../files/_tiny_gsm_common_8h.md#a9c8c9c8249f99863e157f8fae76e7cab) r7 = nullptr, [GsmConstStr](../files/_tiny_gsm_common_8h.md#a9c8c9c8249f99863e157f8fae76e7cab) r8 = nullptr)
  • Parameters:
    • timeout_ms The time to wait for a response
    • data A string of data to fill in with response results
    • r1 The first output to test against, optional with a default value of "OK"
    • r2 The second output to test against, optional with a default value of "ERROR"
    • r3 The third output to test against, optional with a default value of nullptr
    • r4 The fourth output to test against, optional with a default value of nullptr
    • r5 The fifth output to test against, optional with a default value of nullptr
    • r6 The sixth output to test against, optional with a default value of nullptr
    • r7 The seventh output to test against, optional with a default value of nullptr
    • r8 The eighth output to test against, optional with a default value of nullptr
  • Return: the index of the response input

functiongetConfiguredModem

String getConfiguredModem()

Tip

This does not query the modem for its actual manufacture and model, but rather returns the values that were set at compile time.

  • Return: The configured modem manufacture and model based on the compile-time traits.

functiongetModemInfo

String getModemInfo()

Note

The actual value and style of the response is quite varied

  • Return: Some info about the GSM module.

functiongetModemName

String getModemName()
  • Return: The modem name

functiongetModemManufacturer

String getModemManufacturer()
  • Return: The modem manufacturer

functiongetModemModel

String getModemModel()
  • Return: The modem model, as it calls itself

functiongetModemRevision

String getModemRevision()

What is returned as the revision may be either a hardware or a firmware version or some combination of both.

  • Return: The modem revision information

functiongetModemSerialNumber

String getModemSerialNumber()

This is usually equivalent to the IMEI for cellular modems and the MAC address for WiFi modems.

  • Return: The modem serial number

functionfactoryDefault

bool factoryDefault()

This generally restarts the module as well.

  • Return: True if the module successfully reset to default, false otherwise.

Power functions

functionrestart

bool restart(const char * pin = nullptr)
  • Parameters:
    • pin A pin code to unlock the SIM, if necessary
  • Return: True if the module was successfully restarted, false otherwise.

functionpoweroff

bool poweroff()

Deprecated: deprecated

  • Deprecated: deprecated
  • Return: True if the module was successfully powered down, false otherwise.

functionpowerOff

bool powerOff()
  • Return: True if the module was successfully powered down, false otherwise.

functionradioOff

bool radioOff()
  • Return: True if the module radio was successfully turned off, false otherwise.

functionsleepEnable

bool sleepEnable(bool enable = true)

For some modules this immediately puts the module to sleep, for others this sets them to be able to sleep based on pin levels.

  • Parameters:
    • enable True to enable sleep, false to disable
  • Return: True if sleep was successfully enabled or disabled, false otherwise.

functionsetPhoneFunctionality

bool setPhoneFunctionality(uint8_t fun, bool reset = false)
  • Parameters:
    • fun The phone functionality setting. The value and meaning of this varies by module; check your documentation.
    • reset True to reset the module before changing the functionality.
  • Return: True if the phone functionality was successfully changed, false otherwise.

Generic network functions

functiongetRegistrationStatus

regStatusType getRegistrationStatus()
  • Return: The modem-specific registration status value.

functionisNetworkConnected

bool isNetworkConnected()
  • Return: True if the module is connected to the network, false otherwise.

functionwaitForNetwork

bool waitForNetwork(uint32_t timeout_ms = 60000L, bool check_signal = false)
  • Parameters:
    • timeout_ms The time to wait for attachment in milliseconds. Optional with a default value of 1 minute.
    • check_signal True to alternate between checking for connection and checking the signal strength.
  • Return: True if the module is now connected to the network, false otherwise.

functiongetSignalQuality

int16_t getSignalQuality()

This is often a "CSQ" value ranging from 0 to 32, but may be an RSSI or a percent.

  • Return: The signal quality

functiongetLocalIP

String getLocalIP()
  • Return: The local IP address

functionlocalIP

IPAddress localIP()
  • Return: The local IP address

Utilities

functionstreamWrite

void streamWrite(T last)
  • Parameters:
    • last The value to write.

functionstreamClear

void streamClear()

Warning

Never call this inside of a waitResponse() call or a URC parser!

Todo: todo

functionstreamDump

void streamDump(int16_t expected_len)

This is good for discarding an expected number of characters from the stream without waiting a full timeout for each character.

Todo: todo

  • Parameters:
    • expected_len The number of characters to discard from the stream.

SIM card functions

functionsimUnlock

bool simUnlock(const char * pin)
  • Parameters:
    • pin The PIN code to unlock the SIM card.
  • Return: True if the SIM card was successfully unlocked, false otherwise

functiongetSimCCID

String getSimCCID()
  • Return: The SIM card's CCID as a String.

functiongetIMEI

String getIMEI()
  • Return: The modem's IMEI as a String.

functiongetIMSI

String getIMSI()
  • Return: The modem's IMSI as a String.

functiongetSimStatus

[SimStatus](../files/_tiny_gsm_g_p_r_s_8tpp.md#a88faf9e645594ddb7300d159bc0fe5e0) getSimStatus(uint32_t timeout_ms = 10000L)
  • Parameters:
    • timeout_ms The timeout in milliseconds to wait for a response.
  • Return: The SIM card status as a SimStatus enum value.

GPRS functions

functiongprsConnect

bool gprsConnect(const char * apn, const char * user = nullptr, const char * pwd = nullptr)
  • Parameters:
    • apn The Access Point Name (APN) of the network.
    • user The username for the APN (optional).
    • pwd The password for the APN (optional).
  • Return: True if the connection was successful, false otherwise.

functiongprsDisconnect

bool gprsDisconnect()
  • Return: True if the disconnection was successful, false otherwise.

functionisGprsConnected

bool isGprsConnected()
  • Return: True if connected, false otherwise.

functiongetOperator

String getOperator()
  • Return: The current network operator as a String.

functiongetProvider

String getProvider()
  • Return: The current network provider as a String.

GPS (GNSS, GLONASS) functions

functionenableGPS

bool enableGPS()
  • Return: True if the GPS module was successfully enabled, false otherwise.

functiondisableGPS

bool disableGPS()
  • Return: True if the GPS module was successfully disabled, false otherwise.

functiongetGPSraw

String getGPSraw()
  • Return: The raw GPS data string.

functiongetGPS

bool getGPS(float * lat, float * lon, float * speed = 0, float * alt = 0, int * vsat = 0, int * usat = 0, float * accuracy = 0, int * year = 0, int * month = 0, int * day = 0, int * hour = 0, int * minute = 0, int * second = 0)
  • Parameters:
    • lat Pointer to store the latitude.
    • lon Pointer to store the longitude.
    • speed Pointer to store the speed (optional).
    • alt Pointer to store the altitude (optional).
    • vsat Pointer to store the number of visible satellites (optional).
    • usat Pointer to store the number of used satellites (optional).
    • accuracy Pointer to store the accuracy (optional).
    • year Pointer to store the year (optional).
    • month Pointer to store the month (optional).
    • day Pointer to store the day (optional).
    • hour Pointer to store the hour (optional).
    • minute Pointer to store the minute (optional).
    • second Pointer to store the second (optional).
  • Return: True if the GPS data was successfully retrieved, false otherwise.

functiongetGPSTime

bool getGPSTime(int * year, int * month, int * day, int * hour, int * minute, int * second)
  • Parameters:
    • year Pointer to store the year.
    • month Pointer to store the month.
    • day Pointer to store the day.
    • hour Pointer to store the hour.
    • minute Pointer to store the minute.
    • second Pointer to store the second.
  • Return: True if the GPS time data was successfully retrieved, false otherwise.

functionsetGNSSMode

String setGNSSMode(uint8_t mode, bool dpo)
  • Parameters:
    • mode The GNSS mode to set.
    • dpo Whether to enable or disable DPO.
  • Return: The result of the operation.

functiongetGNSSMode

uint8_t getGNSSMode()
  • Return: The current GNSS mode.

Generated by Doxygen and m.css with templates from doxybook2 Updated on 2026-09-11

Clone this wiki locally