Arduino Uno + gps module neo 6m can't connect to database

Hello,

I am a beginner Arduino programmer and I have a W5500 Ethernet module, an Arduino Uno board, and a NEO 6M GPS module. I am programming in Arduino IDE 2.2.1. I set myself the goal of sending to the database information obtained through GPS. The problem is that in the serial monitor, the message "...trying..." is displayed, indicating an attempt to connect to the database, and then the program freezes. Below, I present the code that I uploaded to Arduino. I will also add a screenshot of the CPU usage. I checked the GPS module itself - it works. I also sent constant values to the database - it was successful without any problem. The problem appeared when I wanted to send information directly from the GPS module.

#include <Ethernet.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x99 };
IPAddress server_addr(xxx,xxx,xxx,xx);  // Adres IP serwera MySQL
char user[] = ""; // Użytkownik MySQL
char password[] = ""; // Hasło MySQL

EthernetClient client;
MySQL_Connection conn((Client *)&client);

// Konfiguracja GPS
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);

void setup() {
  Serial.begin(115200);
  ss.begin(GPSBaud);
  while (!Serial); // czekaj na połączenie portu szeregowego
  Ethernet.begin(mac_addr);
  Serial.println("Connecting...");
  if (conn.connect(server_addr, 3306, user, password)) {
    Serial.println("Connected to MySQL server.");
  } else {
    Serial.println("Connection failed.");
  }
}

void loop() {
  // Odczyt danych GPS
  while (ss.available() > 0) {
    if (gps.encode(ss.read())) {
      if (gps.location.isValid()) {
        // Przygotowanie zapytania SQL
        char INSERT_SQL[255];
        sprintf(INSERT_SQL, "INSERT INTO mtbscjchhr_GPS.GPS (dlugosc, szerokosc) VALUES (%f, %f)", gps.location.lat(), gps.location.lng());

        Serial.println("Recording data.");
        MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
        cur_mem->execute(INSERT_SQL);
        delete cur_mem;
      }
    }
  }

  delay(5000); // Czekaj 5 sekund przed kolejnym odczytem
}

Zrzut ekranu 202 Zrzut ekranu 2024-02-04 140043|690x36 4-02-04 134900

Post an annotated schematic showing exactly how you have wired this, be sure to show all connections, power, ground and power sources. Links to the hardware items would be a big help and please note any wires over 25cm/10".

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.