The Arduino MKR GSM 1400 has SIM connectivity and can be connected to the Arduino Cloud remotely. Here you’ll learn how to configure a cellular connection and test it with an example sketch.
What you’ll need
- An Arduino MKR GSM 1400
- A SIM card with GSM/3G service
- A GSM/3G antenna with a micro UFL connector (such as the one included in the cellular kit).
Getting started
-
Slide the SIM card into the tray with the metal contacts facing the board.
-
Attach the antenna to the micro UFL port. Make sure the connector is lined up with the port and apply firm pressure.
The micro UFL port and the SIM tray are highlighted respectively in the image below.
Set up with Arduino Cloud
1. Add Arduino MKR GSM 1400 as a device
-
Connect the board to your computer.
-
Go to Arduino Cloud
-
Click the Devices tab, then click Add device. Choose to set up an Arduino or 3rd party device depending on your device.
-
After a short while, your device should be found. Click Configure to proceed.
-
Follow the instructions to configure your device.
2. Configure a Thing
-
Go to the Things tab.
-
Click the CREATE button in the top-right corner to create a new Thing. You can replace the default “Untitled” name with your own, such as “SIM”.
-
Under the Associated Device heading, click the Select Device button and select your MKR GSM 1400.
-
Under the Network heading, click the Configure button.
-
Enter the network parameters provided by your SIM provider.
-
Click the SAVE button.
3. Upload the sketch
-
Open the Sketch tab.
-
Click the Upload button to upload the updated sketch.
-
Go back to the Setup tab.
-
After a short while, your device should come online. You may have to refresh the page.
Test your remote connection
To test the connection, we can set up a Dashboard widget that will toggle an LED on the board. You’ll need a Thing that’s been associated with the device and configured for the network, like the one set up in the previous instructions.
1. Prepare the sketch
-
Go to the Things tab and open your Thing.
-
Click Add variable, or the Add button if a variable has already been added.
-
Enter the following settings for your variable and click Add variable to save.
- Name: led
- Type: Boolean
- Variable Permission: Read & Write
- Variable Update Policy: On Change
-
Open the Sketch tab of your Thing.
-
In the editor, scroll down and find the
onLedChange()
function. -
Edit the
onLedChange()
function to look like this:void onLedChange() { Serial.print("led: " + led); digitalWrite(LED_BUILTIN, led); }
-
Click the Upload button and wait for the process to complete.
2. Use the variable in a dashboard
-
Open the Dashboards tab.
-
Open an existing dashboard, or click Build Dashboard to create a new one.
-
Click the icon to enable editing.
-
Click the Add button to open the widget selection menu.
-
Click the Things tab and select the name of your Thing from the previous step.
-
Make sure the
led
variable is selected and click Create Widgets. -
A new switch widget will be added to your dashboard. When the switch button is clicked, the IoT will change the
led
cloud variable, triggeringonLedChange()
and changing the state of the LED on the board. You can now disconnect the board from your computer and power it from another source, such as a wall charger. After a short while, the board will connect to Arduino Cloud. You can then toggle the LED remotely using the Dashboard switch.