This project leverages the LILYGO® TTGO T-Relay ESP32 board to control its 4 relays via the TouchOSC app using Open Sound Control (OSC). It's ideal for home automation, lighting control, and other IoT applications requiring wireless relay management.
- WiFi Connectivity: Uses the TTGO T-Relay board's ESP32 for seamless wireless control.
- TouchOSC Integration: Control the relays via a custom layout in the TouchOSC app.
- Dynamic Timing: Relay toggling is based on OSC fader values, offering flexibility.
- Multi-Relay Support: Controls all 4 relays on the TTGO T-Relay board.
- Debugging Support: Serial output for monitoring OSC messages and relay activity.
- TTGO T-Relay ESP32 Board (Product Page)
- WiFi Network
- TouchOSC App (Available for iOS and Android)
- USB-C cable for programming and power
- Install the ESP32 Board Package.
- Install required libraries:
WiFi
WiFiUdp
OSCMessage
- Open the code in the Arduino IDE.
- Update the WiFi credentials:
const char* ssid = "YourWiFiSSID"; const char* password = "YourWiFiPassword";
- Connect the TTGO T-Relay board to your computer via USB-C.
- Select the correct board and port in the Arduino IDE.
- Upload the code to the ESP32.
- Design a layout in the TouchOSC editor with at least 4 faders.
- Assign OSC addresses to the faders:
/1/fader1
for Relay 1/1/fader2
for Relay 2/1/fader3
for Relay 3/1/fader4
for Relay 4
- Set the OSC host to the ESP32's IP address and the port to
8000
.
- Power on the TTGO T-Relay board and connect it to your WiFi network.
- Open the TouchOSC app and connect to the board using its IP address.
- Adjust the faders to control the relays:
- Fader Value < 0.3: Relay off.
- Fader Value ≥ 0.3: Relay toggles at intervals determined by the value.
Fader Address | Relay Pin | Toggle Duration (ms) Based on Fader Value |
---|---|---|
/1/fader1 |
GPIO 21 | 300, 200, 100, 50, 40, 10 |
/1/fader2 |
GPIO 19 | 300, 200, 100, 50, 40, 10 |
/1/fader3 |
GPIO 18 | 300, 200, 100, 50, 40, 10 |
/1/fader4 |
GPIO 5 | 300, 200, 100, 50, 40, 10 |
- No WiFi Connection: Ensure WiFi credentials are correct and the network is 2.4GHz.
- TouchOSC Not Responding: Verify the OSC host IP and port settings in the app.
- Relays Not Working: Ensure the relays are connected properly and GPIO pin assignments are correct.
- Laggy Response: Reduce network traffic or use a dedicated WiFi network.
Relay | GPIO Pin |
---|---|
1 | 21 |
2 | 19 |
3 | 18 |
4 | 5 |
if (faderValue >= 0.3 && faderValue < 0.4) {
duration = 300;
} else if (faderValue >= 0.4 && faderValue < 0.5) {
duration = 200;
} else if (faderValue >= 0.5 && faderValue < 0.6) {
duration = 100;
} else if (faderValue >= 0.6 && faderValue < 0.7) {
duration = 50;
} else if (faderValue >= 0.7) {
duration = 10;
}