Wifi Remote Control Using ESP8266 (2024)

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.

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:

https://www.instructables.com/id/ESP8266-Wifi-Temperature-Logger/

Attachments

  • NunchuckServer.ino

    Download

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. 192.168.1.132:54321 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.

https://github.com/splatspace/esprelay/

Attachments

  • esprelay.py

    Download

  • README.md

    Download

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+RST
AT+CWJAP="SSID of your Wifi","password of your Wifi"

AT+CIPCLOSE

To start communicating with the nunchuk transmitter type:

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

AT+CIPSEND=n

ascii string with no quotes\r\n

AT+CIPCLOSE

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!

http://www.3drcforums.com/showthread.php?685-RC-Ra...

Wifi Remote Control Using ESP8266 (2024)
Top Articles
Latest Posts
Article information

Author: Rueben Jacobs

Last Updated:

Views: 6241

Rating: 4.7 / 5 (57 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Rueben Jacobs

Birthday: 1999-03-14

Address: 951 Caterina Walk, Schambergerside, CA 67667-0896

Phone: +6881806848632

Job: Internal Education Planner

Hobby: Candle making, Cabaret, Poi, Gambling, Rock climbing, Wood carving, Computer programming

Introduction: My name is Rueben Jacobs, I am a cooperative, beautiful, kind, comfortable, glamorous, open, magnificent person who loves writing and wants to share my knowledge and understanding with you.