Control an external process via a website

418 Views Asked by At

Lately I've grown some interest in electronics, more specifically the Arduino platform. I've been soldering, and now I have created a device that can turn off my lights and other power related devices via this platform.

The next step is to be able to control the lights and stuff via a website.

The plan is to have a webserver (Raspberry Pi?) and run Apache with a PHP website. When I click a button (load a page with specific parameters, or some Ajax stuff...) I want to trigger an intermediate program (most likely a Java program) which actually talks to a controller Arduino board, which in turn will send the RF commands.

How can I make a website talk to an intermediate program?

2

There are 2 best solutions below

0
On

Take a look at exec and shell_exec or any other process control function available to PHP.

0
On

You can stay entirely on the Arduino if you add an Ethernet shield. In the Arduino demo library there are examples of web hosting programs that you can use as a starting point.

For example, the Arduino can host a simple HTML page with a button in a form. Clicking that button requests a new URL to the Arduino with some value that you can parse for, and then conditionally toggle on or off a switch. There are some recent examples of people doing something similar with this, connecting an similar microcontroller with an X10 Firecracker widget to monitor and control their home network. Here's the description from hack-a-day.