Ardunio and MySQL

Hello all,

I've been recently looking in to a project that includes an Arduino and LEDs. The idea is that the LEDs will be activated by finding strings of text located in either a text doc, csv doc, or (hopefully) a MySQL database. Any one of those documents would be updated in real-time and it is my hope that Arduino would have the ability to read them in real-time or near real-time. I have no experience with MySQL, but I know it is possible to pipe the data being created in to a MySQL database. I guess the important question would be, is this even possible? Can you point the Arduino to any one of these files (or however MySQL is structured) and have it sift through the text for a string that would enable an LED (what would essentially be a warning). Any ideas would be appreciated.

Thanks!

With GoBetwino running on your PC (Windows only) you can have your Arduino send commands that makes GoBetwino read a line from a txt file and return the result to Arduino.

Of course you cant read and write to a txt file at the same time o a little housekeeping would be needed.

In order to extract data from mysql you'll have to write some sql scripts (on a PC). You can then send the results to the Arduino choosing a file format that is easy to parse (e.g., csv). How near real-time you can get depends on how frequently your data change, but don't expect the Arduino to be exceptionally fast. If you really have a requirement for real-time or near real-time you should concentrate the most processor intensive tasks (finding strings) on a PC, and send to the Arduino only a pre-digested stream of data.

Can this be done? Absolutely. Can it be done (near) real-time, yeah, with 'near' being the key word here. There will be several bottle necks here. First the Arduino needs to send a signal to fetch the data, then it needs to wait for that data to be parsed, executed, and the results sent back, then the Arduino has to process that information, translate it to bytes that the LEDs will understand and send that out. Ask yourself if all of that can be done in real-time.

But, getting past that 'real-time' bit, the answer is still, yes, it can be done. I have a custom setup where I have an Arduino clone requesting SNMP information from my servers, parses the info, and if there's an alarm, it will send a text message to my phone. It doesn't take much to send the request to an MySQL server instead. As someone else pointed out, you need a wrapper in between what the Arduino is sending versus what the MySQL server understands.

Unless you are going to do some very complicated coding on the PC, all of those inputs will need to be polled to pick up new events. Polling Gobetwino from the Arduino would involve starting from scratch for each poll. It would be far more efficient to have an application on the PC coded to consume events from all those various sources (keep a file handle open and read new content as it is appended, look for ways to have the database trigger your code when new data arrives, or query it for new data at regular intervals), and push data out to the Arduino when it arrives.

You could get this working with Gobetwino but it would be far less efficient.

By the way, this is not a 'real time' problem as far as I see it.

Batty_Roy: Hello all,

I've been recently looking in to a project that includes an Arduino and LEDs. The idea is that the LEDs will be activated by finding strings of text located in either a text doc, csv doc, or (hopefully) a MySQL database. Any one of those documents would be updated in real-time and it is my hope that Arduino would have the ability to read them in real-time or near real-time. I have no experience with MySQL, but I know it is possible to pipe the data being created in to a MySQL database. I guess the important question would be, is this even possible? Can you point the Arduino to any one of these files (or however MySQL is structured) and have it sift through the text for a string that would enable an LED (what would essentially be a warning). Any ideas would be appreciated.

Thanks!

I think your project divide into 3 parts;-

  1. Full-Text Search App/DB. i.e. Inverted index database. 2 candidates, MySQL Full-Text Search and Apache Lucene. Lucene is much faster and scalable.

  2. Parsing app, Parsing text from text doc, csv doc... insert it into Full-Text Search database. Apache Tika support a lot of format document parsing. It has parser for Microsoft office document, PDF, Image, sound, video, mbox( parsing email server)... complete list: http://tika.apache.org/1.3/formats.html

  3. Gateway between Full-Text Search server and Arduino.

The Apache Solr provide all the functions above.

Solr=Lucene+Tika+Web RESTful service.

Conventional wisdom is that the arduino is too short on memory to cram a sql engine onto it. You'll always need an external mechanism to interface to the database for you. I wonder however whether the Due changes this. A bit of cursory googling didn't turn anything up but it's not an easy topic to search for - far too many irrelevant hits.

wildbill: I wonder however whether the Due changes this.

No! not until it is in support platform

Platform=Operating System+Architecture

Supported Platforms: MySQL Database

Oh sure, I don't see MySQL running on a Due anytime soon, but a SQL client - that's a different matter I suspect.

Mysql+Web RESTful service end point will support by Arduino.

PHP REST SQL