# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## Overview

https://youtu.be/g-wGXKgTnCg

![](https://cdn-learn.adafruit.com/assets/assets/000/110/580/medium800/wireless_edited_P1320741.png?1649187828)

This guide will show you how to use a QT Py ESP32-S2 running CircuitPython to control a Pure Data patch over WiFi. [Pure Data](http://puredata.info/) is an open source programming language that can be used to create musical applications. It's a visual programming language that lets you drag and drop code blocks into the software interface to create the patches.

The QT Py ESP32-S2 is soldered to a charger BFF. This allows the project to run on a LiPo battery.

![wireless_edited_P1320756.png](https://cdn-learn.adafruit.com/assets/assets/000/110/565/medium640/wireless_edited_P1320756.png?1649186114)

An ADXL343 accelerometer controls the synthesizer patch's filters. A TSC2007 and resistive touch screen are used to send notes to the synth patch.

![wireless_edited_P1320729.png](https://cdn-learn.adafruit.com/assets/assets/000/110/566/medium640/wireless_edited_P1320729.png?1649186160)

The build is housed in a 3D printed case that can be held in your hand.

![wireless_edited_P1320747.png](https://cdn-learn.adafruit.com/assets/assets/000/110/567/medium640/wireless_edited_P1320747.png?1649186217)

## Parts
### Adafruit QT Py ESP32-S2 WiFi Dev Board with STEMMA QT

[Adafruit QT Py ESP32-S2 WiFi Dev Board with STEMMA QT](https://www.adafruit.com/product/5325)
What has your favorite Espressif WiFi microcontroller, comes with&nbsp;[our favorite connector - the STEMMA QT](http://adafruit.com/stemma), a chainable I2C port, and has lots of Flash and RAM memory for your next IoT project? What will make your next IoT project flyyyyy? What a...

In Stock
[Buy Now](https://www.adafruit.com/product/5325)
[Related Guides to the Product](https://learn.adafruit.com/products/5325/guides)
![Angled shot of small square purple dev board.](https://cdn-shop.adafruit.com/640x480/5325-12.jpg)

### Adafruit LiIon or LiPoly Charger BFF Add-On for QT Py

[Adafruit LiIon or LiPoly Charger BFF Add-On for QT Py](https://www.adafruit.com/product/5397)
[Is your QT Py all alone](https://www.adafruit.com/?q=qt+py&sort=BestMatch), lacking a friend to travel the wide world with? When you were a kid you may have learned about the "buddy" system, well this product is kinda like that! A board that will watch your QT...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5397)
[Related Guides to the Product](https://learn.adafruit.com/products/5397/guides)
![Video of a person with white painted nails unplugging a USB cable from a small, black, square-shaped lipo battery breakout board soldered to a similarly shaped microcontroller, which is also connected to a monochrome OLED display breakout. The OLED breakout displays battery and power data.](https://cdn-shop.adafruit.com/product-videos/640x480/5397-05.jpg)

### Adafruit TSC2007 I2C Resistive Touch Screen Controller

[Adafruit TSC2007 I2C Resistive Touch Screen Controller](https://www.adafruit.com/product/5423)
Getting touchy performance with your screen's touch screen? Resistive touch screens are incredibly popular as overlays to TFT and LCD displays. Only problem is they require a bunch of analog pins and you have to keep polling them since the overlays themselves are basically just big...

In Stock
[Buy Now](https://www.adafruit.com/product/5423)
[Related Guides to the Product](https://learn.adafruit.com/products/5423/guides)
![Video of a mushroom-manicured finger pressing a clear touchscreen display. The x-axis and y-axis dimensions are displayed on the connected monochrome OLED display breakout board.](https://cdn-shop.adafruit.com/product-videos/640x480/5423-05.jpg)

### Resistive Touch screen - 3.7" Diagonal

[Resistive Touch screen - 3.7" Diagonal](https://www.adafruit.com/product/333)
Want to poke at your projects? This resistive touch screen can be used with a stylus or fingertip and is easy to use with a microcontroller. You can put it over a paper overlay for a touch control panel or attach it to an LCD to DIY a touch-activated display.

- 2.45" x 3"...

In Stock
[Buy Now](https://www.adafruit.com/product/333)
[Related Guides to the Product](https://learn.adafruit.com/products/333/guides)
![Angled Shot of the Resistive Touch screen - 3.7" Diagonal.](https://cdn-shop.adafruit.com/640x480/333-06.jpg)

### ADXL343 - Triple-Axis Accelerometer (+-2g/4g/8g/16g) w/ I2C/SPI

[ADXL343 - Triple-Axis Accelerometer (+-2g/4g/8g/16g) w/ I2C/SPI](https://www.adafruit.com/product/4097)
Analog Devices has followed up on their popular classic, the ADXL345, with this near-drop-in-replacement, the ADXL343. Like the original, this is a triple-axis accelerometer with digital I2C and SPI interface breakout. It has a wide sensitivity range and high resolution, operating with an 10...

In Stock
[Buy Now](https://www.adafruit.com/product/4097)
[Related Guides to the Product](https://learn.adafruit.com/products/4097/guides)
![Angled shot of red sensor breakout.](https://cdn-shop.adafruit.com/640x480/4097-08.jpg)

### Part: USB Cable
quantity: 1
USB A to C cable, 1 meter, purple
[USB Cable](https://www.adafruit.com/product/5153)

### Part: STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long
quantity: 2
STEMMA QT cable
[STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long](https://www.adafruit.com/product/4399)

### Part: Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh
quantity: 1
3.7V 400mAh LiPo
[Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh](https://www.adafruit.com/product/3898)

### Part: High Temperature Polyimide Tape - 1cm wide x 33 meter roll
quantity: 1
High Temperature Polyimide Tape
[High Temperature Polyimide Tape - 1cm wide x 33 meter roll](https://www.adafruit.com/product/3057)

### Part: Black Nylon Machine Screw and Stand-off Set – M2.5 Thread
quantity: 1
M2.5 screws and stand-offs
[Black Nylon Machine Screw and Stand-off Set – M2.5 Thread](https://www.adafruit.com/product/3299)

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## Circuit Diagram

![](https://cdn-learn.adafruit.com/assets/assets/000/110/519/medium800/wireless_esp32PureDataFritzing.png?1649169255)

This project consists of STEMMA boards that are connected to each other using STEMMA QT cables.&nbsp;

- **TSC2007**
  - **SCL (yellow wire)** to **ADXL343 SCL**
  - **SDA (blue wire)** to **ADXL343**** &nbsp;SDA**
  - **VIN (red wire)** to **ADXL343**** &nbsp;VIN**
  - **GND (black wire)** to **ADXL343**** &nbsp;GND**

- **ADXL343**
  - **SCL (yellow wire)** to **QT Py SCL1**
  - **SDA (blue wire)** to **QT Py**  **SDA1**
  - **VIN (red wire)** to **QT Py**  **3.3V**
  - **GND (black wire)** to **QT Py**  **GND**

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## 3D Printing

![](https://cdn-learn.adafruit.com/assets/assets/000/110/542/medium800/wireless_edited_P1320698.png?1649182375)

The controller may be housed in a 3D printed case, described below. The case consists of four parts: a top lid, main body, bottom lid and handle. All parts print with no supports.

The STL files can be downloaded directly here or from Thingiverse.

[ESP32_Controller_Case.zip](https://cdn-learn.adafruit.com/assets/assets/000/110/520/original/ESP32_Controller_Case.zip?1649169633)
[Thingiverse download](https://www.thingiverse.com/thing:5342288)
The main portion of the case snap fits together. The handle attaches to the main body with two M2.5 screws.

![wireless_edited_P1320712.png](https://cdn-learn.adafruit.com/assets/assets/000/110/543/medium640/wireless_edited_P1320712.png?1649182426)

The bottom lid has mounting holes for the STEMMA boards and a slot for the QT Py ESP32-S2. The top lid has a slot for the touch screen's ribbon cable.

![wireless_edited_P1320709.png](https://cdn-learn.adafruit.com/assets/assets/000/110/544/medium640/wireless_edited_P1320709.png?1649182495)

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## Install Pure Data

Pure Data can run on computers running Windows, Mac OS or Linux.

Open a browser and navigate to the [Pure Data downloads](http://puredata.info/downloads/pure-data) page. Select the installer for your computer and download it.

![wireless_pureDataDownload.png](https://cdn-learn.adafruit.com/assets/assets/000/110/473/medium640/wireless_pureDataDownload.png?1649081614)

After installing, launch Pure Data. A blank Pure Data window will open. This window acts as a console log when you are running a patch. You can print messages to it and get real time feedback.

![wireless_pureDataConsole.png](https://cdn-learn.adafruit.com/assets/assets/000/110/474/medium640/wireless_pureDataConsole.png?1649081761)

Pure Data is open source and has a lot of community support for documentation. There is a [getting started](http://puredata.info/docs/StartHere/) guide available on the Pure Data website that will be helpful if you are new to Pure Data

![](https://cdn-learn.adafruit.com/assets/assets/000/110/475/medium800/wireless_gettingStarted.png?1649081868)

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## CircuitPython

[CircuitPython](https://github.com/adafruit/circuitpython) is a derivative of [MicroPython](https://micropython.org) designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the **CIRCUITPY** drive to iterate.

## CircuitPython Quickstart

Follow this step-by-step to quickly get CircuitPython running on your board.

[Download the latest version of CircuitPython for this board via circuitpython.org](https://circuitpython.org/board/adafruit_qtpy_esp32s2/)
 **Click the link above to download the latest CircuitPython UF2 file.**

Save it wherever is convenient for you.

![install_circuitpython_on_most_boards_CircuitPython_downloaded.jpg](https://cdn-learn.adafruit.com/assets/assets/000/102/129/medium640/install_circuitpython_on_most_boards_CircuitPython_downloaded.jpg?1620922559)

![](https://cdn-learn.adafruit.com/assets/assets/000/107/612/medium800/adafruit_products_QTESP_reset_NeoPixel.jpg?1641246436)

Info: The board above has a chip antenna, not the u.Fl connector, but the process is the same.

Plug your board into your computer, using a known-good data-sync cable, directly, or via an adapter if needed.

Click the **reset** button once (highlighted in red above), and then click it again when you see the **RGB status LED(s)** (highlighted in green above) turn purple (approximately half a second later). Sometimes it helps to think of it as a "slow double-click" of the reset button.

If you do not see the LED turning purple, you will need to reinstall the UF2 bootloader. See the&nbsp; **Factory Reset** &nbsp;page in this guide for details.

On some very old versions of the UF2 bootloader, the status LED turns red instead of purple.

For this board, tap reset and wait for the LED to turn purple, and as soon as it turns purple, tap reset again. The second tap needs to happen while the LED is still purple.

Once successful, you will see the **RGB status LED(s)** turn green (highlighted in green above), and a disk drive ending in " **...BOOT**" should appear on your host computer. If you see red, try another port, or if you're using an adapter or hub, try without the hub, or different adapter or hub.

If double-clicking doesn't work the first time, try again. Sometimes it can take a few tries to get the rhythm right!

A lot of people end up using charge-only USB cables and it is very frustrating! **Make sure you have a USB cable you know is good for data sync.**

Info: 

You will see a new disk drive appear called **QTPYS2BOOT**.

&nbsp;

&nbsp;

Drag the **adafruit\_circuitpython\_etc.uf2** file to **QTPYS2BOOT**.

![adafruit_products_uf2install.png](https://cdn-learn.adafruit.com/assets/assets/000/107/577/medium640/adafruit_products_uf2install.png?1640641747)

Copy or drag the UF2 file you downloaded to the **BOOT** drive.

The **BOOT** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

That's it!

![install_circuitpython_on_most_boards_CIRCUITPY.jpg](https://cdn-learn.adafruit.com/assets/assets/000/102/130/medium640/install_circuitpython_on_most_boards_CIRCUITPY.jpg?1620923145)

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## Coding the ESP32-S2 Controller

Once you've finished setting up your QT Py ESP32-S2 with CircuitPython, you can access the code and necessary libraries by downloading the Project Bundle.

To do this, click on the **&nbsp;Download Project Bundle** &nbsp;button in the window below. It will download as a zipped folder.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Wireless_ESP32-S2_Controller_For_Pure_Data/code.py

## Upload the Code and Libraries to the QT Py ESP32-S2

After downloading the Project Bundle, plug your QT Py ESP32-S2 into the computer's USB port with a known good USB data+power cable. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called&nbsp; **CIRCUITPY**. Unzip the folder and copy the following items to the QT Py ESP32-S2's&nbsp; **CIRCUITPY** &nbsp;drive.&nbsp;

- **lib** &nbsp;folder
- **code.py**

Your QT Py ESP32-S2&nbsp; **CIRCUITPY&nbsp;** drive should look like this after copying the&nbsp; **lib** &nbsp;folder and the&nbsp; **code.py&nbsp;** file.

![CP](https://adafruit.github.io/Adafruit_Learning_System_Guides/Wireless_ESP32-S2_Controller_For_Pure_Data.png )

## **settings.toml**

You will need to create and add a **settings.toml** file to your **CIRCUITPY** drive. Your **settings.toml** file will need to include the following information:

```python
CIRCUITPY_WIFI_SSID="your-wifi-ssid"
CIRCUITPY_WIFI_PASSWORD="your-wifi-password"
timezone="America/New_York"  # http://worldtimeapi.org/timezones
host="YOUR COMPUTER IP ADDRESS"
```

`'host'` will hold the IP address of the computer running Pure Data that you are connecting to. The QT Py ESP32-S2 will be connecting to that computer with a socket connection.

To find your IP address on a Windows machine, [refer to this documentation from Microsoft](https://support.microsoft.com/en-gb/windows/find-your-ip-address-in-windows-f21a9bbc-c582-55cd-35e0-73431160a1b9#Category=Windows_10).

To find your IP address on a Mac, [refer to this documentation from Apple](https://support.apple.com/guide/mac-help/find-your-computers-name-and-network-address-mchlp1177/mac).

To find your IP address on Linux, enter `ip addr` in a terminal.

## Open the Pure Data File

Locate the Pure Data script file in the Project Bundle folder:

- **pureDataWithESP32.pd**

Launch the Pure Data application that you [installed on your computer](https://learn.adafruit.com/wireless-esp32-s2-controller-for-pure-data/install-pure-data) and open the file.

![](https://cdn-learn.adafruit.com/assets/assets/000/110/521/medium800/wireless_pureDataScript.png?1649170126)

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## How the CircuitPython Code Works

First, the `STEMMA_I2C` port is setup for the I2C devices. Then the TSC2007 and ADXL343 are setup.

```python
#  I2C setup for STEMMA port
i2c = board.STEMMA_I2C()

#  touchscreen setup for TSC2007
irq_dio = None
tsc = adafruit_tsc2007.TSC2007(i2c, irq=irq_dio)

#  accelerometer setup
accelerometer = adafruit_adxl34x.ADXL343(i2c)
accelerometer.enable_tap_detection()
```

A number of variables and states are declared. Their function is commented in the code.

Most importantly, the `notes` array holds the MIDI note numbers that are sent to the Pure Data script and played through the synth. If you want to play different notes, you'll want to edit that array.

```python
#  MIDI notes - 2 octaves of Cmaj7 triad
notes = [48, 52, 55, 59, 60, 64, 67, 71]
#  reads touch input
point = tsc.touch
#  accelerometer x coordinate
acc_x = 0
#  accelerometer y coordinate
acc_y = 0
#  last accelerometer x coordinate
last_accX = 0
#  last accelerometer y coordinate
last_accY = 0
#  mapped value for touchscreen x coordinate
x_map = 0
#  mapped value for touchscreen y coordinate
y_map = 0
#  last mapped value for touchscreen x coordinate
last_x = 0
#  last mapped value for touchscreen y coordinate
last_y = 0
#  state for whether synth is running
run = 0
#  tap detection state
last_tap = False
#  new value detection state
new_val = False
```

## Socket Connection

After the QT Py ESP32-S2 connects to your WiFi network, it connects to your computer with a socket connection. The socket needs to know your computer's IP address, which is stored in `host` in the **settings.toml** file. The port is defined as `12345`.

Once a socket connection is established with the Pure Data script, the loop begins to run.

```python
HOST = getenv("host")
PORT = 12345
TIMEOUT = 5
INTERVAL = 5
MAXBUF = 256

#  connect to WIFI
print(f"Connecting to {ssid}")
wifi.radio.connect(ssid, password)
print(f"Connected to {ssid}!")

pool = socketpool.SocketPool(wifi.radio)

ipv4 = ipaddress.ip_address(pool.getaddrinfo(HOST, PORT)[0][4][0])

buf = bytearray(MAXBUF)

print("Create TCP Client Socket")
s = pool.socket(pool.AF_INET, pool.SOCK_STREAM)

print("Connecting")
s.connect((HOST, PORT))
```

## The Loop

The loop begins by checking for tap detection from the accelerometer. If the ADXL343 detects a tap, it will either start or stop the Pure Data synth from playing.

```python
#  tap detection
    #  if tap is detected and the synth is not running...
    if accelerometer.events["tap"] and not last_tap and not run:
        #  run is updated to 1
        run = 1
        #  last_tap is reset
        last_tap = True
        print("running")
        #  message is sent to Pd to start the synth
        #  all Pd messages need to end with a ";"
        size = s.send(str.encode(' '.join(["run", str(run), ";"])))
    #  if tap is detected and the synth is running...
    if accelerometer.events["tap"] and not last_tap and run:
        #  run is updated to 0
        run = 0
        #  last_tap is reset
        last_tap = True
        print("not running")
        #  message is sent to Pd to stop the synth
        #  all Pd messages need to end with a ";"
        size = s.send(str.encode(' '.join(["run", str(run), ";"])))
    #  tap detection debounce
    if not accelerometer.events["tap"] and last_tap:
        last_tap = False
```

## Reading the Touch Screen

If a touch input is detected with the TSC2007, the `x` and `y` coordinates are mapped from their 12-bit value to a range of `0` to `8`. This mapping matches with the sequencer array in the Pure Data script.

```python
#  if the touchscreen is touched...
    if tsc.touched:
        #  point holds touch data
        point = tsc.touch
        #  x coordinate is remapped to 0 - 8
        x_map = simpleio.map_range(point["x"], 0, 4095, 0, 8)
        #  y coordinate is remapped to 0 - 8
        y_map = simpleio.map_range(point["y"], 0, 4095, 0, 8)
```

## Reading the ADXL343

The `x` and `y` values from the ADXL343 are mapped to match values for the synth's filters in the Pure Data script.&nbsp;

```python
#  accelerometer x value is remapped for synth filter
    acc_x = simpleio.map_range(accelerometer.acceleration[0], -10, 10, 450, 1200)
    #  accelerometer y value is remapped for synth filter
    acc_y = simpleio.map_range(accelerometer.acceleration[1], -10, 10, 250, 750)
```

## Comparing Values

The current and previous values from the TSC2007 and ADXL343 are compared using `if` statements. If the values do not match, then the previous value is updated and the state of `new_val` is set to `True`. This indicates that a new value has been received and should be sent to the Pure Data script.

```python
#  if any of the values are different from the last value...
    if x_map != last_x:
        #  last value is updated
        last_x = x_map
        #  new value is detected
        new_val = True
    if y_map != last_y:
        last_y = y_map
        new_val = True
    if int(acc_x) != last_accX:
        last_accX = int(acc_x)
        new_val = True
    if int(acc_y) != last_accY:
        last_accY = int(acc_y)
        new_val = True
```

## Sending Data Over the Socket

If a new value is received from one of the sensors, then a message is sent over the socket with the new readings. Each piece of data is preceded by a variable name that Pure Data will be listening for.&nbsp;

A new note is sent to the sequencer in the Pure Data patch with the `note` variable. The `y_map` coordinate on the touch screen is used as an index marker in the `notes` array.

It's important to note that Pure Data uses a networking protocol called [FUDI](https://en.wikipedia.org/wiki/FUDI). As a result, each message needs to end with a semicolon (`;`). This allows the message to be terminated and sent to the Pure Data script.

```python
#  if a new value is detected...
    if new_val:
        #  note index is updated to y coordinate on touch screen
        note = notes[int(y_map)]
        #  message with updated values is sent via socket to Pd
        #  all Pd messages need to end with a ";"
        size = s.send(str.encode(' '.join(["x", str(x_map), ";",
                                           "y", str(y_map), ";",
                                           "aX", str(acc_x), ";",
                                           "aY", str(acc_y), ";",
                                           "n", str(note), ";"])))
        #  new_val is reset
        new_val = False
```

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## How the Pure Data Script Works

Pure Data uses programming blocks and lines to build a functional script.

## Reading Data from the QT Py ESP32-S2
At the top of the script, Pure Data begins listening to port `12345` and receiving data over the port using `netrecieve`.

The incoming data is sent from the QT Py ESP32-S2 with the socket message. This message is parsed using `route`. The message is divided by the variable names sent before each sensor value.

- TSC2007 x coordinate: `x`
- TSC2007 y coordinate: `y`
- ADXL343 x value: `aX`
- ADXL343 y value: `aY`
- Run state: `run`
- MIDI note number: `n`&nbsp;

Values are sent around a Pure Data script using `s` or `send`. Underneath `route`, you can see each individual value being sent with `s`.

![wireless_netrec.png](https://cdn-learn.adafruit.com/assets/assets/000/110/523/medium640/wireless_netrec.png?1649172554)

## The Sequencer
The `seq` array holds the received MIDI notes and are played in a loop. You can adjust the array's parameters using the `bounds`, `const` and `resize` messages.

Values are received as inputs using `receive` or `r`. `n` and `x` are received by the array using `r`. Those values are written to the array using `tabwrite`.

![wireless_seq.png](https://cdn-learn.adafruit.com/assets/assets/000/110/524/medium640/wireless_seq.png?1649173115)

## Start the Synth
`run` affects whether the synth patch is playing or not. When a new `run` message is received from the socket, the patch will either begin playing or stop. Additionally, when it stops, a `0` is sent to all of the parameters so that the synth is muted using `s off`.

![wireless_run.png](https://cdn-learn.adafruit.com/assets/assets/000/110/525/medium640/wireless_run.png?1649173370)

## Loop Through the Sequencer
The `+ 1` and `% 8` blocks act as a for loop, advancing by `1` with a limit of `8`. This lets the script iterate through the notes in the `seq` array like a sequencer.&nbsp;

`tabread` reads the MIDI notes in the `seq` array. Those note numbers are converted to frequencies using the MIDI to Frequency block (`mtof`). The frequency is sent to the synth.

![wireless_notes.png](https://cdn-learn.adafruit.com/assets/assets/000/110/526/medium640/wireless_notes.png?1649173525)

## The Sawtooth Synth
The synth is built using a sawtooth waveform, created with the `phasor~` block. It has a series of filters that are affected by the accelerometer.

![wireless_synth.png](https://cdn-learn.adafruit.com/assets/assets/000/110/527/medium640/wireless_synth.png?1649173726)

## VCF Filter and Audio Output
The final stop is a VCF filter, created with the `vcf~` block. The VCF's value is affected by the note playing in the `seq` array.

The `output~` block controls the audio output from the patch. You can change the volume by adjusting the `dB` block and mute all audio by clicking next to `mute`.

![wireless_vcfOutput.png](https://cdn-learn.adafruit.com/assets/assets/000/110/528/medium640/wireless_vcfOutput.png?1649173830)

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/110/545/medium800/wireless_edited_P1320716.png?1649182593)

## Solder the ESP32-S2 and Lipoly Charger BFF
![](https://cdn-learn.adafruit.com/assets/assets/000/110/536/medium800/wireless_edited_IMG_4654.png?1649178670)

Solder the short end of the headers to the LiPo BFF.

![wireless_edited_IMG_4658.png](https://cdn-learn.adafruit.com/assets/assets/000/110/537/medium640/wireless_edited_IMG_4658.png?1649178699)

Place the QT Py ESP32-S2 onto the headers on the LiPo BFF. Make sure that the pins are matched. The QT Py's USB port should be on the other side of the LiPo BFF's LiPo port.&nbsp;

Solder the QT Py to the headers.

![wireless_edited_IMG_4661.png](https://cdn-learn.adafruit.com/assets/assets/000/110/538/medium640/wireless_edited_IMG_4661.png?1649178746)

Your QT Py ESP32-S2 is ready to be battery-powered!

![wireless_edited_IMG_4665.png](https://cdn-learn.adafruit.com/assets/assets/000/110/539/medium640/wireless_edited_IMG_4665.png?1649178848)

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## Connect and Mount the STEMMA Boards

![](https://cdn-learn.adafruit.com/assets/assets/000/110/546/medium800/wireless_edited_P1320694.png?1649182628)

The STEMMA boards are connected to each other and the QT Py ESP32-S2 with 50mm QT to QT cables.

Plug the TSC2007's right socket into the ADXL343's right socket.

![wireless_edited_P1320720.png](https://cdn-learn.adafruit.com/assets/assets/000/110/547/medium640/wireless_edited_P1320720.png?1649182668)

Plug the ADXL343's left socket into the QT Py ESP32-S2's STEMMA socket.

![wireless_edited_P1320721.png](https://cdn-learn.adafruit.com/assets/assets/000/110/548/medium640/wireless_edited_P1320721.png?1649182754)

## Mount the Boards
Insert M2.5 screws into the eight mounting holes in the bottom lid of the case.

![wireless_edited_P1320724.png](https://cdn-learn.adafruit.com/assets/assets/000/110/549/medium640/wireless_edited_P1320724.png?1649182851)

Attach M2.5 stand-offs to each of the eight M2.5 screws.

![wireless_edited_P1320725.png](https://cdn-learn.adafruit.com/assets/assets/000/110/550/medium640/wireless_edited_P1320725.png?1649182913)

Slide the QT Py ESP32-S2 into the slot on the bottom lid of the case. The QT Py's USB port should be facing out towards the open area of the lid.

![wireless_edited_P1320727.png](https://cdn-learn.adafruit.com/assets/assets/000/110/551/medium640/wireless_edited_P1320727.png?1649182981)

Attach the ADXL343 to the four stand-offs next to the QT Py's slot with four M2.5 screws.

![wireless_edited_P1320728.png](https://cdn-learn.adafruit.com/assets/assets/000/110/552/medium640/wireless_edited_P1320728.png?1649183059)

Attach the TSC2007 to the four remaining stand-offs with M2.5 screws.

![wireless_edited_P1320729.png](https://cdn-learn.adafruit.com/assets/assets/000/110/553/medium640/wireless_edited_P1320729.png?1649183116)

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## Mount the Touch Screen

![](https://cdn-learn.adafruit.com/assets/assets/000/110/554/medium800/wireless_edited_P1320737.png?1649183193)

The top lid of the 3D printed case is sized to attach the touch screen to it.

On the back of the touch screen, place a mounting sticker in each corner. If you do not have mounting stickers, you can use pieces of looped tape.

![wireless_edited_P1320738.png](https://cdn-learn.adafruit.com/assets/assets/000/110/555/medium640/wireless_edited_P1320738.png?1649183241)

Carefully run the touch screen's ribbon cable through the slot on the top lid. Then, attach the touch screen to the top lid with the mounting stickers.

![wireless_edited_P1320739.png](https://cdn-learn.adafruit.com/assets/assets/000/110/556/medium640/wireless_edited_P1320739.png?1649183294)

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## Assemble the Case

Attach the handle to the main body of the case with two M2.5 screws and two M2.5 nuts.

![wireless_edited_P1320702.png](https://cdn-learn.adafruit.com/assets/assets/000/110/557/medium640/wireless_edited_P1320702.png?1649183455)

![wireless_edited_P1320704.png](https://cdn-learn.adafruit.com/assets/assets/000/110/558/medium640/wireless_edited_P1320704.png?1649183501)

![wireless_edited_P1320705.png](https://cdn-learn.adafruit.com/assets/assets/000/110/559/medium640/wireless_edited_P1320705.png?1649183532)

![wireless_edited_P1320707.png](https://cdn-learn.adafruit.com/assets/assets/000/110/560/medium640/wireless_edited_P1320707.png?1649183576)

Attach the bottom lid of the case to the main body.

![wireless_edited_P1320731.png](https://cdn-learn.adafruit.com/assets/assets/000/110/561/medium640/wireless_edited_P1320731.png?1649183672)

Plug the touch screen's ribbon cable into the TSC2007's socket.

![wireless_edited_P1320733.png](https://cdn-learn.adafruit.com/assets/assets/000/110/562/medium640/wireless_edited_P1320733.png?1649183720)

Plug a LiPo battery into the LiPo BFF. Attach the battery with electrical tape or kapton tape so that it is secured in the case.

![wireless_edited_P1320735.png](https://cdn-learn.adafruit.com/assets/assets/000/110/563/medium640/wireless_edited_P1320735.png?1649183767)

Now you're ready to rock!

![](https://cdn-learn.adafruit.com/assets/assets/000/110/564/medium800/wireless_edited_P1320742.png?1649186009)

# Wireless ESP32-S2 Touch Screen Controller for Pure Data

## Usage

## Start the Synth
Turn on the QT Py ESP32-S2 controller with the on/off switch on the LiPo BFF.

![wireless_edited_P1320756.png](https://cdn-learn.adafruit.com/assets/assets/000/110/568/medium640/wireless_edited_P1320756.png?1649186262)

Open the Pure Data script. The QT Py ESP32-S2 will automatically connect and begin sending data from the sensors.

![wireless_pureDataScript.png](https://cdn-learn.adafruit.com/assets/assets/000/110/569/medium640/wireless_pureDataScript.png?1649186302)

## Sequence Notes
![](https://cdn-learn.adafruit.com/assets/assets/000/110/571/medium800thumb/wireless_seqDemo.jpg?1649186863)

Touch different spots on the touch screen to send different combinations of notes to the Pure Data patch. You'll see them logged in the `seq` array.

## Adjust Filters
![](https://cdn-learn.adafruit.com/assets/assets/000/110/573/medium800thumb/wireless_filterDemo.jpg?1649187178)

Twist and turn the controller to send accelerometer data to affect the filters on the synth patch.

## Start and Stop the Synth
![](https://cdn-learn.adafruit.com/assets/assets/000/110/578/medium800thumb/wireless_tapDemo.jpg?1649187437)

The ADXL343 has tap detection. Tap the side of the enclosure to start and stop the synth patch.


## Featured Products

### Adafruit QT Py ESP32-S2 WiFi Dev Board with STEMMA QT

[Adafruit QT Py ESP32-S2 WiFi Dev Board with STEMMA QT](https://www.adafruit.com/product/5325)
What has your favorite Espressif WiFi microcontroller, comes with&nbsp;[our favorite connector - the STEMMA QT](http://adafruit.com/stemma), a chainable I2C port, and has lots of Flash and RAM memory for your next IoT project? What will make your next IoT project flyyyyy? What a...

In Stock
[Buy Now](https://www.adafruit.com/product/5325)
[Related Guides to the Product](https://learn.adafruit.com/products/5325/guides)
### Adafruit TSC2007 I2C Resistive Touch Screen Controller

[Adafruit TSC2007 I2C Resistive Touch Screen Controller](https://www.adafruit.com/product/5423)
Getting touchy performance with your screen's touch screen? Resistive touch screens are incredibly popular as overlays to TFT and LCD displays. Only problem is they require a bunch of analog pins and you have to keep polling them since the overlays themselves are basically just big...

In Stock
[Buy Now](https://www.adafruit.com/product/5423)
[Related Guides to the Product](https://learn.adafruit.com/products/5423/guides)
### ADXL343 - Triple-Axis Accelerometer (+-2g/4g/8g/16g) w/ I2C/SPI

[ADXL343 - Triple-Axis Accelerometer (+-2g/4g/8g/16g) w/ I2C/SPI](https://www.adafruit.com/product/4097)
Analog Devices has followed up on their popular classic, the ADXL345, with this near-drop-in-replacement, the ADXL343. Like the original, this is a triple-axis accelerometer with digital I2C and SPI interface breakout. It has a wide sensitivity range and high resolution, operating with an 10...

In Stock
[Buy Now](https://www.adafruit.com/product/4097)
[Related Guides to the Product](https://learn.adafruit.com/products/4097/guides)
### Adafruit LiIon or LiPoly Charger BFF Add-On for QT Py

[Adafruit LiIon or LiPoly Charger BFF Add-On for QT Py](https://www.adafruit.com/product/5397)
[Is your QT Py all alone](https://www.adafruit.com/?q=qt+py&sort=BestMatch), lacking a friend to travel the wide world with? When you were a kid you may have learned about the "buddy" system, well this product is kinda like that! A board that will watch your QT...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5397)
[Related Guides to the Product](https://learn.adafruit.com/products/5397/guides)
### Resistive Touch screen - 3.7" Diagonal

[Resistive Touch screen - 3.7" Diagonal](https://www.adafruit.com/product/333)
Want to poke at your projects? This resistive touch screen can be used with a stylus or fingertip and is easy to use with a microcontroller. You can put it over a paper overlay for a touch control panel or attach it to an LCD to DIY a touch-activated display.

- 2.45" x 3"...

In Stock
[Buy Now](https://www.adafruit.com/product/333)
[Related Guides to the Product](https://learn.adafruit.com/products/333/guides)
### STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long

[STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long](https://www.adafruit.com/product/4399)
This 4-wire cable is&nbsp;50mm / 1.9" long and fitted with JST SH female 4-pin connectors on both ends. Compared with the chunkier JST PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4399)
[Related Guides to the Product](https://learn.adafruit.com/products/4399/guides)
### Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh

[Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh](https://www.adafruit.com/product/3898)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of **400mAh** for a total of about 1.9 Wh. If you need a larger (or smaller!)...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3898)
[Related Guides to the Product](https://learn.adafruit.com/products/3898/guides)
### High Temperature Polyimide Tape - 1cm wide x 33 meter roll

[High Temperature Polyimide Tape - 1cm wide x 33 meter roll](https://www.adafruit.com/product/3057)
 **Polyimide Tape** (sometimes referred to by the brand name **Kapton Tape** ) is an interesting addition to your toolbox! Polyimide Tape remains stable across a wide range of temperatures&nbsp;from about −269°C to +400°C.&nbsp;Along with aircraft,...

In Stock
[Buy Now](https://www.adafruit.com/product/3057)
[Related Guides to the Product](https://learn.adafruit.com/products/3057/guides)

## Related Guides

- [Analog Devices ADXL343 Breakout Learning Guide](https://learn.adafruit.com/adxl343-breakout-learning-guide.md)
- [Adafruit QT Py ESP32-S2 and QT Py ESP32-S2 with uFL Antenna](https://learn.adafruit.com/adafruit-qt-py-esp32-s2.md)
- [Adafruit TSC2007 I2C Resistive Touch Screen Controller](https://learn.adafruit.com/adafruit-tsc2007-i2c-resistive-touch-screen-controller.md)
- [Adafruit LiIon or LiPoly Charger BFF Add-On for QT Py](https://learn.adafruit.com/adafruit-qt-py-charger-bff.md)
- [HalloWing M4 Animated Eye Candy Bowl](https://learn.adafruit.com/hallowing-m4-candy-bowl.md)
- [Super Simple Sunrise Lamp](https://learn.adafruit.com/super-simple-sunrise-lamp.md)
- [Mystery Box: Crypto Countdown Case](https://learn.adafruit.com/mystery-box-crypto-countdown-case.md)
- [Espresso Water Tank Meter](https://learn.adafruit.com/espresso-water-tank-meter.md)
- [Star Fragment IoT Lamp](https://learn.adafruit.com/star-fragment-iot-lamp.md)
- [IoT Filament Sensor](https://learn.adafruit.com/iot-filament-sensor.md)
- [Feather Scorpio Snap Fit Case](https://learn.adafruit.com/feather-scorpio-snap-fit-case.md)
- [Wireless NeoPixel Controller](https://learn.adafruit.com/neotrellis-neopixel-controller.md)
- [RGB LED Matrix Cube with 25,000 LEDs](https://learn.adafruit.com/rgb-led-matrix-cube-for-pi.md)
- [Raspberry Pi HQ Camera Case](https://learn.adafruit.com/raspberry-pi-hq-camera-case.md)
- [CRICKIT WobblyBot](https://learn.adafruit.com/crickit-wobblybot.md)
- [Knobby Sequencer](https://learn.adafruit.com/knobby-sequencer.md)
- [Video Nub Shank: ESP32 QT Py Composite Video Injector](https://learn.adafruit.com/video-nub-shank-esp32-qt-py-composite-video-injector.md)
- [LED Noodle Lantern](https://learn.adafruit.com/led-noodle-lantern.md)
- [Modal MIDI Keyboard](https://learn.adafruit.com/modal-midi-keyboard.md)
