Wifi Remote Control Using ESP8266

Introduction: Wifi Remote Control Using ESP8266

We show you how to use an ESP8266 to make a wired nunchuk into a Wifi nunchuk that can then control any device with WiFi access.

The ESP8266 is a very nice microcontroller with WiFi built in. It can be purchased at low cost in small quantities on small breakout boards and has a large community of enthusiasts supporting it. Because it is low cost and small we thought it might be good for a WiFi remote. That is a small portable device that lets you control something else over Wifi. To make this as accessible as possible we decided to avoid reprogramming the ESP8266 (although that is increasingly easy), use Arduino as the interface to the controller and use a wired nunchuck as our control signal generator. These are all low cost and easy to use approaches. In this demonstration our final output is to a serial terminal, however using another Arduino to read the serial nunchuck strings and act on them is very straightforward and documented in many places.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: The Arduino Controller

To glue the nunchuk to Wifi we used an Arduino. The code is for an Arduino Mega so that we could have two serial ports (Rx and Tx pins), one to program the Arduino and one for the Wifi (ESP8266). This is a very straight forward approach.

In a final product you could connect the ESP8266 to Tx and Rx on any Arduino like an UNO or low cost Pro Mini (make sure to get the pins right in the new code). However, this is a little scary to do as you may make the Arduino unreachable from USB port for reprogramming, as the program will take over the programming port when it runs. There are software serial libraries that will use other digital pins as Tx and Rx but they can have trouble going at the speed of the ESP8266. Some folks reprogram the ESP8266 to go at slower speeds but that is a challenge for beginners. The use of the MEGA or any Arduino with multiple Hardware Tx Rx ports makes this easy to do.

A good example of this more complex approach is:


Step 2: Connecting the ESP8266 Wifi Module

There are many sites showing you how to connect the ESP8266. We chose to connect it as shown here. The color code is as follows:

RED = Power 3.3 V

Black = GND 0V

Brown = 3.3V (Enables the chip)

White = Goes to RX1 on MEGA (it is the ESP8266 TX)

Grey = Goes to TX1 on MEGA (it is the ESP8266 RX)

Step 3: Connecting the Nunchuck

You can buy plugs that give access to the nunchuck's pins on a breadboard, but if you don't have one of those plugs on hand, you can easily make the connections with jumper wires by sticking them into the slots for each pin next to the main plug hole. The nunchuck uses i2c communication, and most Arduinos have an i2c bus built in. Simply connect the power as shown. Nunchucks will work with either 3.3v or 5v so it doesn't matter which voltage you use. Connect the SDA to analog pin 4 and the SCK to analog pin 5, or, if you are using an Arduino Mega, connect the SDA and SCK to the corresponding ports on the Mega.

Note that only Nintendo brand nunchucks will work. Don't buy an off-brand nunchuck!

Step 4: Setting Up the Server

Our friend Shaw Terwilliger at Durham's Splatspace Maker Space wrote this very nice Python program that turns a PC into a relay for the ESP8266s, or any internet devices, to talk to each other fairly secuerly. What the program does is let two or more ascii serial communicating devices log into the PC running the code. If they use the same port i.e. and begin with sending the same string "for example, any ascii string". After that anything one sends to the PC will be relayed to the others.

Shaw has placed the code on a Github site and has updated it since the version here. The code posted in this instructable is the version we used. You will have to install Python 2.7 on your computer to run this program. It runs in a terminal window and reports all the activity as links are setup and removed.

We tested it using a telnet program like Putty on Windows. The program allows two telnet sessions to talk to each other, just like the ESP8266s do.


Step 5: Setup Receiving ESP8266

The diagram and photo here show how we connected our receiving ESP8266. This setup is used to diagnose if the ESP is receiving correctly. We used an FTD chip module to connect the serial data to a USB port so we could examine it using a terminal program on a computer.

Because our FTDI module does not have a very powerful power supply it cannot run the ESP8266 all the time. This causes some confusion as the ESP8266 seems to work but keeps resetting. Adding a power supply like the LiPo boost circuit shown, solves this problem and makes the receiver battery operated!

If you wish to use the controller to control something you may replace the FTDI chip module with an microcontroller like an Arduino and have that interpret the nunchuk data to control anything. If you are very savvy you could reprogram the ESP8266 to perform the desired tasks. It has GPIO ports and can be programmed via the Arduino IDE.

Step 6: Receiving Data Through Terminal

On a Windows PC we used the YAT terminal program to see that the serial strings from the nunchuk are arriving.

To set up an ESP8266 type the following commands:

AT+CWJAP="SSID of your Wifi","password of your Wifi"


To start communicating with the nunchuk transmitter type:

AT+CIPSTART="TCP","IP address of your esprelay server e.g.",54321


ascii string with no quotes\r\n


There are a number of online sources for the AT commands for the ESP8266 if you need help. The quotes " are required. AT+CIPSEND=n tells the ESP that n ascii characters are coming next. For example if you use "hi" then n=2, if you use "hi there" then n = 8.

In figure showing the YAT screen we have added timestamps to each serial line and you can see we are getting one serial string approximately every 100ms or about 10 per second. This is over our home router and so the packet latency due to distance is very low.

Step 7: Controlling Things

This is fast enough to be used for aircraft radio control but only just, 50 ms is more typical and 10 ms would be ideal. Maybe someone can improve on our results!


Be the First to Share


    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Finish It Already Speed Challenge

      Finish It Already Speed Challenge

    8 Discussions


    2 years ago

    I want to use the esp8266 on the joystick. How do I communicate with the joystick and use it?



    3 years ago

    want to styudy


    4 years ago

    Did you have any problems with ESP being 3.3v and Arduino being 5v on a serial port?


    Reply 4 years ago

    The only problem was that we needed a 3.3V FTDI for the remote ESP8266 and the common FTDI would not support enough power for the ESP to run all the time. I see that there is a new SparkFun Beefy 3 - FTDI Basic Breakout (DEV-13746) that should solve this. Otherwise you need a battery or other power for the remote ESP

    The Arduino MEGA 3.3V regulated output ran the local ESP just fine.


    Reply 4 years ago

    The ESP8266 did not need a level shifter for 5V inputs from the serial port on the MEGA


    Reply 4 years ago

    Thank you! All this ESP stuff is a bit confusing and information on the web differs a lot for the same chip. Somebody advises using level shifters, somebody just puts voltage divider on an RX pin of ESP, somebody uses straight connection. As for the FTDI - that's right, burned one chip already.