So finally after lot of troubleshooting I got success uploading data to database , however I am facing one problem,
I want to insert data to table after every 5 minute if I use delay, the web server gets stuck and auto refresh doesn't load the page, so how should I have database inserting after every 5 minute irrespective of the loop function cycles
I have implemented client and server in the same sketch, here is the full code:
Since I have RTC module attached to arduino I just realised I can calculate 5 minute difference and insert after every 5 minute of last insert .
so I put this
int mint = util::getMinute();
if (util::getMinute() - mint >= 5)
{
// inserting to sql database on mysql server
INSERT_SQL = "";
INSERT_SQL.concat("INSERT INTO arduinoSensorData.outTempLog (out_temperature) VALUES ('");
INSERT_SQL.concat(tempInC);
INSERT_SQL.concat("');");
const char *mycharp = INSERT_SQL.c_str();
delay(1000);
if (!connected) {
my_conn.mysql_connect(server_addr, 3306, user, password);
connected = true;
}
else if (connected == true)
{
delay(500);
Serial.println("Connection Successfull,inserting to database.");
Serial.print("Inserting : ");
Serial.println(INSERT_SQL);
Serial.println("Connection Successfull,inserting to database.");
my_conn.cmd_query(mycharp);
}
else {
Serial.println("Connection failed.");
}
mint = util::getMinute();
}
Robin2:
How do you know?
What message do you get?
What line is it failing at?
...R
Sorry bout the wrong message, i ran select query in db before 5 minutes after first run obviously there won't be, so cocked later and it does work thank you very much (y)