So I have a PC running a few services for my house. I'm trying to automate my home a little and would like to control various things in my house. Is it possible to control an Arduino from my HTML Apache server? I was thinking about going from the PC -> Raspberry pi -> then serial connection to an Arduino but that seems over excessive.
closed as too broad by gre_gor, sempaiscuba, VE7JRO♦, Greenonline, Dmitry Grigoryev Aug 16 '18 at 13:20
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
If you attach a 'network adapter' to the Arduino, you can start a TCP server on Arduino. The server, a telnet server or a web server will listen for commands sent from computer. In case of web server, you can send commands from web browser too. Other option is to use UDP communication. Arduino can listen UDP.
The options for the network are Ethernet or WiFi. Both are in form of shields or modules. For Ethernet Wiznet 5100 and 5500 chips are best supported and for WiFi the esp8266 is the common option.
If your Arduino has to be far from your PC, then giving it some kind of network interface, as suggested in Juraj's answer, is probably the best solution. If, on the other hand, you can have the Arduino next to the PC, the simplest option is to use the USB connection.
You will need some kind of command interpreter on the Arduino side. You can implement your own command protocol. For inspiration, take a look at this simple Arduino command line interpreter. Or you can use an already made interpreter, like Firmata, which uses its own binary protocol, if you find support for the protocol on the PC side.
I have no experience communicating with an Arduino from an Apache server. I use a Node.js server instead, which seems like a more popular option for this kind of job. If you want to use Apache, you will have to send commands from it trough the USB-emulated serial port. You may be able to do it from a PHP script, but beware that the Arduino resets every time you open the serial port connection, unless you put a capacitor between RST and +5V. Or you may use a Node.js server on a local port and have Apache reverse-proxy it.