Since I wouldn’t get my MKR1000 for at least a month, I figured I’d start working on the code. I would need to accomplish three things:

Connect to my home WiFi

Light weight web server to accept HTTP requests

Parse GET URL for virtual button presses

Send IR signal depending on URL

The MKR1000 should be able to do all this on its own, but my prototype will need a few more components.

Prototyping

Here I have an ESP8266 running the WiFi client and relaying everything to the Arduino Nano over serial. The Nano is running the webserver itself and is responsible for handling the HTTP connections and parsing the URLs. It takes the URL, interprets that as a specific button press, and sends the corresponding IR code.

There is a bit of hackery needed to get this working. First, I’m using AT commands to manage the WiFi connection through the ESP8266. To get all the communication working over software serial, I had to level shift the voltages since the ESP8266 is 3.3v and the Nano is 5v. The ESP8266 also draws a lot of power when connecting to WiFi, so it requires its own power regulator and smoothing cap.

Fortunately, the MKR1000 can do all of this and more on just a single board that’s just slightly larger than the nano (4 pins longer, 3 pins wider on a breadboard).

Since the MKR1000 is a 3.3v board the output from the I/O pins would cause the IR LED to be quite dim. I also plan on having multiple LEDs pointed in different directions, so I’ll need to use the I/O pin to drive an NPN transistor which in turn switches a PNP transistor for each of the LEDs wired in parallel. These PNP transistors have the collector/emitter wired directly to the 5v supply voltage. Going this route, I can have as many IR LEDs as I want and can make an omnidirectional array.

Setting up the Backend

The web page that contains the UI is running on an underutilized C.H.I.P. $9 computer that is already setup on my home network. After doing some research, I found a great tutorial for implementing a REST API for Arduino to control LEDs on adafruit. I used their JavaScript and PHP files to submit the cURL requests and loaded that on the CHIP which is already running apache. After creating a basic HTML page for the remote control, I added the manifest.json and icon files so it can run as a native web app on an Android phone.