- [ESP-WROOM-32 on Arduino ](https://www.deviceplus.com/arduino/lets-play-with-esp-wroom-32-on-arduino-environment-construction-setup-led-blinking/?fbclid=IwAR2MLQgIpNsol_VAYNStH30PhUcd88YtlfI8wNJf24LJSBCFq3KU3BKcsCg)
- [The Newbie’s Guide to Programming an ESP32 on the Arduino IDE](https://www.iottechtrends.com/program-esp32-on-arduino-ide/?fbclid=IwAR1W8dblx-idwUIDvSSKgXqxPp-xUp5z3Nx4CDEQd2OLjUCn-G3ag2rRusU)
ESP-WROOM-32 is a Wi-Fi module equipped with a chip called ESP32 provided by **Espressif Systems** and capable of Wi-Fi and Bluetooth (BLE) communication. It is slightly larger than ESP-WROOM-02, but it still is small. The module also has the advantage that Arduino programs can be written (that is, the module can be used as part of Arduino), and Wi-Fi communication is supported. Read more on the ESP32 board by checking out the links above.
Steps:
1. Download ESP32 Board in Arduino IDE Library
2. Download Files
3. Download Driver
4. Upload Code to ESP32
For step 1: I am following this [link](https://www.iottechtrends.com/program-esp32-on-arduino-ide/?fbclid=IwAR1W8dblx-idwUIDvSSKgXqxPp-xUp5z3Nx4CDEQd2OLjUCn-G3ag2rRusU). I open Arduino IDE then click on File > Preferences and paste the link below to be able to install the ESP32 Board in Arduino IDE boards library.
I am following this [link](https://www.iottechtrends.com/program-esp32-on-arduino-ide/?fbclid=IwAR1W8dblx-idwUIDvSSKgXqxPp-xUp5z3Nx4CDEQd2OLjUCn-G3ag2rRusU). I open Arduino IDE then click on File > Preferences and paste the link below to be able to install the ESP32 Board in Arduino IDE boards library.
For steps 2-4: I am following this [link]((https://www.deviceplus.com/arduino/lets-play-with-esp-wroom-32-on-arduino-environment-construction-setup-led-blinking/?fbclid=IwAR2MLQgIpNsol_VAYNStH30PhUcd88YtlfI8wNJf24LJSBCFq3KU3BKcsCg))
First, I download the ZIP folder from this [github website](https://github.com/espressif/arduino-esp32)
For step 3: I download these softwares for my Driver from this [Silicon Labs](https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?tab=downloads) website. I downloaded the 1st and 3rd
- [Getting Started with Seeed Studio XIAO ESP32C3](https://wiki.seeedstudio.com/XIAO_ESP32C3_Getting_Started/)
- [Seeed Studio XIAO ESP32C3 - RISC-V tiny MCU board with Wi-Fi and Bluetooth5.0, battery charge supported, power efficiency and rich Interface](https://www.seeedstudio.com/Seeed-XIAO-ESP32C3-p-5431.html)
```
_.... to be continued_
Repeat for the second xiao.
[ video of led blinking ]
#### communication between the two boards
### **spiral four**: communication between the two boards
!!! example "Communication Between **two ESP32 mcus**"
TX, Transmitter: Microphone sensor and Xiao on Garment
RX, Receiver: ESP32 connected to Computer Arduino IDE and TD
**TX, Transmitter**: Microphone sensor and Xiao on Garment
**RX, Receiver**: ESP32 connected to Computer Arduino IDE and TD
The two boards will communivate via a program called **_ESP-NOW_**. Tutorial above.
...
...
@@ -374,10 +359,274 @@ I will end up running **3 pieces of code**...
2. Running the Mac Address code on the RX board > to get it's unique wireless communication ID
3. Configuring and uploading the Receiver Code to the RX board
_.... to be continued_
These are codes just to test whether the two xiao boards can communicate with each other. It does not include the data from the microphone sensor. The next spiral will include code for the microphone sensor.
#### First Code:
```
// Transmitter Code
#include <esp_now.h>
#include <WiFi.h>
#define Channel 1 // TX and RX must be on same channel
esp_now_peer_info_t slave; // stores info about slave, incl MAC Address
uint8_t data = 0; // initial data sent...unsigned integer...250 bytes or less
## PART FOUR: COMMUNICATION BETWEEN ARDUINO IDE & TD
void setup() {
Serial.begin(115200);
pinMode(buttonPin, INPUT);
WiFi.mode(WIFI_STA); // set TX mode as Wifi Station
esp_now_init();
esp_now_register_send_cb(OnDataSent); // run Call-back function called OnDataSent
ScanForSlave(); // find slave MAC address at specific SSID
esp_now_add_peer(&slave); // point to stored slave data...based on discovered MAC address
}
void loop() {
esp_now_send(slave.peer_addr, &data, sizeof(data)); // send to slave address, data, data length
data++;
delay(3000);
int state = digitalRead(buttonPin);
}
void ScanForSlave(){
int8_t scanResults = WiFi.scanNetworks();
for (int i = 0; i < scanResults; ++i){
String SSID = WiFi.SSID(i);
String BSSIDstr = WiFi.BSSIDstr(i);
if (SSID.indexOf("RX") == 0){ // Looks for matching network name
Plug the RX board into your computer and upload this code. Then go to serial monitor and copy the digits like this:
```
//Get MAC Address Code
#include "WiFi.h"
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_MODE_STA);
Serial.println(WiFi.macAddress());
}
void loop(){}
```
Open your serial monitor.
this is what i got in the last line: this is the MAC address for the RX board: I will need these digits for when I want the TX to send information wirelessly to my RX (in the next spiral):
15:08:56.975 -> **34:85:18:03:77:7C**
#### Third Code:
```
// Receiver Code
#include <esp_now.h>
#include <WiFi.h>
#define Channel 1 // same channel as TX
uint8_t newData;
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_AP); // set wifi to AP mode
WiFi.softAP("RX_1", "RX_1_Password", Channel, 0); // SSID that TX can recognize
esp_now_init();
esp_now_register_recv_cb(OnDataRecv);
}
void loop() {
Serial.print("I did this to data >> ");
Serial.println(newData * 5); //making use of incoming data
delay(3000);
}
void OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len){
Serial.print("I just received >> ");
Serial.println(*data);
memcpy(&newData, data, sizeof(newData)); //copy data from membory (memory copy) for use in loop
}
```
Now that I've tested that the TX and RX Xiao boards can communicate with one another, I want the TX to transmit microphone sensor data to the RX.
### **spiral five**: test microphone sensor with TX+RX
#### TX code
In this code I will insert my **RX board's MAC address**
the line that says "uint8_t RxMACaddress[] = {0x34, 0x85, 0x18, 0x03, 0x77, 0x7C};" is where those digits go
//int val = map(receivedData.micVal, 4095, 0, 0, 1000);
Serial.println(receivedData.micVal);
}
```
## PART FOUR: SERIAL DATA AND AUDIO-REACTIVE VISUALS
Once i've managed to transfer my microphone sensor data from Arduino IDE to TD, I can start playing around with this data in TouchDesigner to trigger different animations.