Skip to content

Add example for sending SMS only #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions examples/SendSMS/SendSMS.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This example shows how to send an SMS message using the Arduino_Cellular library.
*
* Instructions:
* 1. Insert a SIM card with or without PIN code in the Arduino Pro 4G Module.
* 2. Provide sufficient power to the Arduino Pro 4G Module. Ideally, use a 5V power supply
* with a current rating of at least 2A and connect it to the VIN and GND pins.
* 3. Make sure the SIM card has enough credit to send SMS messages.
* 4. Specify the APN, GPRS username, and GPRS password of your mobile network provider.
* 5. Specify the PIN code of your SIM card if it has one.
* 6. Specify the phone number of the recipient and the message you want to send.
* 7. Upload the sketch to the connected Arduino board.
*
* Initial author: Sebastian Romero @sebromero
*/
#include "ArduinoCellular.h"

const char apn[] = "internet";
const char gprsUser[] = "";
const char gprsPass[] = "";

ArduinoCellular cellular = ArduinoCellular();

void setup(){
Serial.begin(115200);
while (!Serial);
delay(1000); // Give the serial monitor some time to start

cellular.begin();
String pinCode = "1234"; // If your SIM card has a PIN code, specify it here

Serial.println("Connecting to network...");
cellular.connect(apn, gprsUser, gprsPass, pinCode);

Serial.println("Sending SMS...");
cellular.sendSMS("+41791234567", "bleep bleep");
Serial.println("Done.");
}

void loop(){
delay(1000);
}
Loading