Go Down

Topic: MySQL_Connector_Arduino v1.1 not working (Read 3418 times) previous topic - next topic


Jun 27, 2019, 12:07 pm Last Edit: Jun 27, 2019, 12:10 pm by mokos
i have ardruino wifi rev 2 and i've downloaded the latest MySQL_Connector_Arduino library
my server PC has static ip with the latest mysql installed
my system is arch linux x86_64 with the latest kernel
Code: [Select]

#include <SPI.h>
#include <WiFiNINA.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress ip(192,168,1,130);
IPAddress server_addr(192,168,1,2);   // IP of the MySQL *server* here
char user[] = "root";                   // MySQL user login username
char password[] = "***";               // MySQL user login password

// WiFi card example
char ssid[] = "WeatherPi";               // your SSID
char pass[] = "***";                // your SSID Password

WiFiClient client;                        // Use this for WiFi instead of EthernetClient
MySQL_Connection conn((Client *)&client);

char INSERT_SQL[] = "INSERT INTO test.data (`num_steps`) VALUES ('4')";

void setup() {
  while (!Serial); // wait for serial port to connect. Needed for Leonardo only

  // Begin WiFi section
  int status = WiFi.begin(ssid, pass);
  if ( status != WL_CONNECTED) {
    Serial.println("Couldn't get a wifi connection");
  // print out info about the connection:
  else {
    Serial.println("Connected to network");
    IPAddress ip = WiFi.localIP();
    Serial.print("My IP address is: ");
  // End WiFi section

  if (conn.connect(server_addr, 3306, user, password)) {
    Serial.println("Connection Successfull,inserting to database.");
   // Initiate the query class instance
  MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
  // Execute the query
  // 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("Query Success!");
    Serial.println("Connection failed.");

void loop() {

in my server i created a database 'test' with 1 table 'data' and 2 rows 'id' and 'num_steps'

my ardruino is connecting into my network but it freezes when it tries to connect into my database....
is something wrong with my setup or my code?


can anyone check my code and test it, is it freezing also to you? i've scanned the whole internet and i didnt find which mysql version supports


Same here. Still no hints or solutions found

Go Up