Pessoal, realizei a conexão com o BD através da lib. em questão.
Ao tentar realizar o comando de SELECT, no serial monitor a leitura é informada com caracteres aleatórios.
Alguém saberia qual seria o problema?
#include <Ethernet.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(xxx, xxx, x, xxx);
IPAddress ip(xxx, xxx, x, xxx);
IPAddress subnet(xxx, xxx, x, x);
char user[] = "meuusuario";
char password[] = "senha";
char query[] = "SELECT message FROM tcc.hello_arduino";
EthernetClient client;
MySQL_Connection conn((Client *)&client);
MySQL_Cursor cur = MySQL_Cursor(&conn);
void setup() {
Serial.begin(9600);
while (!Serial);
Ethernet.begin(mac_addr, ip);
Serial.println("Connecting...");
if (conn.connect(server_addr, 3306, user, password)) {
delay(1000);
}
else
Serial.println("Connection failed.");
}
void loop() {
row_values *row = NULL;
long head_count = 0;
delay(1000);
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
cur_mem->execute(query);
column_names *columns = cur_mem->get_columns();
do {
row = cur_mem->get_next_row();
if (row != NULL) {
head_count = atol(row->values[0]);
}
} while (row != NULL);
delete cur_mem;
// Show the result
Serial.print("Texto: ");
Serial.println(head_count);
}
Tags:
As respostas para este tópico estão encerradas.
Sim, estão iguais..
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por