The Arduino MKR GSM 1400 has SIM connectivity and can be connected to the Arduino IoT Cloud remotely. Here you'll learn how to configure a cellular connection and test it with an example sketch.
What you need
- An Arduino MKR GSM 1400
- An activated SIM card from Arduino or some other service provider.
- 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.
Connecting your board to the IoT Cloud
-
Connect the board to your computer.
-
Go to Arduino IoT 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.
Creating a sketch
You can skip step 1 if you already have a Thing with a sketch prepared, but you still need to add the led variable if you want to follow the example later in this article.
The network parameters will be written to the thingProperties.h
and Secret
sketch files. But a sketch is only generated when a variable is added, so we'll do that first. You can add any variable you like, but here we'll prepare a variable to use in an example later in this article.
-
Open the Things tab and click Create Thing. Click on 'Untitled' and give it a name, such as 'SIM'.
-
Under the Device heading, click the button and associate the GSM 1400.
-
Click Add variable and configure the variable with the below settings. When you're done, click Add Variable.
-
Your sketch will now be generated and can be viewed in the Sketch tab.
Configuring the network parameters
-
Under the Network heading, click the Configure button. If you are configuring an Arduino SIM, use the following parameters.
APN prepay.pelion PIN 0000 Username arduino Password arduino Otherwise, use the parameters provided by your SIM provider.
-
Go to the sketch tab and upload the code to your board.
-
After a short while, your board should be online.
Testing your remote connection
To test the connection, we can set up a Dashboard widget that will toggle an LED on the board.
You will need a Thing configured with the led
from the previous step.
-
Open the Sketch tab of your Thing.
-
Scroll down to the bottom of the sketch and add this code.
void onLedChange() { Serial.print("led: " + led); digitalWrite(LED_BUILTIN, led); }
-
Upload the changes to the board.
-
Open the Dashboards tab in the top bar. Open an existing dashboard, or click Build Dashboard to create a new one.
-
Click the notepad icon to enable editing. Then click Add > Things and select your Thing.
-
Make sure the
led
variable is selected and click Create Widget. -
Click Done to accept the default settings.
-
A new switch widget will be added to your dashboard.
When the switch button is clicked, the IoT will change the led
cloud variable, triggering onLedChange()
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 the IoT Cloud. You can then toggle the LED remotely using the Dashboard switch.