I'm using this domain http://www.decathlon.commonarchitecture.ca/ to host my phpmyadmin database and php code. I would like to read a specific column of the database in the serial monitor, displaying each number one right after the other. I'm unsure of whether to work with a GSM shield, an Ethernet shield or an Arduino wifi shield. Here is my php code (indents are off I know):


 $dbhost = "mysql.commonarchitecture.ca";
 $username = "arduinodb";
 $password = "*******";
 $db = "arduinodb" ;

    mysql_connect("$dbhost" , "$username" , "$password");
     //echo "Connected" ; 

    //select db
    //echo "Connected to db" ;

  $sql="SELECT * FROM data";



 <!DOCTYPE html>

 <title> Consumption Data </title>


 <table width="600" border="1" cellpadding="1" cellspacing"1">


 <th>Water Consumption (liters per person)</th>



    while($data=mysql_fetch_assoc($records)) {

         echo "<tr>";

         echo "<td>".$data['id']."</td>";

         echo "<td>".$data['date']."</td>";

         echo "<td>".$data['value']."</td>";

         echo "</tr>";

     }//end while




The code works, however I'm unsure of how to go about reading the data on an Arduino (very new to Arduino)

Here's my Arduino code paired with an ethernet shield

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress ip(192, 168, *, *);

EthernetClient client;

char server[] = "www.decathlon.commonarchitecture.ca";

void setup()

  // attempt a DHCP connection:
  Serial.println("Attempting to get an IP address using DHCP:");
  if (!Ethernet.begin(mac)) {
  // if DHCP fails, start with a hard-coded address:
  Serial.println("failed to get an IP address using DHCP, trying 
     Ethernet.begin(mac, ip);

  Serial.print("My address:");

void loop()
    // connect to the server
    if (client.connect(server, 80))
        // print to serial monitor
        Serial.println("ARDUINO: forming HTTP request message");

        // send data the server through GET request
        client.print("GET /index.php?value");
        client.println(" HTTP/1.1");
        client.print("HOST:  ");

        Serial.println("ARDUINO: HTTP message sent");       

        // give server time to receive request

        // get the response from the page and print it to serial port
        // to ascertain that request was received properly
            Serial.println("ARDUINO: HTTP message received");
            Serial.println("ARDUINO: printing received headers and 
script response...\n");

                char c = client.read();
            Serial.println("ARDUINO: no response received / no response 
received in time");

    // do nothing forever after:

My issue now is in getting the Arduino to read my php data, can I not use an http GET request to display data in my serial monitor? Am I using this function properly? There's a ton of documentation on posting Arduino sensor data to the web using php/my sql but not as much on retrieval of set data back into the serial monitor. Here's what the monitor reads currently...

Attempting to get an IP address using DHCP:
My address:192.168.*.*
ARDUINO: forming HTTP request message
ARDUINO: HTTP message sent
ARDUINO: no response received / no response received in time

2 Answers 2


Firstly if you really are using an Uno then you cant read the data without putting the uno on a network (obviously). To do this you could get either a Ethernet shield of a Wifi shield. A wifi shield is probably based on an ESP8266 and you talk to it by creating a serial connection (using a software serial port). There are plenty of examples and messages on here to get you started.

Once that's working you need to write a web client (note that this is much easier if you program the ESP8266 rather than the Arduino). Your client needs to request the page from your server and then parse the returned data and extract the field you want.

While you are waiting for you network shield to arrive you could practice doing it on a Windows PC with Visual Studio, it will be easier to debug.


Any one of a GSM shield, an Ethernet shield or an Arduino wifi shield should be able to pull a web page from a web server and feed it into your Arduino.

I highly recommend buying hardware from people that put lots of example program text on their website, rather than trying to save a few nickles buying "equivalent" hardware from people that don't give any examples, leading to hours of frustration.

Some of the places I've found that have lots of example program text (in no particular order):

If I were you, I would test the hardware with exactly the example programs given for that hardware, and resist the urge to "improve" them until after I confirm that the example programs actually do work. (Perhaps you already did that? If so, please update your question to say the example code seemed to run OK, and exactly which example code you tried, and what minor changes you made that still seemed to run OK, so we can focus on what changed between "partially working" vs. "not even that part working").

(I personally find it easier to parse JSON data sent by a web server set up to send out "Content-Type: application/json; charset=utf-8", or TOML data sent by a web server as "Content-Type: text/plain; charset=utf-8", rather than programmatically parse HTML tables sent by a web server set up to send out "Content-Type: text/html; charset=utf-8", but any of these ways should work).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.