Author: Interaction Research Studio
This guide is inspired by Light Touch, a device that allows you to exchange coloured lights with another person over the internet. It's part of Yo-Yo Machines, a collection of devices that we developed for people to make at home and use them to communicate with each other to keep in touch with friends and family. Learn more about Light Touch and Yo-Yo Machines here.
In this guide, we'll make a simpler version of Light Touch. We will be able to control an LED across the room (or maybe in the room next door if you're lucky) and send morse-like messages between two devices. Instead of using the internet, we'll use ESP-Now, a wireless communication protocol that is super easy to set up, since it doesn't require a Wi-Fi router or any networking.
Here's what you need to follow this guide:
- 2 x ESP32 Dev boards
- 2 x 5mm LEDs (any colour will do)
- 2 x female to female jumper wires
- 1 x female to male jumper wire
- A small piece of aluminium foil
You should have a working installation of Arduino IDE on a Windows, Mac or Linux computer. You should also install the Silabs CP210x driver so that your computer can communicate with the ESP32 board via USB.
Use two female-to-female wires to connect the LED directly to the ESP32 board. The long leg of the LED (positive side) should connect to D4, and the short leg (negative side) should connect to GND.
Connect the female-to-male wire to pin D4 on the ESP32 board. Poke the pointy side of the wire into a ball of aluminium foil.
Repeat steps 1 and 2 for the second ESP32 board.
In order to use the ESP32 board on the Arduino IDE, you have to install it with the Boards Manager. Here's how to set up the arduino IDE:
- Open a new sketch
- Copy the code from this repository and paste it in your sketch
- Open your Arduino IDE settings / preferences window
- Under Additional Boards Manager URLs, add this link, and click ok
https://espressif.github.io/arduino-esp32/package_esp32_index.json
- Open the Boards Manager from Tools > Board > Boards Manager
- Search for
esp32
- Install esp32 by Espressif Systems
Now your Arduino IDE is ready to talk to your ESP32 boards!
When you're ready to upload the code, click on the Board Selector field on the top left of your IDE and select ESP32 Dev Module as your board. Select the serial port that your board is connected to. On mac, this is normally /dev/cu.SLAB_USBtoUART
, and on Windows it's one of the COM ports listed.
Click the Upload button and wait for your board to be flashed with the firmware. Repeat this for the second ESP32 board! Easiest way is to unplug the board and plug in the second one, so you don't have to select the serial port again.
Go ahead and power up both boards by plugging them into a USB port. It doesn't have to be the same USB source!
Touch the capacitive button on one device, and you should see the LED light up on the other board. And vice versa!
This is a basic setup that can get you really far with wireless communications! Here are some things to try next:
- Experiment with how far the devices can be from one another. Does it work across the room? Does it work between walls?
- Add more devices in the network by uploading the same code to them. Now multiple people can flash LEDs!
- Change the LED with a different output, for example a servo motor or a larger LED strip.
If you enjoyed this kind of wireless communication, you could have a go at building a Yo-Yo machine yourself!