Introduction: ESP32Thing-Wifi-Remote

About: Hi, I'm a hobbyist in the Chicago area, I like to do some woodworking, and automation with Arduino / Raspberry Pi.

In this tutorial I'm going to show you how I made a wifi remote that controls switches using the ESP32 Thing sold by Sparkfun.

The switch simply turns on or off a device that is connected to it. This tutorial describes the remote only. The tutorial for the switch can be found here: https://www.instructables.com/id/ESP8266-Wifi-Swit...

The idea is the following: I want to be able to control groups of several switches using a remote. For example I want to turn all lamps of the bedroom by the push of a button, or to turn all lamps of the livingroom by the push of another button, etc...

In summary, the remote contains buttons connected to the input pins of the ESP32 Thing board. The board is connected to the wifi and sends buttons state to a group of switches via Blynk. The remote is powered by a Lithium ion battery.

The end result is shown above: in the video I show how 1 button of the remote simultaneously turns on 2 lights, each controlled by a diferent switch. Currently I have 4 groups assigned, with 2 to 3 switches in each group. The remote is held on a wall plug and is charged by a usb outlet, but the remote can be unplugged and carried (the battery lasts about 12 hours when the remote is unplugged).

Step 1: Scheme and Components

The buttons I used are SPDT: when the button is on, it connects the pin to 3.3V, and when the button is off, it connects the pin to ground. I guess it can work with SPST buttons and pull-down resistors as well. The buttons I chose are the following: digikey.com

The buttons are soldered on a perfboard, and the perfboard is plugged in on the ESP32 Thing board. The contacts between the perfboard and the ESP32 Thing are ground, 3.3V, and 1 pin per button. The perfboard I chose is the following: console5.com. I had to cut it in a rectangle of 13 x 23 holes.

The ESP32 Thing is a board containing the ESP32 microcontroller. It's wifi and bluetooth compatible, has 28 GPIO, and integrates a LiPo Battery Charger: sparkfun.com

The perfboard and ESP32 Thing are connected by headers: male-male headers are soldered at the bottom of the perfboard, and male-female headers are connected on top of the ESP32 Thing. The headers I chose are the following: sparkfun.com and sparkfun.com

The remote is powered by a battery so that it still works when it is disconnected from the USB outlet. The battery I chose has a capacity of 2000mAh and can be found here: sparkfun.com

The whole is enclosed in a case that shapeways.com 3D printed in polyamide. It's essentially just a rectangle with a hole to plug a mini-USB cable, and legs to hold it on the wall plug. The sketchup model can be found on the github repository: github.com

I also added 2 SPST buttons: one that connects the reset pin to ground and another one that connects pin 0 to ground. They make resetting and programmation easier. These buttons can be found here: sparkfun.com

Step 2: Assembling

Perfboard:

The buttons are soldered in 2 rows on top of the perfboard. The male-male headers are then soldered at the bottom of the perfboard, and the middle pin of the SPDT button is connected to the header as shown in the photo.

For each row: 2 headers are also soldered for ground and 3.3V. A resistor is connected between the ground header and the left pin of each button, and another resistor is connected between the 3.3V header and the right pin of each button.

One last header is added to connect the SPST push button to ground. The male-male header is soldered to 2 90° male-female headers, so that the buttons can easily be connected and disconnected to the perfboard.

ESP32 Thing:

Male-female headers are soldered on top of the ESP32 Thing. 2 headers are soldered to ground and 3.3V that are placed next to GPIO16. 2 headers are soldered to ground and 3.3V that are placed next to the reset pin. 1 header is soldered to ground that is placed next to GPIO 21. Then 1 header is soldered for each button. In my case I used GPIO 2, 22, 23, 27, 32 and 34.

2 90° male-female headers are soldered at the bottom of the board: 1 on pin 0 and 1 on the reset pin.

Case:

2 holes are drilled on the sides for the SPST push buttons, and 6 holes are drilled on the top where the SPDT buttons go. Flat cable clips are glued on the wall plate to hold the remote by the legs.

Step 3: Program

The ESP32 is programmed just like an arduino. To flash the code, pin 0 has to be connected to ground on startup. So either press "button 0" on the ESP32 Thing, or press the SPST push button linked to GPIO 0. To execute the code, simply reset by pressing the "rst button" or the SPST push button linked to rst GPIO.

The program allows the remote to be connected to any of several wifi. The remote is linked to the switches using the bridge widget from the Blynk app. The remote is always connected to the wifi, and checks every 0.2s if the state of the buttons has changed. If the state of a button has changed, it sends the new state to the virtual pin V0 of a group of switches via bridges.

The arduino IDE code can be found on the github repository: github.com

Thanks for reading this instructable. If you want to build this project or part of this project, do it at your own risk. I do not guarantee its functionality or its safety. The project is licensed under MIT License. This means you can use it for commercial purposes, distribute it or modify it, only include a copy of the license and copyright notice with it.
If you have any suggestion, or feedback, please let me know! Looking forward to have your input.

Internet of Things Contest 2017

Participated in the
Internet of Things Contest 2017