├── .gitattributes ├── README.md ├── simpleOSCSender └── simpleOSCSender.ino ├── OSCbuttonFaderFunction └── OSCbuttonFaderFunction.ino └── OSCreceive.maxpat /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Blog post here: http://www.dotlib.org/blog/2018/1/16/feather-huzzah-32-osc-esp32 2 | 3 | # Huzzah32OSC 4 | 5 | The Huzzah32 is great as it has lots of analogue inputs so we can read lots of sensors. It can connect to Wifi and send OSC to a host computer or indeed tablet app. Its easy to programme the same way as an Arduino over USB and has loads of extra capabilities including Bluetooth/BLE: 6 | https://learn.adafruit.com/adafruit-huzzah32-esp32-feather/overview 7 | 8 | Using Huzzah32 with Arduino IDE for sending OSC over Wifi 9 | 10 | This will tell you how to set the board in the IDE and get the driver, although I had to use the legacy USB driver, even though I am on OS X 10.10, to get it working: 11 | https://learn.adafruit.com/adafruit-huzzah32-esp32-feather/using-with-arduino-ide 12 | 13 | You will also need the OSC library, and even if you have it, it has recently been updated for ESP32 so you may need to update it. 14 | https://github.com/CNMAT/OSC 15 | 16 | Everything else is from the WiFi library, it should grab the one you have installed with the Espressif board setup rather than the built in one. 17 | 18 | The included sketches show how to send basic ints, strings and floats (**NB - to get the float to send I had to declare a variable to hold it rather than just putting it in the brackets for some reason) and how to efficiently send button and sensor readings. 19 | 20 | Also included is a MaxMSP patch showing how I receive and route the button and fader inputs over OSC in Max. 21 | 22 | …and don’t forget to add your own network name, password and host IP address!! 23 | 24 | 25 | 26 | ***NB - Currently you can not use WiFi and do an analogRead on any pin 27 | below 32, i.e. use A2, A3, A4​, A7, A9 28 | https://github.com/espressif/arduino-esp32/issues/102 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /simpleOSCSender/simpleOSCSender.ino: -------------------------------------------------------------------------------- 1 | 2 | /* Send OSC to a computer on the local network using the Huzzah32 and Wifi 3 | * 4 | * I'm sure I have borrowed from WiFi and OSC library examples, can't find exact sources to credit 5 | 6 | Luke Woodbury 9th January 2018 7 | */ 8 | 9 | 10 | //Wifi and OSC stuff 11 | #include 12 | #include 13 | #include 14 | 15 | char ssid[] = "Your Network Name"; // your network SSID (name) 16 | char pass[] = "yourpassword"; // your network password 17 | 18 | WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP 19 | const IPAddress outIp(10, 133, 112, 252); // remote IP of your computer 20 | const unsigned int outPort = 8000; // remote port to receive OSC 21 | const unsigned int localPort = 9000; // local port to listen for OSC packets (actually not used for sending) 22 | 23 | #define LEDpin 13 24 | 25 | 26 | void setup() { 27 | 28 | pinMode(LEDpin, OUTPUT); 29 | 30 | Serial.begin(115200); 31 | // Connect to WiFi network 32 | Serial.println(); 33 | Serial.println(); 34 | Serial.print("Connecting to "); 35 | Serial.println(ssid); 36 | WiFi.begin(ssid, pass); 37 | 38 | while (WiFi.status() != WL_CONNECTED) { 39 | delay(500); 40 | Serial.print("."); 41 | } 42 | Serial.println(""); 43 | 44 | Serial.println("WiFi connected"); 45 | Serial.println("IP address: "); 46 | Serial.println(WiFi.localIP()); 47 | 48 | Serial.println("Starting UDP"); 49 | Udp.begin(localPort); 50 | Serial.print("Local port: "); 51 | //Serial.println(Udp.localPort()); 52 | 53 | } 54 | 55 | void loop() { 56 | float fnum = 3.14; 57 | 58 | OSCMessage msg("/pongo"); 59 | msg.add(3); 60 | msg.add("hello"); 61 | msg.add(fnum); 62 | Udp.beginPacket(outIp, outPort); 63 | msg.send(Udp); 64 | Udp.endPacket(); 65 | msg.empty(); 66 | 67 | digitalWrite(LEDpin, HIGH); 68 | delay(500); 69 | digitalWrite(LEDpin, LOW); 70 | delay(500); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /OSCbuttonFaderFunction/OSCbuttonFaderFunction.ino: -------------------------------------------------------------------------------- 1 | /* Tracking button presses and analog readings with arrays and functions, 2 | * only outputting the states when they change. 3 | * Sending everything out over OSC using Huzzah32 4 | * 5 | * I'm sure I have borrowed from WiFi and OSC library examples, can't find exact sources to credit 6 | * 7 | NB - Currently you can not use WiFi and do an analogRead on any pin 8 | below 32, i.e. use A2, A3, A4​, A7, A9 9 | https://github.com/espressif/arduino-esp32/issues/102 10 | * 11 | * Luke Woodbury 16/1/18 12 | */ 13 | 14 | 15 | 16 | //button pin array, add the pins your buttons are on 17 | byte buttons[] = {13, 14, 15, 22, 23, 27}; 18 | const int numBut = sizeof(buttons); 19 | 20 | //fader pin array, add the pins your sensors are on 21 | byte faders[] = {A2, A3, A4, A7, A9}; 22 | const int numFad = sizeof(faders); 23 | 24 | //Wifi and OSC stuff 25 | //#include 26 | #include . 27 | #include 28 | #include 29 | 30 | char ssid[] = "********"; // your network SSID (name) 31 | char pass[] = "********"; // your network password 32 | 33 | WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP 34 | const IPAddress outIp(10, 133, 112, 252); // remote IP of your computer 35 | const unsigned int outPort = 8000; // remote port to receive OSC 36 | const unsigned int localPort = 9000; // local port to listen for OSC packets (actually not used for sending) 37 | 38 | 39 | 40 | void setup() { 41 | // set up serial port 42 | Serial.begin(115200); 43 | 44 | //debug 45 | Serial.print("OSC sender with "); 46 | Serial.print(numBut, DEC); 47 | Serial.println(" buttons"); 48 | Serial.print(numFad, DEC); 49 | Serial.println(" faders"); 50 | 51 | //set up button pins as inputs 52 | for (int i=0; i