Getting an Arduino to read data from a database

I'm trying to get an Arduino to read messages sent into a database. It would be connected by a USB.

I have code done previously where you submit information to a website and it stores in the database and appears on the site. I want to use this code again but instead, make the Arduino read the information sent through the website.

What would be the best approach to this?


You could try writing a program in Python or other language. What database are you using?

Using serial communication is a easy way:

If you want to read the data via USB then you would need to write an application to run on the PC which receives requests from the Arduino via the USB serial port, fetches the required data from the database and sends the results back via the serial port. If your PC is running Windows then you could use Gobetwino for that. For any other OS you'd need to write your own equivalent, which would be relatively simple to do.

I have code done previously where you submit information to a website and it stores in the database and appears on the site.

Was an arduino involved in this piece before?

No it wasn’t, it was just simply a form that sent names and a category to a database and it appeared on the page once submitted.

What I’m trying to do now is have a php form that sends a name and message to the database.

I then have a separate php page that connects to the database and echoes the name and comment from the database

After this I need to connect this echo to send to the Arduino and show the Arduino is reading the data. I found this tutorial:

Should this do the job?

I have to wait until tomorrow to test it. I’m using a database in college for testing that I need to be connected to ethernet in the building but if I know this should work I can get it working tomorrow hopefully!

You will need a program on the PC that can read/write to the Arduino and deal with the database if the database can't talk to a serial COM channel.

You can use Processing which the Arduino IDE was made to work with. It is free. It looks a lot like Arduino code but it is JAVA instead of C/C++. It is similar enough that you have to take care over details going from one to the other.

Oh ok! Yeah I already have Processing downloaded.

So I use the code in the tutorial in Processing, not in Arduino? Pretty new to all this

You need to use/include the Processing Serial library to talk to the Arduino, it is not in by default:

In the IDE go to File->Examples and in the window that comes up look near the bottom for Libraries->serial.

I don't know if you will be accessing database files or a database engine, there are file access examples.