Arduino Ethernet, POST to PHP to MySQL

June 28, 2013

This is to help others figure out how to send data from an
ARDUINO with ETHERNET to a MySQL database
via the POST method through a PHP page.


Arduino Uno with Ethernet Shield
Arduino Uno with Ethernet Shield

I am not an expert. 
I am just a hack.
I do not understand all of the code nuance.
I take what others have done, substitute my variables and modify the code to my requirements.
There are a million ways to skin a cat.
This is one way that I have muddled through.
I don’t go into how to set up a MySQL data base, try google.


Make a PHP file called config.php.

CODE for config.php


Make a file called update.php

CODE for update.php



Multiple variables being posted might look like…

In PHP you can break lines for readability.
End of line or statement is denoted by a semicolon.


6 thoughts on “Arduino Ethernet, POST to PHP to MySQL

    1. Tonnie, if you are referring to the config.php file, it can go anywhere on your web server as long as the call for it, in the update.php file, has the directory with the name.
      If config.php is a subdirectory called “configs”
      The require statement in update.php would look like this…



  1. It is excellent and very simple, thank you very much.

    Now the request: I can connect my Arduino (MEGA2560) and my Crestron processor (QM-RMC) via TCP/IP. The MEGA is server and Crestron is the client. It is a good alternative for to extend few and expensive relay ports that has Crestron. I need that the activities of these ports are recorded in a MySQL database, to make it, I configured the MEGA2560 as a client.

    Now, I appeal to your generosity, could you advise me how to have both configurations in a single arduino sketch?

    Regard, Johann.

Leave a Reply

Your email address will not be published. Required fields are marked *