Skip to content

Commit 5344f32

Browse files
added Readme, properties
1 parent a8919ac commit 5344f32

18 files changed

+1015
-0
lines changed

.DS_Store

6 KB
Binary file not shown.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Render Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- ".github/workflows/render-documentation.ya?ml"
9+
- "examples/**"
10+
- "src/**"
11+
pull_request:
12+
branches:
13+
- main
14+
paths:
15+
- ".github/workflows/render-documentation.ya?ml"
16+
- "examples/**"
17+
- "src/**"
18+
workflow_dispatch:
19+
20+
jobs:
21+
render-docs:
22+
permissions:
23+
contents: write
24+
uses: sebromero/render-docs-github-action/.github/workflows/render-docs.yml@main
25+
with:
26+
source-path: './src'
27+
target-path: './docs/api.md'
28+
fail-on-warnings: true

.gitignore

Whitespace-only changes.

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Arduino 4G Module Library
2+
3+
This library provides a toolkit for interacting with the official Arduino 4G Modules. It allows you to connect to the internet, send and receive SMS messages, and get location from the cellular network or GPS.
4+
5+
## Examples
6+
* [examples/HTTPClient]() - Example of using this library together with [HttpClient]() to connect to a web server
7+
* [examples/HTTPClient]() - Example of using this library together with [HttpClient]() that uses [BearSSL]() under the hood to create a secure connection to a web server
8+
* [examples/SMSReceive]() - Example for the SMS sending and receiving functionality
9+
* [examples/TimeAndLocation]() - Use GPS, or Cellular to aquire the location and time of the device.
10+
* [examples/ModemTerminal]() - A handy example for debugging and Testing AT commands
11+
12+
## Features
13+
* Fast 4G connection to the internet
14+
* Secure SSL connections with BearSSL
15+
* Get location using GPS or GSM
16+
* Synchronise time with the cell provider
17+
* Send and Receive SMS Messages
18+
19+
## Instructions
20+
1. Insert your Arduino 4G module to the Arduino Portenta Mid Carrier
21+
2. Insert a valid SIM card either on the back of the Arduino 4G miniPCI board, or the **PCIE_SIM** connector on the Portenta Mid Carrier
22+
3. Connect the 6 **SERIAL1** header pins to their corresponding pins on the **PCIE_BREAKOUT** header using jumpers
23+
4. Connect the **3V3 PCIE** pin to the **3V3 Buck**
24+
5. Connect external power to the Mid Carrier, via the **VIN** (5-12V) because modem use a lot of power when connecting or getting a GPS location. Make sure your supply can handle around 3A.
25+
6. Get the APN settings from your network operator and add them to the "ArduinoSecrets.h" file for each sketch
26+
```c
27+
const char apn[] = "live.vodafone.com";
28+
const char gprsUser[] = "live";
29+
const char gprsPass[] = "";
30+
```
31+
7. Install the library and it's dependencies
32+
8. Enjoy
33+
34+

examples/.DS_Store

6 KB
Binary file not shown.

examples/HTTPClient/HTTPClient.ino

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#define ARDUINO_CELLULAR_DEBUG
2+
3+
#include "ArduinoCellular.h"
4+
5+
6+
const char apn[] = "live.vodafone.com";
7+
const char gprsUser[] = "live";
8+
const char gprsPass[] = "";
9+
10+
const char server[] = "vsh.pp.ua";
11+
const char resource[] = "/TinyGSM/logo.txt";
12+
const int port = 80;
13+
14+
ArduinoCellular cellular = ArduinoCellular();
15+
//TinyGsmClient networkClient = cellular.getNetworkClient();
16+
//HttpClient http = HttpClient(networkClient, server, port);
17+
HttpClient http = cellular.getHTTPClient(server, port);
18+
19+
20+
void setup(){
21+
Serial.begin(115200);
22+
while (!Serial);
23+
cellular.begin();
24+
cellular.connect(apn, gprsUser, gprsPass);
25+
}
26+
27+
void loop(){
28+
29+
Serial.println("Making GET request...");
30+
31+
http.get(resource);
32+
33+
int status_code = http.responseStatusCode();
34+
String response = http.responseBody();
35+
36+
Serial.print("Status code: ");
37+
Serial.println(status_code);
38+
Serial.print("Response: ");
39+
Serial.println(response);
40+
41+
http.stop();
42+
43+
delay(5000);
44+
45+
}
46+

