EStou tentando conectar usando todos os tipos de exemplos que achei tanto na internet quanto nos exemplos oficiais e não consigo conectar, alguem poderia me auxiliar ?
O codigo que uso é esse?
#include <SPI.h>
#include <Ethernet.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte subnet[] = {255, 255, 255, 0}; // Define a máscara de rede
byte gateway[] = {10, 0,68, 1}; // Define o gateway
char user[] = "arduino"; // MySQL user login username
char password[] = "304219"; // MySQL user login password
char banco[] = "USE arduinodb";
IPAddress server(127, 0, 0, 1);
EthernetClient client;
MySQL_Connection conn((Client *)&client);
void setup() {
Serial.begin(115200);
while (!Serial); // wait for serial port to connect
Serial.println("Inicializando Ethernet com DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failha ao configurar Ethernet usando DHCP");
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield não foi achada. :(");
} else if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet não conectado.");
}
// no point in carrying on, so do nothing forevermore:
while (true) {
delay(1);
}
}
// print your local IP address:
Serial.print("Meu IP: ");
Serial.println(Ethernet.localIP());
IPAddress ip(Ethernet.localIP());
Serial.println(ip);
Serial.print("Mascara Subrede: ");
Serial.println(Ethernet.subnetMask());
Serial.print("Puerta Enlace : ");
Serial.println(Ethernet.gatewayIP());
Serial.print("DNS ServerIP : ");
Serial.println(Ethernet.dnsServerIP());
Ethernet.begin(mac, ip, subnet, gateway);
Serial.println("Conectando...");
if (conn.connect(server, 3306, user, password)) {
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
cur_mem->execute(banco);
delete cur_mem;
delay(10000);
Serial.println("Conectado...");
}
else
Serial.println("Falha na Conexao.");
conn.close();
}
void loop() {
IPAddress ip(Ethernet.localIP());
Serial.begin(115200);
while (!Serial); // wait for serial port to connect
Ethernet.begin(mac, ip);
Serial.println("Conectando...");
Serial.println(ip);
if (conn.connect(server, 3306, user, password)) {
delay(10000);
Serial.println("Conectado...");
}
}