9. Inputs¶
Files¶
Overview¶
This week I used an ESP32S3 and its touch sensors as my input deivce for learning more about inputs.
Group Work¶
This week me and my partner Tyler tested the digital and analog signals of a board with step responce using an oscilloscope. It was slightly difficult when it came to making the board but afterwards it was just understanding which was digtial and which was analog.
Code¶
I initally had some difficulty finding the range of an input like touch on an esp32c6. To solve this, I first found out what the touch sensors read at a normal rate to be able to set a thresshold. I used this code to do that:
// Touch sensor pins
const int touchPin1 = 2;
const int touchPin2 = 3;
const int touchPin3 = 4;
void setup() { To do this,
Serial.begin(115200);
delay(1000); // Give some time for serial monitor to start
Serial.println("ESP32-S3 Touch Sensor Reading");
}
void loop() {
int touchValue1 = touchRead(touchPin1);
int touchValue2 = touchRead(touchPin2);
int touchValue3 = touchRead(touchPin3);
Serial.print("Touch 2: "); Serial.print(touchValue1);
Serial.print("\tTouch 3: "); Serial.print(touchValue2);
Serial.print("\tTouch 4: "); Serial.println(touchValue3);
delay(200); // Read every 200 ms
}
With that code, I saw that the threshold I needed to implement which was 150,000. This lead me to change the code and add a way to show it in the form of a “Woof”. Heres what that looked like:
// Touch sensor pins
const int touchPin1 = 2;
const int touchPin2 = 3;
const int touchPin3 = 4;
const int touchThreshold = 150000;
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("ESP32-S3 Touch Sensor Dog Detector Ready 🐾");
}
void loop() {
int t1 = touchRead(touchPin1);
int t2 = touchRead(touchPin2);
int t3 = touchRead(touchPin3);
Serial.print("T2: "); Serial.print(t1);
Serial.print("\tT3: "); Serial.print(t2);
Serial.print("\tT4: "); Serial.println(t3);
if (t1 > touchThreshold || t2 > touchThreshold || t3 > touchThreshold) {
Serial.println("🐶 Woof!");
} else {
Serial.println("...no paws detected");
}
delay(100);
}
With this code I could tell when I pressed down on the pin.
Board Design¶
I designed a simple board with three pinouts so that I could easily test the pinouts. One thing I would like to note is that when I pressed the ESP32S3 into the female pinheaders that were soldered to the board it would stop the connection from the microcontroller to the computer, I dont know why so I just didnt press it all the way down, and it worked.
Heres the PCB Design:

Heres the board:

And heres a video of the code working on the board:
Reflection¶
This week was a very enjoyable week for me. While it was annoying having my detection models fail, I learned alot about how they work through the presentation and it was fun to try and make one even if it failed. When it came to the touch sensors on the S3, they were also interesting and figuring out the threshold for it was a bit difficult but still enjoyable.