How to Post Electric Imp data to a SQL database?

Hi :
I want use Electric imp send data to a SQL or MySQL database.
Is Electric imp support php script ? or any method could send data to SQL DB?
If yes, Is any sample code for reference?


For sure use JSON data. The imp and PHP are both good at encoding and decoding JSON, which makes it easy. To answer your question, the imp doesn’t do PHP. You’ll have to have a website (webhost account) to handle the PHP and SQL.

The imp will create the JSON array and POST to a remote PHP script. The PHP script will receive the data and write to SQL. Anyone that knows your PHP URL could post data to it, so you’ll also use an API key to make it more secure. Only the imp and the PHP script will know the key. You could have several imps all writing to the same database too. And of course the PHP script can send data back to any of the imps. You may want a visible LED indication that the PHP script successfully write to SQL.

I can provide an example later today. For now, let us know what kind of data and how much, and how often you are saving it.

You are going to have to specify what database and API you’re using too. Plenty of SQL databases offer a REST frontend for queries though…