BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk v0.5.3 with TinyGSM 0.3.5 libraries, modem does not respond

I am trying the new libraries with the MKR1400 (UBLOX SARA-U201). I have tried everything I know to try, and what has been suggested in the forums. I am using Hologram for SIM service, and I have no issues sending data to the cloudsocket.hologram.io server using the MKRGSM.h library. When I try to use Blynk v0.5.3 libraries along with TinyGSM 0.3.5 libraries, my modem simply does not respond. Here is my code (any help would be greatly appreciated!):

//#define BLYNK_PRINT Serial
#define TINY_GSM_MODEM_UBLOX
//#define BLYNK_HEARTBEAT 30
#define SerialAT Serial1

// libraries
#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>

// APN data
char apn[] = "hologram";
char user[] = "";
char pass[] = "";

//Blynk App Auth Token
char auth[] = "bd83de9139b847fcb67c53ba33d93d50";

TinyGsm modem(SerialAT);

// initialize sensor variables
#define M A1
int value;
String mval;

void SensorRead()
{
 pinMode(M, OUTPUT);
 value = analogRead(M);
 Serial.println(value);
}

  BLYNK_READ(V5)
  {
  SensorRead();
  Blynk.virtualWrite(V5, value); //sending to Blynk
  }

void setup() 
{
  // Debug
  Serial.begin(115200);
  
 // Set GSM module baud rate
  SerialAT.begin(19200);
  delay(3000);
  Serial.println("Initializing modem...");
  modem.restart();
  delay(3000);
  String modemInfo = modem.getModemInfo();
  Serial.print("Modem: ");
  Serial.println(modemInfo);

  Blynk.begin(auth, modem, apn, user, pass);
  
  //Function Calls
}

void loop() 
{
 Blynk.run();
}

I have also been able to get my device to work over Wia in this way:

#include <ArduinoHttpClient.h>
#include <MKRGSM.h>
#include <ArduinoJson.h>

// PIN Number
const char PINNUMBER[]     = ""; //blank if no pin
// APN data: check settings on mobile for sim provider or contact carrier for network settings
const char GPRS_APN[]      = "hologram";
const char GPRS_LOGIN[]    = "";
const char GPRS_PASSWORD[] = "";

// get this from the wia dashboard. it should start with `d_sk`
const char* device_secret_key = "SECRETKEYHERE";

GSMClient client;
GPRS gprs;
GSM gsmAccess;

// initialize sensor variables
#define M A1
int value;
String mval;

// Wia API parameters
char server[] = "api.wia.io";
char path[] = "/v1/events";
int port = 80;


StaticJsonBuffer<512> jsonBuffer;
HttpClient httpClient = HttpClient(client, server, port);
JsonObject& root = jsonBuffer.createObject();
String response;
int statusCode = 0;
String dataStr;

void SensorRead()
{
 pinMode(M, OUTPUT);
 value = analogRead(M);
 Serial.println(value);
}

void setup() {

   SensorRead();
  
  // initialize serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("Starting GSM connection to Wia!.");
  // connection state
  boolean connected = false;

  // After starting the modem with GSM.begin()
  // attach the shield to the GPRS network with the APN, login and password
  while (!connected) {
    if ((gsmAccess.begin(PINNUMBER) == GSM_READY) &&
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY)) {
      connected = true;
    } else {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("connecting...");
  // if you get a connection, report back via serial:
  if (client.connect(server, port)) {
    Serial.println("connected");
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop() {
  root["name"] = "DATA";
  root["data"] = value;

  // if you get a connection, report back via serial:
  if (client.connect(server, port)) {

    postToWia(root);

  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
  // read the status code and body of the response
  statusCode = httpClient.responseStatusCode();
  response = httpClient.responseBody();

  Serial.print("Status code: ");
  Serial.println(statusCode);
  Serial.print("Response: ");
  Serial.println(response);

  delay(3.6e6); // Wait for 3 seconds to post again
}

void postToWia(JsonObject& data) {
  data.printTo(dataStr);
  httpClient.beginRequest();
  httpClient.post(path);
  httpClient.sendHeader("Content-Type", "application/json");
  httpClient.sendHeader("Content-Length", data.measureLength());
  httpClient.sendHeader("Authorization", "Bearer "  + String(device_secret_key));
  httpClient.beginBody();
  httpClient.print(dataStr);
  httpClient.endRequest();

}

Please properly format your code for forum viewing… as required…

Blynk - FTFC

Then others are more likely to help.

Taken care of. Thanks for the advice…

Update:

I have figured out what I was doing wrong. It is important that with the MKR1400 additional configuration is done. This is of course documented in the (Readme); https://github.com/vshymanskyy/TinyGSM/blob/master/README.md

I should have checked here first. This issue can be closed.