I am developing a City Security IOT System .
Learning Litlle by Little .
I have some , knowledge , with PHP , MYSQL, HTML,CSS, Bootstrap, Lynux, etc..
But i am very new to python and c .
I am Online all day long , So any help from someone i will be immediately on top of it .
At these moment i am stocked on a situation trying to pass Variables to functions on my sketches like Sim800l.Sendsms() and also Mysql_connector INSERT_SQL[].
Once i can understand how to be able to use a variable instead of " letters,charters " then i will be able to keep going .
I have read more than 30 articles , i have spend more than a week researching , with not success at all .
Next code , inserts into mysql database into my arduino_test (table) valor(field) the Value 'I love Esp8266'
and it does it Correctly NO PROBLEM AT ALL IT WORKS FINE
But as an example , i will want to replace the text VALUES ('I love Esp8266')"; and replace it with a variable containing the (WiFi.localIP()); to insert the ip addres instead .
What i need is an example , so i can understand .
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
/// byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(10,0,0,137); // IP of the MySQL *server* here
char user[] = "eliteve_ardu"; // MySQL user login username
char password[] = "anypassword"; // MySQL user login password
// WiFi card example
const char* ssid = "denis150";
const char* pass = "any `password";
WiFiClient client; // Use this for WiFi instead of EthernetClient
MySQL_Connection conn((Client *)&client);
char INSERT_SQL[] = "INSERT INTO eliteve_arduino.test_arduino (valor) VALUES ('I love Esp8266')";
///char INSERT_SQL[] = "INSERT INTO `eliteve_arduino`.`test_arduino` (`valor`) VALUES (' jose raafael ')";
void setup() {
Serial.begin(9600);
while (!Serial); // wait for serial port to connect. Needed for Leonardo only
// Begin WiFi section
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(">");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
// End WiFi section
Serial.print("insert sql es asi ");
Serial.println(INSERT_SQL);
Serial.println("Connecting...");
if (conn.connect(server_addr, 3306, user, password)) {
delay(1000);
delay(2000);
Serial.println("Recording data.");
// Initiate the query class instance
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
// Execute the query
cur_mem->execute(INSERT_SQL);
// Note: since there are no results, we do not need to read any data
// Deleting the cursor also frees up memory used
delete cur_mem;
}
else
Serial.println("Connection failed.");
conn.close();
}
void loop() {
}
I will much appreciate Some one that can teach me , how to reach this goal , on variables conversions to be able to be send by these functions .
Thanks In advance .