Reader small image

You're reading from  Arduino Data Communications

Product typeBook
Published inNov 2023
PublisherPackt
ISBN-139781837632619
Edition1st Edition
Right arrow
Author (1)
Robert Thas John
Robert Thas John
author image
Robert Thas John

Robert Thas John is a data engineer with a career that spans two decades. He manages a team of data engineers, analysts, and machine learning engineers – roles that he has held in the past. He leads a number of efforts aimed at increasing the adoption of machine learning on embedded devices through various programs from Google Developers and ARM Ltd, which licenses the chips found in Arduinos and other microcontrollers. He started his career as a software engineer with work that has spanned various industries. His first experience with embedded systems was in programming payment terminals.
Read more about Robert Thas John

Right arrow

Leveraging Cellular Communication Technology

Cellular communication technology is popular on mobile phones. It is popular across the world because it is deployed by large businesses that maintain the infrastructure. We will learn how to work with this technology by writing code that sends data, using Simple Messaging Service (SMS) and General Packet Radio Services (GPRS), so that we can deploy solutions that communicate using this technology.

In this chapter, we will cover the following main topics:

  • Learning about cellular connectivity
  • Choosing cellular radios
  • Making phone calls
  • Working with SMS
  • Working with GPRS

By the end of this chapter, you will have learned how to send temperature and humidity data using cellular technology.

Technical requirements

We will make use of the following in this chapter:

  • Arduino MKR GSM 1400
  • Arduino MKR ENV Shield
  • Antenna (this is bundled with the microcontroller if you purchase directly from the Arduino Store)
  • The Arduino IDE
  • A SIM card
  • A 9V battery or similar source
  • A 9V-to-5V buck converter
  • The battery and buck converter can be replaced with a benchtop power supply if you have access to one
  • Cables

The code snippets for this chapter are available at the following GitHub URL: https://github.com/PacktPublishing/Arduino-Data-Communications/tree/main/chapter-9

Learning about cellular connectivity

Cellular connectivity is provided by telecommunication networks. These networks are usually privately owned, although they can be publicly owned in some countries. These networks are licensed at a national level. As a result, even if a network has the same name as a network in another country, you can’t use the other network unless the two networks have a roaming agreement.

In order to connect to a cellular network, you will need a device that is capable of communicating over the right frequency and a Subscriber Identity Module (SIM). A SIM can be either physical or virtual (or electronic). A physical SIM is also called a SIM card. Physical SIM cards have shrunk in size over the years, thus making it possible for device manufacturers to also make smaller devices. A SIM card with cutouts for three generations of sizes is shown in the following figure, with the card itself in the white area.

Figure 9.1 – A physical SIM card

Figure 9.1 –...

Choosing cellular radios

There are two radios involved in cellular communications – one radio is mounted on the cell site and is outside of our control. The other radio is within our IoT device, and we can choose which radio to work with.

There are various cellular connectivity standards across the world. The choice of which one to use will be determined by the geographical location of the final deployment.

Deployments in North America

For deployments in North America, the available options are as follows:

  • LTE Cat-1
  • GSM (3G/4G/5G)
  • NB-IoT

You can find various cellular connectivity modules at https://sparkfun.com.

Deployments in EMEA

For deployments in Europe, the Middle East, and Africa, the options are as follows:

  • GSM (3G/4G/5G)
  • LTE Cat-1

A great provider of modules is Blues Wireless (https://blues.io/). Let’s discuss them in detail.

Blues Wireless

Blues Wireless is in the business of providing cellular connectivity...

Making phone calls

Let’s discuss the situation in which phone calls make sense by considering the alternatives.

SMS delivers messages as text. These messages can be delivered to any type of phone, even what is called a feature phone. However, SMS utilizes a methodology called store-and-forward. SMS is not an emergency service; the network will use a best-effort approach to deliver the message, but delivery could be delayed for many days.

GPRS delivers messages over the internet. This is immediate, but the message will end up on the cloud, from where a notification would need to be sent to a smartphone, or the end user would need to have a dashboard open in order to see the notification. In such a case, any device that doesn’t have access to the internet, or that isn’t smart, will be unable to get this information.

With the preceding information, how then could we implement an alarm? How might we implement a smoke alarm that would be guaranteed to notify...

Working with SMS

SMS is a text-based two-way communication method. It is useful because it works well in the absence of internet connectivity, and it is used in a lot of applications where you want the microcontroller to do something, or where you want the microcontroller to report the status of something.

Let’s consider the first instance where you would like a microcontroller to receive an SMS.

Project 2 – Receiving an SMS

Take the following steps to display the content of any SMS messages received on the microcontroller. The code for this section is available at GitHub (https://github.com/PacktPublishing/Arduino-Data-Communications/tree/main/chapter-9/MKR-GSM-Simple-Receive-SMS):

  1. Connect the dipole antenna to the MKR GSM. This is the antenna that comes with the MKR GSM purchased from the Arduino Store.
  2. Insert the SIM card into the holder.
  3. Connect the negative pin of the 5V power supply to the GND pin of the microcontroller.
  4. Connect the...

Working with GPRS

You can make use of GPRS to access REST API endpoints, just as you did using Wi-Fi. However, there is one difference – you need to ensure that the SIM has an active data subscription. You will also need to find the Access Point Name (APN) of your telecom provider, as well as the credentials for connecting. This is normally published somewhere on the provider’s website.

The SIM in our microcontroller can’t communicate with the server in our local network. We will need to communicate with a server that is publicly hosted. Let’s use https://webhook.site for this purpose. This will let us monitor the data we send from the Arduino without having to write a custom API to receive the data. This is useful to quickly debug what we send from our microcontrollers. Visit the site and search for the connection URL, which looks similar to the following.

Figure 9.7 – The webhook.site unique URL

Figure 9.7 – The webhook.site unique URL

You will need to...

Summary

In this chapter, you learned about cellular connectivity options and also looked at some modules that you could make use of. You then worked with an MKR GSM board and made phone calls, sent and received an SMS, and sent data over GPRS to a REST endpoint.

In the following chapter, you will learn how to work with a communication technology that works over a peer-to-peer network.

Further reading

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Arduino Data Communications
Published in: Nov 2023Publisher: PacktISBN-13: 9781837632619
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Robert Thas John

Robert Thas John is a data engineer with a career that spans two decades. He manages a team of data engineers, analysts, and machine learning engineers – roles that he has held in the past. He leads a number of efforts aimed at increasing the adoption of machine learning on embedded devices through various programs from Google Developers and ARM Ltd, which licenses the chips found in Arduinos and other microcontrollers. He started his career as a software engineer with work that has spanned various industries. His first experience with embedded systems was in programming payment terminals.
Read more about Robert Thas John