GSMexample

In this example, we'll use a GSM module to connect to a mobile network the same way a phone does, and use it to access the internet and send an SMS.

Hardware you'll need:

  • ESP32 or other IoT.Cafe-supported main board
  • SIM800L module or compatible
  • A SIM card with mobile data and able to send SMS

Let's go!

Setup GSM-enabled device

The GSM peripheral allows your device to use the mobile phone network (i.e. GSM - Global System for Mobile communications) and send SMS notificatons or have access to the internet.

Here's how to setup a project with GSM capabilities

  • Create a new project and add a GSM peripheral
  • Enable the GSM peripheral by setting its On property to 1
  • If the SIM card you intend to use has a PIN code, enter it in the Pin Code property. Otherwise leave it empty.

Sending SMS

You can use the GSM module to send an SMS to a phone number using the GSM SMS peripheral.

This is different than using the WebAlert peripheral for SMS, because the SMS is sent by your device directly to the recepient via the mobile network, while WebAlert uses the internet to make a request to the IoT.Cafe website, which in turn sends the SMS.

To send an SMS

  • Add a GSM SMS peripheral to your project
  • Set the Recepient property with the phone number, which is to receive the SMS. It must be a full number, starting with + and containing country code and all
  • Set the Send property to 1
The message will contain the values of the device's properties.

The message gets sent each time the Send property becomes 1.
This means that for the current configuration, the message will be sent once at device start up.

If you want to send the message multiple times during device operation or at certain event, you should bind it to another property, like that of a Button or Trigger peripheral for example.

Mobile internet

In order to access the internet with the GSM peripheral, you need to enable GPRS and provide the Access Point Name (APN) settings, which are specific for your mobile operator

  • Set GPRS to 1
  • Set APN
  • Set APN User
  • Set APN Password

To find your mobile operator's APN settings, you can search online, ask an AI, look directly on your operator's website or even directly ask their support - it's public information.

And that's it!
Your device should now have internet access and be able to use features such as Weblink and Webalert.

Done!

This concludes the practical part of the example.
Following below are some related additional details.

Supplemental

2G

If you have trouble getting the GSM peripheral to work, you may check if your GSM module is SIM800L or SIM800L-compatible and whether your mobile operator supports the technology standard of your module.

Originally, SIM800L is a 2G module and it is possible that your operator does not support 2G, as it is regarded as an old standard.

For v2.0, we're planning to add support for a more recent standard like 4G with the SIM7070G chip based module.

Fees

There's no avoiding fees when it comes to mobile operators.

Using GPRS mobile data and sending SMS via the mobile network will charge you according to your mobile operator's terms.
This is between you and your mobile operator.

The GSM SMS peripheral sends SMS explicitly via the mobile network and requires a GSM peripheral.

The Webalert peripheral sends SMS and other notifications through the internet and it requires an internet source.
This can be any of the following

  • GSM peripheral with enabled GPRS
  • Generic Wi-Fi peripheral for a board with a buil-in Wi-Fi like ESP32 or ESP8266
  • Wi-Fi peripheral for an external Wi-Fi module. The ESP8266 can serve as such a module.
While Email and mobile notifications are free, SMS notifications depend on mobile operator fees even when using Weblink.

APNs

The APN settings are public information and we'd love to make it the easiest for you and provide a full list of all the APNs here, but there are so many mobile operators worldwide, with new emerging or existing ones merging or simply changing their nams and settings, that it'd be quite difficult to support such a list ever-accurate.
That's why we suggest to look for the settings personally.