MySQL Forums
Forum List  »  Connector/Arduino

Helps to achieve connect
Posted by: Miguel martinez
Date: October 10, 2014 12:38AM

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?

Options: ReplyQuote


Subject
Views
Written By
Posted
Helps to achieve connect
2039
October 10, 2014 12:38AM
1026
October 14, 2014 02:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.