Skip to content

About

ESP32 project interfacing TTP229 16-key capacitive keypad with Wi-Fi connectivity. Transmits touch input to TCP server over local network. Built with ESP-IDF, demonstrates GPIO handling, Wi-Fi setup, and TCP communication.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

ESP32 TTP229 Controller

This project demonstrates the integration of a TTP229 16-key keypad with an ESP32, including Wi-Fi connectivity and communication with a TCP server on a local network.

Important Notes

Please be aware that this project may present certain security risks, particularly regarding data transmission over the network. As this project is intended solely for educational and experimental purposes, these risks have not been addressed in the current implementation.

Additionally, Wi-Fi SSID and password credentials are hardcoded within the source code. While it is possible to configure the ESP32 to create its own network for direct connection, this project is designed to allow simultaneous internet access and ESP32 connectivity by running a TCP server on your local machine. This repository contains only the ESP32 firmware.

Please consider these points before using this project with your own hardware.

Configuration

Below you'll find a list of files and code sections you need to modify before building the project. These changes are necessary to set up your Wi-Fi credentials and customize the keypad behavior. I'll point out exactly which files and lines to edit as you go through the setup.

  1. Wi-Fi Credentials

    Open components/wifi_library/wifi.c and look for these lines:

    #define WIFI_SSID "here"
    #define WIFI_PASS "here"

    Replace here with your own Wi-Fi network name (SSID) and password.

  2. TCP Server IP and Port

    Open main/numpad.c and find these lines:

    #define HOST_IP_ADDR "192.168.0.9"
    #define PORT 8008

    Change "192.168.0.9" to the IP address of your computer (the one running the TCP server), and update the port if needed.

    To find your computer's local IP address, you can use this command in your terminal:

    hostname -I

    or, on macOS & Linux:

    ifconfig | grep inet

That's it! After making these changes, you can continue with the build and flash steps below.

Installation

Please ensure that your router supports a 2.4 GHz Wi-Fi network, as the ESP32-WROOM ESP32S used in this project does not support 5 GHz Wi-Fi. If you require 5 GHz support, consider using the ESP32-C5-DevKit.

This project has been tested with the ESP32-WROOM ESP32S module. However, it is expected to work with other ESP32 variants as well.

To build and configure this project, you must install the ESP-IDF development framework on your computer. Pre-built binaries are not provided, as you will need to configure the firmware with your own network credentials.

Please refer to the official ESP-IDF documentation for installation instructions: ESP-IDF Get Started Guide.

Once ESP-IDF is installed, you may clone this repository:

git clone https://github.com/wcnrny/esp32-ttp229-example.git

Downloading the TCP Server

To receive keypad data from your ESP32, you will also need to run a TCP server on your computer. A simple C-based TCP server is available in the following repository:

https://github.com/wcnrny/esp32-tcp-server

Clone the repository and follow the instructions in its README to set up and start the server:

cd esp32-tcp-server
gcc tcp_server.c -o tcp_server
./tcp_server

After completing the installation steps above, your environment will be ready to build and flash the firmware to your ESP32 device. If you encounter any issues during setup, please consult the official ESP-IDF documentation or open an issue on GitHub for further assistance.

You may now proceed to the build instructions below.

Building

It is assumed that you have successfully installed the ESP-IDF development framework on your system.

Before proceeding with the build process, you must set up the ESP-IDF environment variables in your terminal session. On Linux systems, this can be accomplished by sourcing the export script provided by ESP-IDF. For convenience, you may define an alias as follows:

alias IDF_EXPORT=". ~/esp/esp-idf/export.sh"

Next, initialize the ESP-IDF environment variables by executing the export script. You may do this by running IDF_EXPORT if you have defined the alias as shown above, or by sourcing the script directly.

Once the environment is set up, navigate to the project directory:

cd /path/to/your/esp32-ttp229-example

To build your project, execute the command below:

idf.py build

This command will initiate the build process. Upon successful completion, the firmware will be ready for flashing to your ESP32 device.

Flashing

  1. Connect your ESP32 to your computer with a USB cable.

  2. Check if your computer detects the device by listing the serial ports:

    ls -l /dev/ttyUSB*

    If you see something like /dev/ttyUSB0, your device is connected. If not, make sure you have the right drivers installed.

  3. To upload the firmware to your ESP32, run this command. Replace * with the correct device number you found above:

    idf.py -p /dev/ttyUSB* flash
  4. Wait for the process to finish. When it’s done, you can open the serial monitor to see the output from your ESP32:

    idf.py -p /dev/ttyUSB* monitor

Hardware Connections

  • ESP32: Any ESP32 development board (tested with ESP32-WROOM ESP32S)
  • Keypad: TTP229 16-key capacitive touch keypad

Wiring Example:

TTP229 Pin ESP32 Pin Description
VCC 3V3 Power
GND GND Ground
SCL GPIO22 Clock (can be changed in code)
SDO GPIO21 Data (can be changed in code)

Adjust GPIO numbers in the firmware if you use different pins.

Usage

  • After flashing, reset the ESP32.
  • The device will attempt to connect to the configured Wi-Fi network.
  • Keypad presses will be sent to the TCP server running on your local machine.
  • Monitor the serial output for debug information and connection status.

Troubleshooting

  • Wi-Fi Not Connecting: Double-check your SSID and password in the source code.
  • No Output on Serial Monitor: Ensure you are using the correct serial port. The default baud rate for idf.py monitor is 115200, but you can specify a different rate if needed using the --baud option.
  • Keypad Not Detected: Verify wiring and pin assignments.

License

This project is licensed under the MIT License. See LICENSE for details.

About

ESP32 project interfacing TTP229 16-key capacitive keypad with Wi-Fi connectivity. Transmits touch input to TCP server over local network. Built with ESP-IDF, demonstrates GPIO handling, Wi-Fi setup, and TCP communication.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages