Access MySQL database from Imp

Is there anyway to directly connect to a MySQL database from my electric imp?

I have a php script currently getting data from my imp and inserting it into my database. But I would really rather cut out the middle man…

There is not. The Electric Imp platform is designed to make connecting to other web services really easy.

If you would like to cut out the middle man, I would encourage you to look at a service like Firebase. Firebase is a hosted database that exposes RESTful endpoints for you. It allows you to create and manage a database without having to host your own server - and allows you to read and write to it from the imp without having to have scripts that sit between your imp and your db.

I’m sure there are other services out there that are similar to Firebase, that’s just the one I’m familiar with :slight_smile:

Hi beardedinventor,

Thanks for the suggestion. I’m looking into that as well as the agent object API.

Thanks so much for the help!

I know some people are interested in taking the php route that you have… Any chance you could give more information about the PHP side? Possibly code? I know the community would appreciate your input!!

In terms of sharing code the issue is what do want to store. For many of my imps it’s temp/humidity/movement/activity etc. for others door open/closed looks like a much better solution as it’s very easy to setup link data togethermodeling-time-series-data. I was going to do a tutorial on this may be something others would help with. It would allow direct posting from agents.

I was referring to this:

I don’t have much experience in PHP so any help is awesome!!

@physicsnole happy to help I’m not a programmer but know enough to get stuff in an out of MySQL with php so happy to help.

Do you have your own PHP/MYSql server or a hosted solution?

I wanted to have a desktop at home with apache running for a server. Then have a PHP file on the server that takes imp data and records it! Do I need MySQL or can I just use PHP to a file on the server?

A database is much better solution if you want look at historical data or given time period. For example I’m often looking at Temp vs Humidity on a given day. Graph data from MySQL

What are you looking to store?

You don’t strictly need a database…but it’s a really good idea.

I personally wouldn’t bother self-hosting.

I’ve been playing around with several services. Xively,, tempodb, datadog, PRTG, and stathat all have free/limited options that are quite good. Graphing is built in to all of these options. Xively’s my favorite so far - it was pretty trivial to connect it to a Hannah board and log temperature, and Xively turns it in to a nice graph -

Firebase seems nice too. Haven’t tried it yet, can’t speak to it, sounds like a more powerful tool than you’d want if you’re just logging sensor data.

Check out also Parse.

Dropbox also has a new datastore API of sorts - haven’t looked at it yet, but it might be promising.

A friend of mine works at Parse. They have lovely t-shirts. I’m using them to drive some interesting bridge code (Imp -> Agent -> Parse -> httpebble -> Pebble) but again, they’re general-purpose and this is a pretty specific subproblem (time-series datalogging.)

Dropbox’s datastore API seems to be designed to replace iCloud Sync, which is laudable but I’m not sure what Imp project I’d use it for - most of the things it solves are things I’d solve using the Planner.