Closed pedrotvo closed 5 years ago
What size board are you using? Random lockup and reboots are most likely caused by running out of memory. In my experience, whenever to get < 500 bytes of data memory, the Arduino becomes unstable.
Also, ensure you are calling the close() on the connector objects to fully remove the memory. Simply disconnecting doesn't free memory.
I'm using a Mega-like board. So, probably not a memory issue.
But, I tried to insert the close()
function on my_conn.close()
and the IDE is telling me that there is no member called "close" on class Connector.
[...]
// if the inserted password is the same as the received from the query's result set
if (strcmp(auxSenha, senha) == 0) {
//activate relay and turn on the green led
lcd.clear();
lcd.print("Bem vindo(a):");
lcd.setCursor(0, 1);
lcd.print(auxNome);
digitalWrite(relePin, HIGH);
digitalWrite(pinG, HIGH);
delay(1000);
digitalWrite(relePin, LOW);
digitalWrite(pinG, LOW);
my_conn.close(); //here
reset_suav();
} else {
// in case they're not the same or password not found
// turn on red led and write msg on lcd
digitalWrite(pinR, HIGH);
lcd.clear();
lcd.print("Usuario nao");
lcd.setCursor(0, 1);
lcd.print("encontrado.");
delay(1000);
digitalWrite(pinR, LOW);
my_conn.close(); //here
reset_suav();
}
}
}
auxKpd = 0;
senha[0] = '\0';
auxNome[0] = '\0';
auxSenha[0] = '\0';
auxSenha1[0] = '\0';
i = 0;
lcd.clear();
}else{
my_conn.close(); //here
my_conn.disconnect();
my_conn = Conecta();
}
}
[...]
This is where I inserted the close() function.
Ok. What version of the connector are you using? You can find this in the mysql_packet.h file. (e.g. #define MYSQL_VERSION_STR "1.1.1a")
Note: the latest version is 1.1.1a. If you're not using that version, you should be. That version supports the close() methods.
On 10/2/18 11:52 AM, Pedro Otávio wrote:
I'm using a Mega-like board. So, probably not a memory issue. But, I tried to insert the |close()| function on |my_conn.close()| and the IDE is telling me that there is no member called "close" on class Connector.
|[...] // if the inserted password is the same as the received from the query's result set if (strcmp(auxSenha, senha) == 0) { //activate relay and turn on the green led lcd.clear(); lcd.print("Bem vindo(a):"); lcd.setCursor(0, 1); lcd.print(auxNome); digitalWrite(relePin, HIGH); digitalWrite(pinG, HIGH); delay(1000); digitalWrite(relePin, LOW); digitalWrite(pinG, LOW); my_conn.close(); //here reset_suav(); } else { // in case they're not the same or password not found // turn on red led and write msg on lcd digitalWrite(pinR, HIGH); lcd.clear(); lcd.print("Usuario nao"); lcd.setCursor(0, 1); lcd.print("encontrado."); delay(1000); digitalWrite(pinR, LOW); my_conn.close(); //here reset_suav(); } } } auxKpd = 0; senha[0] = '\0'; auxNome[0] = '\0'; auxSenha[0] = '\0'; auxSenha1[0] = '\0'; i = 0; lcd.clear(); }else{ my_conn.close(); //here my_conn.disconnect(); my_conn = Conecta(); } } [...] |
This is where I inserted the close() function.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/65#issuecomment-426327227, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4DtCyj1b8WRxIM-ZTmwO8Fl1n7Hmks5ug4vTgaJpZM4W984d.
Oh, in fact, I was using version 1.0.4ga from LaunchPad.
I've downloaded the latest version, read the manual and made the changes on functions and libraries.
On the first attempt, I was just closing connection and running the code again, reconnecting, and it did not work. So I wrote the code in order to close the connection and restart the arduino everytime it sent queries to MySQL and it WORKED!
Thank you so much, doc!
Hello, everyone!
So, I've been working on a project with the same configuration as this guy -> https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/59#issue-346506980
Made the changes @ChuckBell mentioned on the libraries and everything worked fine.
But, what happens is that everytime I start the board, the first request I send to the database works perfectly, but when the sketch send a second request, everything restart and the board take some (way more) time to connect to the database.
Here it is the source code of my project, with some comments for better understanding:
(This is my first project with arduino, so it might have some brute coding at some parts, but as my cat says "if it fit, it sit")