I use ESP’s for everything now.
you can get pre-packaged chips that work just like arduino, I like the D1 Mini series.
amazon.com/IZOKEE-NodeMcu-I … ds=d1+mini
just like arduino they come with all sorts of shields
[url]https://www.amazon.com/Diymore-ESP8266-Development-Shield-Arduino/dp/B01N9KG234/ref=sr_1_1?ie=UTF8&qid=1548708397&sr=8-1&keywords=d1+mini+relay[/url]
and with a little bit of code you can connect it to Touch in a few minutes.
I also use OSC for things like this.
[ below is arduino code ]
#include <WiFiUdp.h>
#include <ESP8266WiFi.h>
#include <OSCMessage.h>
#include <OSCBundle.h>
WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP
IPAddress outIp(10, 0, 1, 5); // remote IP of your computer
const unsigned int outPort = 9900; // remote port to receive OSC
const unsigned int localPort = 9901; // local port to listen for OSC packets (actually not used for sending)
const char* ssid = "[YOUR SSID OF WIFI]";
const char* password = "[THE WIFI PASSWORD]";
unsigned int ledState = LOW; // LOW means led is *on*
void setup() {
pinMode(D1, OUTPUT);
digitalWrite(D1, ledState);
Serial.begin(115200);
delay(100);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Starting UDP");
Udp.begin(localPort);
Serial.print("Local port: ");
Serial.println(Udp.localPort());
server.begin();
}
void oscMessage(int input) {
Serial.print("oscMessage()");
OSCMessage msg("/esp");
msg.add(input);
Udp.beginPacket(outIp, outPort);
msg.send(Udp);
Udp.endPacket();
msg.empty();
delay(50);
}
void relay(OSCMessage &msg, int addrOffset ) {
ledState = msg.getInt(0);
digitalWrite(D1, ledState);
Serial.print("/led: ");
Serial.println(ledState);
oscMessage(ledState);
}
void loop() {
OSCMessage msgIN;
int size;
if ( (size = Udp.parsePacket()) > 0)
{
while (size--)
msgIN.fill(Udp.read());
if (!msgIN.hasError()) {
msgIN.route("/relay", relay);
}
outIp = Udp.remoteIP();
}
}
in touch, use an OSCOUT dat and run this script
op('oscout_relay').sendOSC('/relay',[1])
or this one
op('oscout_relay').sendOSC('/relay',[0])
Heres something I literally threw together in 10 minutes.
[url]https://photos.app.goo.gl/kUkHgcjHfreXy5DP7[/url]