Go Down

Topic: database communication internet (Read 1 time) previous topic - next topic


Good afternoon,

Next, I'm almost a week reading articles and publications and simply not found what I want.
To facilitate understanding, I need a variable to be sent to the arduino for a database on the Internet.
Limitations: no direct communication with the computer (the Arduino will be powered by a source and communicate via the ethernet shield)

Given this:
- The classic php that creates a communication via socket will not work;
- The html dynamically created arduino's works, but there is no way to save data;

Possible solution:
- Provide a php page on a web server and make the arduino access (eg www.mysite.com/pagina.php?variable), and through the get() in php play data in the database.

Does anyone know how to do this, or has done something similar?

Thank you, I put my hand to share information about it.
Sorry for my english.
Big hug.


You can have the Arduino-as-client issue a GET request, invoking a PHP script that stores data in a database. I know, because I do just that.

Code: [Select]
  if (client.connect())
    // Make a HTTP request:
    client.println("GET /pub/getValue.php?ID=2 HTTP/1.0");
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");

The getValue.php script is located in the pub folder on the web server. The data of interest is ID=2. The script accesses a MySQL database to get a value from a table with a column called ID. The column contains the value 2. Another column contains the value of interest.

The php script looks like:
Code: [Select]
require_once 'library/functions.php';

include 'library/opendb.php';

// foreach($_GET as $key=>$value)
// {
// echo "<p>GET: $key = [$value]</p>";
// }

$id $_GET['ID'];

$valueQuery "SELECT value FROM beer.tags WHERE ID = $id";
// echo "<p>Query: $valueQuery</p>";
$valueResult mysql_query($valueQuery);
$row mysql_fetch_assoc($valueResult);
$value $row['value'];
echo "$value";

include 'library/closedb.php';

You can easily change what the script does to store data, instead. If you need help, ask.

The art of getting good answers lies in asking good questions.


Seriously what is it? Hell, I imagined something much more complex. I will implement it and post a return. Thank you!!!

Go Up