examples/HTTPSClient/HTTPSClient.ino

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
#include <Arduino.h>
3+
#include "ArduinoCellular.h"
4+
#include <ArduinoHttpClient.h>
5+
#include "arduino_secrets.h"
6+
7+
const char apn[] = "live.vodafone.com";
8+
const char gprsUser[] = "live";
9+
const char gprsPass[] = "";
10+
11+
const char server[] = "example.com";
12+
const char resource[] = "/";
13+
const int port = 443;
14+
15+
ArduinoCellular cellular = ArduinoCellular();
16+
HttpClient http = cellular.getHTTPSClient(server, port);
17+
18+
void setup(){
19+
Serial.begin(115200);
20+
while (!Serial);
21+
22+
cellular.begin();
23+
cellular.connect(apn, gprsUser, gprsPass);
24+
}
25+
26+
void loop()
27+
{
28+
Serial.println("Making GET request...");
29+
30+
http.get(resource);
31+
32+
int status_code = http.responseStatusCode();
33+
String response = http.responseBody();
34+
35+
Serial.print("Status code: ");
36+
Serial.println(status_code);
37+
Serial.print("Response: ");
38+
Serial.println(response);
39+
40+
http.stop();
41+
42+
delay(5000);
43+
}
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//CA Certificate for www.howsmyssl.com (valid until 04-07-2021)
2+
const char root_ca[] PROGMEM =
3+
"-----BEGIN CERTIFICATE-----\n"
4+
"MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw\n"
5+
"TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n"
6+
"cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4\n"
7+
"WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu\n"
8+
"ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY\n"
9+
"MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc\n"
10+
"h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+\n"
11+
"0TM8ukj13Xnfs7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5\n"
26+
"ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur\n"
27+
"TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC\n"
28+
"jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc\n"
29+
"oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq\n"
30+
"4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA\n"
31+
"mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d\n"
32+
"emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n"
33+
"-----END CERTIFICATE-----\n";
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "ArduinoCellular.h"
2+
3+
4+
ArduinoCellular cellular = ArduinoCellular();
5+
6+
float lat = 0.00;
7+
float lon = 0.00;
8+
9+
const char apn[] = "live.vodafone.com";
10+
const char gprsUser[] = "live";
11+
const char gprsPass[] = "";
12+
13+
void setup(){
14+
Serial.begin(115200);
15+
while (!Serial);
16+
cellular.begin();
17+
cellular.connect(apn, gprsUser, gprsPass);
18+
}
19+
20+
void loop() {
21+
if (Serial.available() > 0) {
22+
// Define a buffer to store incoming data. Adjust the size as needed.
23+
char incomingData[255]; // Adjust the size according to your needs
24+
25+
// Read data from serial until newline is found
26+
int size = Serial.readBytesUntil('\n', incomingData, sizeof(incomingData) - 1); // Leave space for null terminator
27+
28+
// Null-terminate the string
29+
incomingData[size] = '\0';
30+
// Call the sendATCommand function with the read data
31+
Serial.println(cellular.sendATCommand(GF(incomingData)));
32+
}
33+
}

