Helps to achieve connect
Now I have the information of my sensors, I only need to pass it to mysql.
This is my try sketch:
#include "SPI.h"
#include "Ethernet.h"
#include "sha1.h"
#include "mysql.h"
/* Setup for Ethernet Library */
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 10);
IPAddress gw(192, 168, 1, 1);
IPAddress sn(255, 255, 255, 0);
IPAddress server_addr(192, 168, 1, 3);
/* Setup for the Connector/Arduino */
Connector my_conn; // The Connector/Arduino reference
char user[] = "root";
char password[] = "" ;
char INSERT_SQL[] = "INSERT INTO shop.data VALUES ('Hello, MySQL!', 77)";
void setup() {
Serial.begin(115200);
}
void loop() {
Ethernet.begin(mac_addr,ip,gw,sn);
Serial.print("Local IP is: ");
Serial.println(Ethernet.localIP());
delay(1000);
Serial.println("Connecting...");
if (my_conn.mysql_connect(server_addr, 3306, user, password))
{
delay(500);
/* Write Hello, World to MySQL table test_arduino.hello */
my_conn.cmd_query(INSERT_SQL);
Serial.println("Query Success!");
}
else
Serial.println("Connection failed.");
}
... But the serial monitor only says:
Connecting...
Connection failed.
There is something special to configure the mysql to accept the orders of the connector library?