Arduino based SQL Queries

We are successfully performing SQL queries on two Arduino’s, one in the US, one in Italy, inserting data into a HostGator hosted MySQL server. We are polishing a spiffy PHP / Ajax interface so you can see the results.

INSERT – Done!
SELECT – Done!
UPDATE – Done!
DELETE – Done!

Got all 4 queries working. DELETE, UPDATE, SELECT, and INSERT. Ran out of memory on the UNO, had to step up to a 2560.

Become the Maker you were born to be. Try Arduino Academy for FREE!

Here’s a taste of what’s going on:

void read_data() {

sensorValue = analogRead(sensorPin);
char buf[128];
sprintf(buf, “INSERT INTO spspence_test_arduino.temp VALUES (%i)”,
sensorValue);
my_conn.cmd_query(buf);
Serial.println(“Data read and recorded.”);
Serial.println(sensorValue);

}

void setup() {
Ethernet.begin(mac);
Serial.begin(9600);
delay(1000);
Serial.println(“Connecting…”);
if (my_conn.mysql_connect(server_addr, 3306, user, password))
delay(500);
else
Serial.println(“Connection failed.”);
}

void loop() {
delay(read_delay);
read_data();
}

Become the Maker you were born to be. Try Arduino Academy for FREE!

 

Learn more by reading Beginning Sensor Networks with Arduino & Raspberry Pi by Charles Bell

 

Subscribe
Notify of
guest
0 Comments

Archives

0
Would love your thoughts, please comment.x
()
x