ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
332 stars 133 forks source link

MySQL_Connection conn variable setting make the Arduino unusable #43

Closed berkaysit closed 6 years ago

berkaysit commented 6 years ago

https://github.com/ChuckBell/MySQL_Connector_Arduino/blob/17a379a6604f65cc3278b40eab449c5a48a90a35/examples/basic_select/basic_select.ino#L47

This line locks the Arduino MKR1000 after uploding the example sketch. Arduino couldn't get any COM port on Windows Device Manager and doesn't do anything. I have to use reset pin for bootloader startup and upload another safe sketch (Blink ) in order to set the device normal operating.

berkaysit commented 6 years ago

It's better if give more information;

I have Arduino MKR1000 and MariaDB Server installed on a remote machine on Azure. The Example "Connect_Wifi" works great if I change the #include <WiFi.h> statement as #include <WiFi101.h> So we see the example can connect to Maria DB without doubt. After that, I would like to change the code of basic_select example. Because of it writen for Ethernet, I replaced the lines about network connection with Wifi101 required strings. So, I replaced the following original lines

EthernetClient client; 
MySQL_Connection conn((Client *)&client);
// Create an instance of the cursor passing in the connection
MySQL_Cursor cur = MySQL_Cursor(&conn);

void setup() {
  Serial.begin(115200);
  while (!Serial); // wait for serial port to connect
  Ethernet.begin(mac_addr);
  Serial.println("Connecting...");
  if (conn.connect(server_addr, 3306, user, password)) {
    delay(1000);
  }
  else
    Serial.println("Connection failed.");
}

with following lines

WiFiClient client;            // Use this for WiFi instead of EthernetClient
MySQL_Connection conn((Client *)&client);
// Create an instance of the cursor passing in the connection
MySQL_Cursor cur = MySQL_Cursor(&conn);

void setup() {
  Serial.begin(115200);
  while (!Serial); // wait for serial port to connect

  // Begin WiFi section
  int status = WiFi.begin(ssid, pass);
  if ( status != WL_CONNECTED) {
    Serial.println("Couldn't get a wifi connection");
    while(true);
  }

  // print out info about the connection:
  else {
    Serial.println("Connected to network");
    IPAddress ip = WiFi.localIP();
    Serial.print("My IP address is: ");
    Serial.println(ip);
  }
  // End WiFi section

Later, I uploeded the sketch to the Arduino and it stoped working. It even can not connect as a COM port to PC. If I comment the line MySQL_Cursor cur = MySQL_Cursor(&conn); and all the loop() block, it can work, of course only make a WiFi connection.

ChuckBell commented 6 years ago

I will try to test this next week and post my findings.

Please note: The connector does not support any variant of MySQL except those maintained and released by Oracle.

berkaysit commented 6 years ago

May be it's a Arduino memory issue. I configured the Insert example for WiFi101 like I did before for Select example and it worked.

ChuckBell commented 6 years ago

Excellent! Would you please consider closing the item if your problems have been solved?

Are you still using an alternative MySQL server?

On 5/26/18 6:15 AM, Berkay wrote:

May be it's a Arduino memory issue. I configured the Insert example for WiFi101 like I did before for Select example and it worked.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/43#issuecomment-392251727, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4IXs7EC5c7h1L6ryR78OMbt8VqjKks5t2Ss1gaJpZM4UF5B4.

berkaysit commented 6 years ago

Actually the problem is not solved, but I my opinion some kind of memory issue on MKR1000 caused the error. I am still using MariaDB. Thank you very much for your interest.