Remote LED control with Arduino and the Ethernet Shield using mysql

Hello I was wondering if there was a example out there that i can control three led and a relay using Ethernet and mysql? everything i found online so far i searched seems to be wanting to know the Ip address of the Ethernet shield and at times i do not know the ip address. I just wanted to store it in mysql and let ehte Arduino trigger if it's a 1 or a 0 on or off. Can someone please point me in the right direction where i can find something like this?

Joseph

You don't need to get IP address of Ethernet. What you need to do:

  1. install XAMPP (include. Web Server PHP and MySQL) on your PC
  2. create Database
  3. create a PHP code file that read data from MySQL
  4. write Arduino code that periodically make HTTP request to WebServer (PHP file)
  5. In Arduino code, get the ON/OFF from HTTP response, control LED and relay.

See how to make HTTP request on Arduino

What is mysql doing in this stack? An arduino can persist a small amount of data to EEPROM, if that's all you are trying to do.

To find the IP address of your ethernet shield, log on to your home router. Your router runs the DHCP service that hands out IP addresses to devices. You can probably instruct it to always hand out the same address to your ethernet board, which it identifies by its MAC address.

I am guessing you want to update the MySQL database from, say, a web browser, maybe on a smartphone. You want the Arduino to respond to these changes by switching leds etc.

In that case you configure the Arduino as a web client which regularly polls the MySQL database to see if there are new commands it has to respond to.

You’ll need to write php code to interface between the remote web server and database.

Hello Yes A lot of times I'm not at home and i would love to see how temperature is and i would love to control two of my lamps that uses relays. The problem is i know how to set data to mysql such as temperature i learned that from online. But as far as receiving commands like turning on and off a led or relay i do not know how to do so.

Why I'm using mysql is because My external Ip address changes all the time. have the mysql on a shared hosting with a webpage to view the temperature. This is where i got the code for the temperature at here. One of the links in there took me to a github page here. I have a php page to view temperature also I'm working on sending the commands from the php page to put a 1 or a 0 in the mysql. but i do not know how to grab the data using arduino from the mysql.

Joseph

Hello I'm truely sorry but i might be cross posting from another post i had a couple years ago here. 6V6GT and others Helped me on that. I didn't remember it. I thought i had something But i wasn't sure i looked back at all the post and found it. I'm not sure if i update that post or this now I'm confused.

Joseph

Hello no i can not. I share a internet connection with 6 other people in my building the owner Lets us use our own ports for us. But from what i have saw on the router doesn't have a way to set up that.

Joseph

ok, than use your webspace/mysql as a poor-mans-dyndns.

Send every 5 minutes a request to your webserver, the webserver will keep track of your arduino public ip (in the db)
Host a page on your webserver, iframe an external link to the ip:port of your Arduino.
On the router introduce a port forwarding to your Arduino
On your Arduino setup a webserver and enable some switches.
See if you get the IDE example Ethernet | Webserver - working.
if you are external/outbound - connect to your public Webserver and the Arduino page should get iframed.

Hello the problem is not the php or mysql. I'm okay with that. What I'm not Fimliar with is in arduino how to send the data to the mysql or php to send to mysql. I totally forgot a couple of years ago i tried this project and i couldn't remember why i stopped it. Now I'm back at it once again. 6V6GT Helped me with this problem back then. I'm revisiting that old post i didn't even remember working on. I will port a update in a day or two thank you all for the help.

Joseph