website logo
BlogPlansAbout UsCareersSignup
⌘K
Introduction
Getting started on Bytebeam Cloud
Concepts
Projects
Streams
Device Shadow
Device Metadata
Actions
Module Integration Guides
ESP32
Arduino
Console Guides
Device Management
Dashboards
Streams (Tables)
Actions
Users
Roles
Release Notes
R10 24-May-2023
R9 10-May-2023
R8 26-Apr-2023
R7 05-Apr-2023
R6 22-Mar-2023
R5 08-Mar-2023
R4 22-Feb-2023
R3 10-Feb-2023
R2 01-Feb-2023
R1 19-Jan-2023
Docs powered by archbee 

Setting up BytebeamArduino for GSM Connectivity

12min

This guide will show you how to setup your project for GSM connectivity.

Step 1. Getting the SDK

You can install the SDK via Arduino Library Manager. We recommend installing the latest version of the SDK for this integration. Follow the below steps to install the SDK :)

Open the Arduino Library Manager and search for the bytebeam keyword. The BytebeamArduino SDK will pop up. Go ahead select the latest version (say 1.0.1) and hit the install button.

Document image


Now you should be able to see the SDK in the Arduino IDE. See Sketch > Include Library > BytebeamArduino within the Arduino IDE.

Document image


You can also look for example sketches that comes along with the SDK. See File > Examples > BytebeamArduino within the Arduino IDE.

Document image


Step 2. Getting the GSM Client Dependencies

In order to work with GSM Client, you need to install the following libraries,

  • TinyGSM - Available in Arduino Library Manager
  • ArduinoHttpClient - Available in Arduino Library Manager
  • SSLClient - You need to install it via GitHub

Step 3. Device Provisioning

Provision device with device config data

Provisioning the device is the first step towards getting cloud connectivity at your device end. So, before you get started with the BytebeamArduino you need to provision your device. Each device has its own config file which needs to be flashed into its file system. When you call the begin method our SDK will look for this device config data and use that in order to establish the secure connection with the remote device at the cloud end.

For this integration we will go with the default configurations. If you want to change the configuration, check out the Advanced SDK Configurations guide.

Before getting ahead make sure you have the SPIFFS file system partition. For this you can select the partition table setting under Tools section. See Tools > Partition Scheme within the Arduino IDE:

Document image


Follow the below steps to provision your device:

  1. Download the device configuration JSON file from Bytebeam cloud by following the Provisioning a Device guide.
  2. After downloading the config file, open it in your favourite text editor and format the json document. Once done copy the formatted json document to the clipboard.
  3. Open SPIFFS Provisioning example sketch as per your choice of the file system. See File > Examples > BytebeamArduino > Provisioning > SPIFFSProvisioning within the Arduino IDE.
  4. Paste the copied content to the deviceConfigWriteStr char array, Refer below code snippet to do so.
  5. Setup the ESP32 board configurations and Hit the Upload button.
  6. Watch out the Serial logs for the provisioning status.
