Skip to content

Stop working GPRS #215

Open
Open

Description

@tarcisocallegario

Dear Dr ChukBell, I have been using the MySQL_Connector_Arduino library during the month of June/2023 in an IOT product that uses the ESP32 board combined with the SIM800L module. After many attempts I managed to insert data into BD HOSTINGER.com.br. The device sent a record every 5 minutes to the DB. For connection I used the TinyGsmClient.h library. After working for 30 days, the device stopped sending records to the DB. The SIM800L module can no longer connect to the BD. Checking the MySQL_Connector_Arduino documentation I was able to verify, to my surprise, that this library should not work with the GPRS GSM module. Would you recommend any modifications so that the MySQL_Connector_Arduino could establish a connection with the DB using the GSM module?

Activity

  1. ChuckBell commented on Oct 13, 2023

    @ChuckBell
    Owner
  2. tarcisocallegario commented on Oct 16, 2023

    @tarcisocallegario
    Author

    Dear Dr. Charles Bell, I am sending the message recorded in the Error Log file in the Public folder
    from Hostinger at https://srv369-files.hstgr.io/e4c740aebdfa4af5/files/public_html/error_log:
    ...
    464 [15-Oct-2023 22:29:57 UTC] PHP Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'u262515252_Aerogerador'@'141.136.41.220' (using password: YES) in /home/ u262515252/domains/claudia28.hostingerapp.com/public_html/wp-includes/class-wpdb.php on line 2019

    465 [15-Oct-2023 22:29:57 UTC] PHP Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'u262515252_Aerogerador'@'141.136.41.220' (using password: YES) in /home/ u262515252/domains/claudia28.hostingerapp.com/public_html/wp-includes/class-wpdb.php on line 2019
    ...

  3. tarcisocallegario commented on Oct 16, 2023

    @tarcisocallegario
    Author

    Dear Dr. Charles Bell, below is the code from the MySQL_Connection.cpp library where I inserted the "lprint" commands to check where the program stopped working:
    MySQL_Connection.cpp - Library for communicating with a MySQL Server over Ethernet. (formerly mysql.cpp)

    Change History:

    Version 1.0.0a Created by Dr. Charles A. Bell, April 2012.
    Version 1.0.0b Updated by Dr. Charles A. Bell, October 2013.
    Version 1.0.1b Updated by Dr. Charles A. Bell, February 2014.
    Version 1.0.2b Updated by Dr. Charles A. Bell, April 2014.
    Version 1.0.3rc Updated by Dr. Charles A. Bell, March 2015.
    Version 1.0.4ga Updated by Dr. Charles A. Bell, July 2015.
    Version 1.1.0a Created by Dr. Charles A. Bell, January 2016.
    Version 1.1.1a Created by Dr. Charles A. Bell, January 2016.
    Version 1.1.2b Created by Dr. Charles A. Bell, November 2016.
    Version 1.2.0 Created by Dr. Charles A. Bell, March 2020.
    */
    #include <Arduino.h>
    #include <MySQL_Connection.h>
    #include <MySQL_Encrypt_Sha1.h>

    #define MAX_CONNECT_ATTEMPTS 3
    #define CONNECT_DELAY_MS 500
    #define SUCCESS 1

    const char CONNECTED[] PROGMEM = "Connected to server version ";
    const char DISCONNECTED[] PROGMEM = "Disconnected.";

    /*
    connect - Connect to a MySQL server.

    This method is used to connect to a MySQL server. It will attempt to
    connect to the server as a client retrying up to MAX_CONNECT_ATTEMPTS.
    This allows the possibility of longer than normal network lag times
    for wireless networks. You can adjust MAX_CONNECT_ATTEMPTS to suit
    your environment.

    server[in] IP address of the server as IPAddress type
    port[in] port number of the server
    user[in] user name
    password[in] (optional) user password
    db[in] (optional) default database

    Returns boolean - True = connection succeeded
    */
    boolean MySQL_Connection::connect(IPAddress server, int port, char *user,
    char *password, char *db)
    {
    int connected = 0;
    int retries = MAX_CONNECT_ATTEMPTS;

    // Retry up to MAX_CONNECT_ATTEMPTS times.
    while (retries--)
    {
    Serial.println("...trying...");

    Serial.println(server);
    Serial.println(port);
    Serial.println(user);
    Serial.println(password);

    connected = client->connect(server, port);       >>>>>>>>>>>>>>>>>>>>> the pprogram seems to stop working here...
    if (connected != SUCCESS) {
      Serial.print("...got: ");
      Serial.print(connected);
      Serial.println(" retrying...");
      delay(CONNECT_DELAY_MS);
    } else {
      break;
    }
    

    }

    ....

  4. tarcisocallegario commented on Oct 16, 2023

    @tarcisocallegario
    Author

    Below is the result in the serial output during the execution of the script of my program:

    range2===>>>11
    millis===>>>88007
    range2===>>>1
    Allcom.brallcomallcom
    vento=0
    vento_copia=0.00
    rpm=0
    rpm_copia=0.00
    range2=1
    version=34
    pointerdirection=7
    last_action=0
    rpm_previous=0.00
    If 1
    If 2
    141.136.34.3
    u262515252_testeuser
    Tarciso21

    ps: from here is the output generated by the MySQL_Connection.cpp library resulting from the "lprint" commands

    ...trying...
    141.136.34.3
    3306
    u262515252_testeuser
    Tarciso21

  5. tarcisocallegario commented on Oct 16, 2023

    @tarcisocallegario
    Author

    Here's part of the program I'm developing:

    //
    // Created on: 03/07/2019 By Tarciso Callegario - tarciso.callegario@gmail.com - updated on 08/10/2023 - Version 3.4
    //
    #include <ESP32httpUpdate.h>
    #include <Arduino.h>
    #include <Update.h>
    #define TINY_GSM_MODEM_SIM800 // definition of the modem used (SIM800L)
    #define TINY_GSM_RX_BUFFER 1030
    #include <TinyGsmClient.h> // library with GSM commands
    // SIM800L serial communication object
    HardwareSerial SerialGSM(1);
    // library object with GSM functions
    TinyGsm modemGSM(SerialGSM);
    #include <CRC32.h>
    #include "FS.h"
    #include "SPIFFS.h"
    //
    #include <MySQL_Connection.h>
    #include <MySQL_Cursor.h>

    TinyGsmClient client(modemGSM);

    const char server[] = "141.136.41.220";
    const int port = 80;

    int program_version = 34;

    IPAddress server_addr(141 , 136 , 34 , 3) ​​; // IP of the MySQL server here
    char userdb[] = "u262515252_testeuser" ; // MySQL user login username
    char passworddb[] = "Tarciso21" ; // MySQL user login password

    char INSERT_SQL[] = "INSERT INTO u262515252_Aerogerador.Parametros_Aerogerador ( v_vento , eixo_rpm , versao_firmiware, ponteirodirecao, ultima_acao, intervalo2 ) VALUES ('%f', '%f', '%d', '%d', '%d', '%d')";
    //( v_vento , eixo_rpm , versao_firmiware , data_corrente, ponteirodirecao ,ultima_acao , rpm_anterior , intervalo2) VALUES ('%d', '%d','%d', '%d','%d', '%d','%d','%d')";
    char query[256];

    // INSTANCIANDO OBJETOS
    MySQL_Connection conn((Client *)&client);

    ....
    ...

    if (modemGSM.waitForNetwork())
      {
      Serial.println(" If 1");  
      if (modemGSM.gprsConnect(APN, USER, PASSWORD))
        {
        Serial.println(" If 2");
         
        Serial.println(server_addr);
        Serial.println(userdb);
        Serial.println(passworddb);
    
    
        if (!conn.connect(server_addr, 3306, userdb, passworddb))    >>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> the pprogram seems to stop working here...
          {
          Serial.println(" If 3");  
          Serial.println("Conexão SQL falhou.");
          conn.close();
          delay(1000);
          }
        else
          {
          Serial.println(" If 4"); 
          sprintf(query, INSERT_SQL, vento_copia, rpm_copia, versao_programa , ponteirodirecao , ultima_acao, intervalo2 );
          // Initiate the query class instance
          Serial.println(" If 5"); 
          MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
          // Execute the query
          cur_mem->execute(query);
          Serial.println(" If 6"); 
          // Note: since there are no results, we do not need to read any data
          // Deleting the cursor also frees up memory used
          delete cur_mem;
          Serial.println("Informações Enviadas");
          conn.close();
          }
        }
    
  6. tarcisocallegario commented on Oct 16, 2023

    @tarcisocallegario
    Author

    Thank you for your helpful help and availability. Att. Tarciso Callegario

  7. tarcisocallegario commented on Oct 16, 2023

    @tarcisocallegario
    Author

    MariaDB Server 10.5.19

  8. ChuckBell commented on Oct 18, 2023

    @ChuckBell
    Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions