MKR1000 Universal Remonster!




WiFi connected universal remote with smart phone webapp.

Things used in this project

Hardware components

Arduino MKR1000
Arduino MKR1000
Arduino Nano R3
Arduino Nano R3
General Purpose Transistor NPN
General Purpose Transistor NPN
Triggers the PNP transistors of IR LED array
Resistor 1k ohm
Resistor 1k ohm
pulls down NPN transistor
IR transmitter (generic)
IR LEDs. Get wide angle if you have a choice
General Purpose Transistor PNP
General Purpose Transistor PNP
One PNP transistor per IR LED; you can do much more than two

Software apps and online services

Arduino IDE
Arduino IDE

Story

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.

Writing the Code

On the MKR1000 side, I just had to switch out the ESP8266WiFi.h with the WiFi101.h library. Then I trimmed down the webserver to just accept a GET request, parse the URL, send a 200 OK, and then disconnect.

void loop() {
 // listen for incoming clients
 WiFiClient client = server.available();
 if (!client) {
   return;
 }
   Serial.println("new client");  // can be removed after debugging
   // Wait until the client sends some data
   while(!client.available()){
     delay(1);
   }
 // Read the first line of the request (the GET string)
 String req = client.readStringUntil('\r');
 Serial.println(req);  // can be removed after debugging
 // Send request over to Arduino Nano
 Serial1.println(req);   
 client.flush();
   // give the client time to receive the data
   delay(1);
   // close the connection
   client.stop();
   client.flush();
   Serial.println("client disconnected");  // can be removed after debugging
}

Based off the URL, the Arduino would send the IR code that was mapped to the button pressed. I say “would” because I just found out the IRremote library I have used in the past does not work with the SAMD ARM based Arduinos (which the MKR1000 is).

READ  InnoComm NXP i.MX8M System on Module – An Advanced Video Processing SoM with Connectivity

Rather than re-writing the library, I’ll just output the commands from the MKR1000 over serial to an Arduino Nano and have that drive the LEDs.

READ  Slipper Shining with LED strip & Xadow

JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w




Leave a Comment

*
= 4 + 3

(Spamcheck Enabled)

Read previous post:
ESP8266 Standalone WiFI Relay Control
ESP8266 Standalone WiFI Relay Control

AIM To control a relay switch using esp8266 in standalone mode(without arduino,pic or any other Micro-controller) via Web-UI The ESP...

Close
Scroll to top