JSON
|
char deviceConfigWriteStr[DEVICE_CONFIG_STR_LENGTH] = R"(
{
    "project_id": "espbytebeamsdktest",
    "broker": "cloud.bytebeam.io",
    "port": 8883,
    "device_id": "1",
    "authentication": {
        "ca_certificate": "-----BEGIN CERTIFICATE-----\nMIIFrDCCA5SgAwIBAgICB+\naWExETAPBgNVBAgTCEthcm5hdGFrMRIwEAYDVQQHEwlCYW5nYWxvcmUxFzAVBgNV\nBAkTDlN1YmJpYWggR2FyZGVuMQ8wDQYDVQQREwY1NjAwMTExFDASBgNVBAoTC0J5\ndGViZWFtLmlvMB4XDTIxMDkwMjExMDYyM1oXDTMxMDkwMjExMDYyM1owdzEOMAwG\nA1UEBhMFSW5kaWExETAPBgNVBAgTCEthcm5hdGFrMRIwEAYDVQQHEwlCYW5nYWxv\ncmUxFzAVBgNVBAkTDlN1YmJpYWggR2FyZGVuMQ8wDQYDVQQREwY1NjAwMTExFDAS\nBgNVBAoTC0J5dGViZWFtLmlvMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKC\nAgEAr/bnOa/8AUGZmd/s+7rejuROgeLqqU9X15KKfKOBqcoMyXsSO65UEwpzadpw\nMl7GDCdHqFTymqdnAnbhgaT1PoIFhOG64y7UiNgiWmbh0XJj8G6oLrW9rQ1gug1Q\n/D7x2fUnza71aixiwEL+KsIFYIdDuzmoRD3rSer/bKOcGGs0WfB54KqIVVZ1DwsU\nk1wx5ExsKo7gAdXMAbdHRI2Szmn5MsZwGL6V0LfsKLE8ms2qlZe50oo2woLNN6XP\nRfRL4bwwkdsCqXWkkt4eUSNDq9hJsuINHdhO3GUieLsKLJGWJ0lq6si74t75rIKb\nvvsFEQ9mnAVS+iu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DwHNpa6g0NQNGN5IRl/w1TS1izzjzgWhR6r8wX8OPLRzhNRz\n2HDbTXGYsem0ihC0B8uzujOhTHcBwsfxZUMpGjg8iycJlfpPDWBdw8qrGu8LeNux\na0cIevjvYAtVysoXInV0kg==\n-----END CERTIFICATE-----\n",
        "device_certificate": "-----BEGIN CERTIFICATE-----\nMIIEcjCCAlqgAwIBAgICB+\naWExETAPBgNVBAgTCEthcm5hdGFrMRIwEAYDVQQHEwlCYW5nYWxvcmUxFzAVBgNV\nBAkTDlN1YmJpYWggR2FyZGVuMQ8wDQYDVQQREwY1NjAwMTExFDASBgNVBAoTC0J5\ndGViZWFtLmlvMB4XDTIyMTEwMzA3NDcwMloXDTMyMTEwMzA3NDcwMlowKTEbMBkG\nA1UEChMSZXNwYnl0ZWJlYW1zZGt0ZXN0MQowCAYDVQQDEwExMIIBIjANBgkqhkiG\n9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzsm8CF8fKSzWFKZeO52RJRGER4z7sYrgTb9x\noIeljE8kmhR+EW217sxUyUn+rmJSCxRz6jtspKv37POPaQilmwtriVq8L46YCrXa\nbI9manlqw0WqAfaWAlFXzM13CuXeGZKhuAK3INs15jqP0s+oWFvww8+hww540I+s\nn6j5yEUnWKSIgoYEc82cwvj0qOvaxYxjUTXgV2IDLSXdFJbZq4k9LDbzPZdDe0aY\n4X9UpdrjS5cRWT3Ok4VwWpMRwOT654CTwE8WUja/pHTRFbMYkqd1jrD2Joqtm+u9\nplTq7I9/fDnkRqPjueDQ04LKTbUC2UsRKw1VmHPndw22+mDPUwIDAQABo1YwVDAO\nBgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwHwYDVR0jBBgwFoAU\nqX8xNsutnSC6ud46YB8Ec74sfP4wDAYDVR0RBAUwA4IBMTANBgkqhkiG9w0BAQsF\nAAOCAgEAcj5Ytt47AdmsXBsv/K7YkUvkNwV64luBMQtqmTKRDWnIQLaFzPjdpieu\n81ktFKklKw6pRe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lNE9P7XZyOyfQdzOlJWv8B78dwrbwMiwkhGyb6ms11GGB5J90f8oON4tMjEzdW\nKFI0T+ZOXN99GcKLHeg5GfGqHcHlEhXP9BtRyTJVz914alvOIaiY\n-----END RSA PRIVATE KEY-----\n"
    }
}
)";


Step 4. Defining GSM Network Interface

