1

Is it at all possible to send data to a MySQL database from an Arduino with an Ethernet shield?

Currently I have data outputting to a webpage, but I would like to record a history of that data - can I send the data directly to a databse?

Alternatively, can I use PHP to capture the data and send it to a database without having a page constantly open, as I would like to record data over a series of days.

1
  • As long as you can throw the data onto a web page in the Arduino, consider creating a page on the Arduino with the data in a standard format like XML or JSON. Then you can use pretty much anything else to grab the details regularly and stuff them in a database. Everything from your phone to an IBM mainframe will have tools available to grab data from a web page by http, and throw it into a database with ease. I'd do as much heavy lifting outside the Arduino as you can; there's not a lot of headroom for complex work on them. Commented Jun 23, 2014 at 17:46

3 Answers 3

4

Yes you can, although it might be tediouis. The details of client/server protocol are here: http://dev.mysql.com/doc/internals/en/client-server-protocol.html so it's just a matter of implementing it in Arduino. Given program memory limitations, it might a difficult task though.

The other option, having database exposed as a webservice would be a lot easier. You can define the protocol however you wish, and leave all MySQL handling to PHP.

Sign up to request clarification or add additional context in comments.

Comments

2

Without a web server and PHP, you would need a MySQL client library for the Arduino, but I don't think one exists. AFAIK it's not possible to communicate directly with the MySQL server otherwise.

If you install a web server with PHP alongside MySQL, you can set up a PHP script that listens to the Arduino's requests and stores the passed-in data into the database. Those connections are between the Arduino and the web server, so you don't have to keep any page constantly open.

Note that the PHP script won't listen just to your Arduino but to anyone sending a request to it, so you should make sure that you can trust the passed-in data before storing it in the database.

Comments

2

This is now possible with the new Connector/Arduino MySQL Database connector. Check it out at: https://launchpad.net/mysql-arduino. Also, see my blog at: http://drcharlesbell.blogspot.com/2013/04/introducing-mysql-connectorarduino_6.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.