access arduino uno + ethernet shield from php web server.

I have searched a lot regarding this topic, and i found things like php_serial library and connecting arduino with router (port fowarding). I want to access my arduino without being attached to my computer so serial is not an option? the other option seems right but have to provide port number so that the router fowards it to arduino. Can anybody guide me the proper way to do this, i intend to use php and haven't found enough good resources.

I hope i made the problem clear, any kind of help is much appreciated.

Can you clarify what you intend to use this setup for? If you want a system to read sensors and write actuators over an internet connection then search "arduino web blink" for a number of ways to achieve this.

The portion you are talking about with the ports is called "port forwarding" - basically, most home routers block all incoming connection attempts (you would be amazed/terrified to see how many connection attempts you get in an hour from all over the world - not nice folks out there!!). The Arduino would need to have a web page and be "listening" on the port you have configured in your router to forward to the Arduino. Usually, the Arduino would have a static (fixed) IP address so the router knew where to send the connection attempts. You would need to have the Arduino configured either with a ethernet shield (connected via cable to your router/switch) or a wifi module (like the ESP8266) which the router (assuming your router supports wifi) would direct the connection attempt to. It takes a bit to get your head around all the pieces required - probably starting with the suggested "arduino web blink" will give you some ideas (I'm still trying to find all the pieces to my project along the same lines).

mikey

thank you guys for your reply.

The board has a static ip.
all i want to do is to give a message (command) to arduino via http (php) to switch on a led. there are many resources about from arduino to a php server but a few way around.

Isn't THIS what you are trying to do in practice?

yes exactly but the webpage is not hosted on the SD card but on the localhost and i am using php instead of javascript.

So you have a php web page hosted on a PC in your local network that you want your arduino to access in some way? In this case arduino is a http client rather than a server?

yes, arduino is a client and the server is on the local network (localhost).

Be careful when you use the term "localhost" - I think you are meaning a machine on your local network, but in the network world, it means the computer you are on. See localhost - Wikipedia for more information (and note the IP address of "localhost")

In that case port-forwarding is done on your router to your local PC and doesnt involve the arduino at all.

You will need some kind of wifi or ethernet shield for arduino.

Start with https://www.arduino.cc/en/Tutorial/WebClient or search for "arduino http client "

Next look at some of the examples from the search “arduino fetch data from web page”

Do you have an ethernet shield (preferably w5100 based)?

yes i have an ethernet shield and the server is on my machine (127.0.0.1) from which messages would be sent for arduino and it should switch on or off the led.

Its unlikely that the address 127.0.0.1 will be useful- nothing apart from the computer itself can access that address (which is why its called "localhost"). This is probably how you are accessing the generated web page from a browser on the same computer: Other devices need a different address.

If your computer is connected to the network it should have another address- most likely something starting with 192.168. That is the address you will have to configure in your arduino to retrieve data from the computer.

When using this mode there is no way for the computer to "send" a message to the arduino. The arduino will have to regularly retrieve a file from the computer and then look at the contents to determine if the LED is ON or OFF. This is called "polling"

That was what I pointed out back in #8 the trap using the term "localhost". It will only work on that machine that you are on if the web server is also on that same machine.

now i get your point, i'll try out some more things and see what happens.
thank you guys for the help much appreciated!!

bro i am also trying to do samething , but did'nt find any solution