By default, we define the Wi-Fi network interface inside the SDK and in order to work with GSM you need to define the Modem Network Interface. Follow the below steps to do so,

  • Open the Arduino library's location.
  • Step into BytebeamArduino\src folder.
  • Open BytebeamArduinoDefines.h in your favorite text editor.
  • Add Modem Network Interface instead of Wi-Fi Network Interface.

Refer below code snippet for reference,

C++
|
//
// Enable the define as per your connectivity interface
// Make sure you enable only one interface at a time
//

// defines for using the wifi interface
// #define BYTEBEAM_ARDUINO_USE_WIFI

// defines for using the modem interface
#define TINY_GSM_MODEM_SIM7600           // define the modem you're using
#define BYTEBEAM_ARDUINO_USE_MODEM


Step 5. Initialize and Start Bytebeam Client

The next step is to initialize and start bytebeam client. Refer below code snippet to do so :)

C++
|
// Add this include to your sketch
#include <BytebeamArduino.h>

//
// By including the above header you got the access to the gloabl object named Bytebeam
// Use Bytebeam global object to perform the required operations
//

void setup() {
  // put your setup code here, to run once:

  //
  //  Your application setup stuff goes here
  //

  // Make sure your initialize modem and ntp before gettig ahead
  // If you want logging via Serial Monitor, consider initialzing Serial as well
  
  // setting up the device info i.e to be seen in the device shadow
  Bytebeam.status          = "Device is Up!";
  Bytebeam.softwareType    = "setup-gsm-client-ino";
  Bytebeam.softwareVersion = "1.0.0";
  Bytebeam.hardwareType    = "ESP32 Dev Module";
  Bytebeam.hardwareVersion = "rev1";
  
  // This method will initialize and start the bytebeam client
  // We expect the pointer to modem object of class TinyGSM in begin method 
  // You can over-ride the default file system and file name options, if needed
  // eg. Bytebeam.begin(&modem, BytebeamArduino::LITTLEFS_FILE_SYSTEM, 
  // "/my_device_config.json")
  if(!Bytebeam.begin(&modem)) {
    Serial.println("Bytebeam Client Initialization Failed.");
  } else {
    Serial.println("Bytebeam Client is Initialized Successfully.");
  }

  //
  // If above call is successfull then the bytebeam client is now configured for the
  // use. You can always check for the logs in serial monitor for the status of the 
  // above call
  //

  // check if bytebeam client is connected or disconnected
  bool connectionStatus = Bytebeam.isConnected();

  if(!connectionStatus) {
    SerialMon.println("Bytebeam Client is Disconnected.");
  } else {
    SerialMon.println("Bytebeam Client is Connected.");
  }

  // Call the end method to stop and de-initialize the bytebeam client at any point of 
  // time in the code
  // Bytebeam.end();
}

void loop() {
  // put your main code here, to run repeatedly:

  //
  //  Your application regular stuff goes here
  //

  // This method will let you maintain the connection with the bytebeam cloud, In case
  // the connection is lost, it will attempt to reconnect to the bytebeam cloud
  Bytebeam.loop();

  // software delay, you can customize it as per your application needs
  delay(5000);
}


Look at the SetupClient_GSM example sketch for reference. See File > Examples > BytebeamArduino > ESP32 > SetupClient_GSM within the Arduino IDE.

Document image


Step 6. Build and Flash Application

You can build and flash your application as usual with the Arduino IDE, just setup your board configurations and hit the upload button within the Arduino IDE.

Updated 24 Apr 2023
Did this page help you?
Yes
No
PREVIOUS
Integrate Over the Air Updates
NEXT
Advanced SDK Configurations
Docs powered by archbee 
TABLE OF CONTENTS
Step 1. Getting the SDK
Step 2. Getting the GSM Client Dependencies
Step 3. Device Provisioning
Provision device with device config data
Step 4. Defining GSM Network Interface
Step 5. Initialize and Start Bytebeam Client
Step 6. Build and Flash Application