examples/SMSReceive/SMSReceive.ino

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include "ArduinoCellular.h"
2+
3+
const char apn[] = "live.vodafone.com";
4+
const char gprsUser[] = "live";
5+
const char gprsPass[] = "";
6+
7+
#define TINY_GSM_DEBUG Serial
8+
#define ARDUINO_CELLULAR_DEBUG
9+
10+
ArduinoCellular cellular = ArduinoCellular();
11+
12+
boolean newSMS = false;
13+
14+
15+
void printMessages(std::vector<SMS> msg){
16+
for(int i = 0; i < msg.size(); i++){
17+
Serial.println("SMS:");
18+
Serial.print("\t * From: "); Serial.println(msg[i].number);
19+
Serial.print("\t * Message: "); Serial.println(msg[i].message);
20+
Serial.print("\t * Timestamp: "); Serial.println(msg[i].timestamp.getISO8601());
21+
}
22+
}
23+
void newSMSCallback(){
24+
Serial.println("new sms received");
25+
newSMS = true;
26+
}
27+
28+
void setup(){
29+
Serial.begin(115200);
30+
while (!Serial);
31+
cellular.begin();
32+
cellular.connect(apn, gprsUser, gprsPass);
33+
34+
35+
attachInterrupt(digitalPinToInterrupt(A0), newSMSCallback, RISING);
36+
37+
Serial.println("Read SMS:");
38+
std::vector<SMS> readSMS = cellular.getReadSMS();
39+
printMessages(readSMS);
40+
41+
Serial.println("Unread SMS:");
42+
std::vector<SMS> unreadSMS = cellular.getUnreadSMS();
43+
printMessages(unreadSMS);
44+
45+
cellular.sendSMS("+40788494946", "bleep bleep");
46+
}
47+
48+
void loop(){
49+
if(newSMS){
50+
newSMS = false;
51+
std::vector<SMS> unreadSMS = cellular.getUnreadSMS();
52+
if (unreadSMS.size() > 0){
53+
printMessages(unreadSMS);
54+
}
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#define DUMP_AT_COMMANDS
2+
3+
#include "ArduinoCellular.h"
4+
5+
6+
ArduinoCellular cellular = ArduinoCellular();
7+
8+
float lat = 0.00000;
9+
float lon = 0.00000;
10+
int year = 0;
11+
int month = 0;
12+
int day = 0;
13+
int hour = 0;
14+
int minute = 0;
15+
int second = 0;
16+
17+
18+
const char apn[] = "internet";
19+
const char gprsUser[] = "";
20+
const char gprsPass[] = "";
21+
22+
void setup(){
23+
Serial.begin(115200);
24+
while (!Serial);
25+
cellular.begin();
26+
//cellularModem.connect(apn, gprsUser, gprsPass);
27+
cellular.enableGPS(false);
28+
}
29+
30+
void loop(){
31+
Location loc = cellular.getGPSLocation(10000);
32+
Serial.print("Latitude: "); Serial.println(lat);
33+
Serial.print("Longitude: "); Serial.println(lon);
34+
35+
Time t = cellular.getGPSTime();
36+
Serial.print("ISO String: "); Serial.println(t.getISO8601());
37+
38+
delay(1000);
39+
40+
}

library.properties

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name=Arduino_Cellular
2+
sentence=This library provides a toolkit for interacting with the official Arduino 4G Modules.
3+
4+
paragraph=A library that allows you to connect to the internet, send and receive SMS messages, and get location from the cellular network or GPS using the official Arduino 4G Modules on the Portenta Mid Carrier board.
5+
category=Communication
6+
url=https://github.com/arduino-libraries/ArduinoCellular
7+
architectures=*
8+
includes=ArduinoCellular.h

src/ArduinoBearSSLConfig.h

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef ARDUINO_BEARSSL_CONFIG_H_
2+
#define ARDUINO_BEARSSL_CONFIG_H_
3+
4+
/* Enabling this define allows the usage of ArduinoBearSSL without crypto chip. */
5+
#define ARDUINO_DISABLE_ECCX08
6+
7+
#endif /* ARDUINO_BEARSSL_CONFIG_H_ */

0 commit comments

Comments
 (0)