Xinyuan-LilyGO / LilyGo-T-Call-SIM800

https://www.aliexpress.com/item/33045221960.html
473 stars 239 forks source link

Has anybody able to run the platformio Thingsboard example successfully? #196

Open shivanshumahim opened 2 years ago

shivanshumahim commented 2 years ago

I have a SIM800L TTGO TCall. I have chosen Thingsboard IoT platform for a project. The example just doesn't work for me :( I have tested Blynk GSM example and it works fine. I have tested thingsboard via ESP32 wifi, works fine, however GSM + Thingsboard doesn't. No Complication error, just " Could not connect

Serial Output:- (after esp32 wakes up)

IP5306 setPowerBoostKeepOn: OK IP5306 Battery level:100 Battery from ADC: 4195mV In loop MODEM_RST & IP5306 IRQ: HIGH MODEM_PWKEY: HIGH MODEM_POWER_ON: HIGH MODEM_PWKEY: LOW Modem: SIM800 R14.18 The sensor did not respond. Please check wiring. GSM Battery: 0% 0mV IP5306 Battery level:100 Battery from ADC: 4194mV Waiting for network... OK Signal quality:31 Connecting to airtelgprs.com OK Connecting to: demo.thingsboard.io with token 6bh72bChcwDdzKTRKvql Failed to connect GPRS disconnect Radio off GSM power off Going to sleep now

this on loop :(

shivanshumahim commented 2 years ago

I was able to connect via HTTP, so will leave the code here, if anyone needs it. My project requires MQTT so i am working on it. Once done, will update here as well.

HTTP code:-

`

define SIM800L_IP5306_VERSION_20190610

// Select your modem:

include "utilities.h"

// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_UBLOX // #define TINY_GSM_MODEM_BG96 // #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_M590 // #define TINY_GSM_MODEM_ESP8266

define TINY_GSM_MODEM_SIM800

define SerialMon Serial// Set serial for AT commands (to the module)// Use Hardware Serial on Mega, Leonardo, Micro

define SerialAT Serial1

include

include

include "ThingsBoard.h"

// Your GPRS credentials // Leave empty, if missing user or pass const char apn[] = "airtelgprs.com"; const char user[] = ""; const char pass[] = "";

// See https://thingsboard.io/docs/getting-started-guides/helloworld/ // to understand how to obtain an access token

define TOKEN "81z6bHg8K9SxNrSdcTHN"

define THINGSBOARD_SERVER "demo.thingsboard.io"

define THINGSBOARD_PORT 80

// Baud rate for debug serial

define SERIAL_DEBUG_BAUD 115200

// Serial port for GSM shield // RX, TX pins for communicating with modem

// Uncomment to see StreamDebugger output in serial monitor //#define DUMP_AT_COMMANDS 1

ifdef DUMP_AT_COMMANDS

include

StreamDebugger debugger(SerialAT, SerialMon); TinyGsm modem(debugger);

else

// Initialize GSM modem TinyGsm modem(SerialAT);

endif

// Initialize GSM client TinyGsmClient client(modem);

// Initialize ThingsBoard instance ThingsBoardHttp tb(client, TOKEN, THINGSBOARD_SERVER, THINGSBOARD_PORT);

// Set to true, if modem is connected bool modemConnected = false;

void setup() { // Set console baud rate

// Set console baud rate SerialMon.begin(115200);

delay(10);

setupModem();

SerialMon.println("Wait...");

// Set GSM module baud rate and UART pins
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);

delay(6000);

// Restart takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println("Initializing modem...");
modem.restart();
// modem.init();

String modemInfo = modem.getModemInfo();
SerialMon.print("Modem Info: ");
SerialMon.println(modemInfo);

if TINY_GSM_USE_GPRS

// Unlock your SIM card with a PIN if needed
if ( GSM_PIN && modem.getSimStatus() != 3 ) {
    modem.simUnlock(GSM_PIN);
}

endif

SerialMon.print("Waiting for network...");
if (!modem.waitForNetwork()) {
    SerialMon.println(" fail");
    delay(10000);
    return;
}
SerialMon.println(" success");

if (modem.isNetworkConnected()) {
    SerialMon.println("Network connected");
}

// GPRS connection parameters are usually set after network registration
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, user, pass)) {
    SerialMon.println(" fail");
    delay(10000);
    return;
}
SerialMon.println(" success");

if (modem.isGprsConnected()) {
    SerialMon.println("GPRS connected");
}

// Unlock your SIM card with a PIN //modem.simUnlock("1234"); }

void loop() { delay(1000);

if (!modemConnected) { SerialMon.print(F("Waiting for network...")); if (!modem.waitForNetwork()) { SerialMon.println(" fail"); delay(10000); return; } SerialMon.println(" OK");

SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, user, pass)) {
    SerialMon.println(" fail");
    delay(10000);
    return;
}

modemConnected = true;
SerialMon.println(" OK");

}

// Uploads new telemetry to ThingsBoard using HTTP. // See https://thingsboard.io/docs/reference/http-api/#telemetry-upload-api // for more details

SerialMon.println("Sending temperature data..."); tb.sendTelemetryFloat("temperature", 299);

SerialMon.println("Sending humidity data..."); tb.sendTelemetryFloat("humidity", 3.141592); delay (10000); } ` Note:- 1) don't forget to add utilities.h file 2) idk if its a code issue or thingsboard issue, the data is sent every 10 seconds, but it is updated in the demo thingsboard only when I refresh the page. 3) comments of this code might/might not be correct, I merged 2 different codes to work.