Olá amigos, estou tentando fazer um Insert simples de teste porem so aparece a mensagem, conectando… e nao envia para o BD.
Connected to network
My IP address is: 2.2.2.2
Connecting to SQL…
#include <ESP8266WiFi.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
char ssid = “iot”;
char pass = “iot123”;
IPAddress server_addr(2,2,2,2); // IP of the MySQL server here
char user = “root”; // MySQL user login username
char password = “”; // MySQL user login password
//int numero = 10;
// Sample query
char INSERT_SQL = “INSERT INTO esp8266.teste (texto) VALUES (‘Ola’)”;
WiFiClient client; // Use this for WiFi instead of EthernetClient
MySQL_Connection conn(&client);
MySQL_Cursor* cursor;
void setup()
{
Serial.begin(115200);
// Begin WiFi section
Serial.printf("\nConnecting to %s", ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// print out info about the connection:
Serial.println("\nConnected to network");
Serial.print("My IP address is: ");
Serial.println(WiFi.localIP());
Serial.println("Connecting to SQL… ");
if (conn.connect(server_addr, 3306, user, password))
Serial.println(“OK.”);
else
Serial.println(“FAILED.”);
// create MySQL cursor object
cursor = new MySQL_Cursor(&conn);
}
void loop()
{
if (conn.connected())
cursor->execute(INSERT_SQL);
delay(5000);
}