Skip to content

Commit 34f8e00

Browse files
committed
Hardware change & documentation
1 parent 0926925 commit 34f8e00

File tree

6 files changed

+38
-24
lines changed

6 files changed

+38
-24
lines changed

QuizHubEsp32/QuizHubEsp32.ino

+26-15
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ the data folder to the internal flash memory of the ESP32. The upload tool, once
4343
of your Arduino environment as extra menu item "ESP32 Sketch data upload". See these links:
4444
- https://github.com/me-no-dev/arduino-esp32fs-plugin
4545
46+
Buttons for manual start/stop/test are implemented using the ESP32 capcitive touch. You only need to feed
47+
a wire to the outside of your box and touch it to "touch" the button.
48+
4649
NAT support.
4750
Version 1.0.4 of ESP32 core does not support NAT (like ESP8266 does). This means that nodes connected to the soft AP side can not
4851
reach the internet. This is fine for the quiz nodes and the web browser can connect to the quiz hub through the second IP address provided
@@ -94,14 +97,15 @@ Still todo:
9497
#define LEDBLUEPIN 2 // blue led (on board LED and also extern connected to GPIO02) 1=on, 0=off
9598
#define LEDGREENPIN 22 // green LED: when a node has won
9699
#define LEDREDPIN 23 // red LED: when "hot" (nodes are flashing)
100+
#define PIN_HOT 4 // enter hot mode to all nodes GPIO5 => GPIO4 Touch
101+
#define PIN_STOP 33 // set stop mode to all nodes GPIO4 => GPIO33 Touch
102+
#define PIN_TEST 15 // run connection test (will turn on/off all button LEDs) GPIO15 Touch
103+
#define WIFIPORTALPIN PIN_HOT // trigger WiFi portal during reboot
104+
105+
// parameters
97106
#define LEDON 1 // for LEDs: value to digitalwrite to turn led off
98107
#define LEDOFF 0 // for LEDs: value to digitalwrite to turn led on
99-
#define PIN_HOT 5 // enter hot mode to all nodes GPIO5 => GPIO5 mark
100-
#define PIN_STOP 18 // set stop mode to all nodes GPIO4 => GPIO18
101-
#define PIN_STATUS 19 // show statistics of all nodes and run connection test (will turn on/off all button LEDs) GPIO19
102-
#define SWITCH_OFF 0 // DigitalRead for PIN_HOT, PIN_STOP, PIN_STATUS to show the switch is not pressed
103-
#define SWITCH_ON 1 // idem for switch is pressed
104-
#define WIFIPORTALPIN PIN_HOT // trigger WiFi portal during reboot
108+
#define TOUCHTHRESHOLD 50 // value from touchRead() to consider the button to be touched
105109

106110
// We have 2 webservers defined on port 80, of which only 1 runs at a time
107111
WebServer server(80); // web server for normal Quiz function
@@ -215,10 +219,6 @@ void setup(void) {
215219
digitalWrite(LEDBLUEPIN, LEDON); // turn on blue LED
216220
digitalWrite(LEDREDPIN, LEDOFF);
217221
digitalWrite(LEDGREENPIN, LEDOFF);
218-
pinMode(WIFIPORTALPIN, INPUT_PULLUP);
219-
pinMode(PIN_HOT, INPUT_PULLUP);
220-
pinMode(PIN_STOP, INPUT_PULLUP);
221-
pinMode(PIN_STATUS,INPUT_PULLUP);
222222
Serial.begin(115200);
223223

224224
Serial.println();
@@ -242,7 +242,7 @@ void setup(void) {
242242
wm.setClass("invert"); // set dark theme
243243
wm.setConfigPortalTimeout(40); // auto close configportal after n seconds
244244

245-
if (digitalRead(WIFIPORTALPIN)==SWITCH_ON) {
245+
if (getTouch(WIFIPORTALPIN)) {
246246
Serial.println("Button pressed at boot, wipe WiFi settings");
247247
wm.resetSettings(); // wipe settings to force
248248
}
@@ -293,7 +293,6 @@ void setup(void) {
293293

294294
digitalWrite(LEDBLUEPIN, LEDOFF); // turn off LED
295295

296-
297296
// configure standard Quiz web server
298297
server.on("/", handleRoot);
299298
server.on("/quiz", handleNodeAPI);
@@ -318,7 +317,7 @@ void loop(void) {
318317
}
319318
}
320319

321-
if (((digitalRead(PIN_STOP)==SWITCH_ON) && flashtime+1000 < millis()) || tell2cmd==0) {
320+
if ((getTouch(PIN_STOP) && flashtime+1000 < millis()) || tell2cmd==0) {
322321
Serial.println(F("Setting stop mode.."));
323322
digitalWrite(LEDREDPIN, LEDOFF);
324323
digitalWrite(LEDGREENPIN, LEDOFF);
@@ -329,7 +328,7 @@ void loop(void) {
329328
flashtime = millis();
330329
}
331330

332-
if (((digitalRead(PIN_HOT)==SWITCH_ON) && flashtime+1000 < millis()) || tell2cmd==1) {
331+
if ((getTouch(PIN_HOT) && flashtime+1000 < millis()) || tell2cmd==1) {
333332
Serial.println(F("Setting hot mode.."));
334333
sendAllNodes(CMD_HOT); // set hot to all buttons
335334
quizMode = mode_hot;
@@ -340,7 +339,7 @@ void loop(void) {
340339
flashtime = millis();
341340
}
342341

343-
if (((digitalRead(PIN_STATUS)==SWITCH_ON) && flashtime+1000 < millis()) || tell2cmd==2) {
342+
if ((getTouch(PIN_TEST) && flashtime+1000 < millis()) || tell2cmd==2) {
344343
flashtime = millis();
345344
digitalWrite(LEDGREENPIN, LEDOFF);
346345
digitalWrite(LEDREDPIN, LEDOFF);
@@ -632,3 +631,15 @@ void displayDir(String dirname) {
632631
file = root.openNextFile();
633632
}
634633
}
634+
635+
// capacitive touch routine. To filter out spike noises we require the touchRead() value to be 100ms at a filter below
636+
// the defined threshhold
637+
int getTouch(int port) {
638+
int t;
639+
for (int i=0; i<10; i++) {
640+
t=touchRead(port);
641+
if (t>TOUCHTHRESHOLD) return 0;
642+
delay(10);
643+
}
644+
return 1;
645+
}

README.md

+12-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This project was based on the need to create a set of "Quiz" buttons for a fun family evening to support a Quiz setting, where multiple teams have to answer quiz questions and you need to know who presses the Quiz-button first.
44

5+
![Quiz Hub ESP32](img/QuizHubESP32Outside.png?raw=true "Quiz Hub ESP32")
6+
57
## Overview
68

79
I bought 4 large pushbuttons on Sparkfun (see https://www.sparkfun.com/products/9181) and mounted the buttons on a piece of plywood, supported by some large screws. The Arduino hardware for each button is mounted underneath.
@@ -44,16 +46,15 @@ The quiz button is powered by 2 AA batteries making the supply 3V (on average).
4446

4547
![Quiz Button back](img/QuizButton_ESP8266.png?raw=true "Quiz Button back")
4648

47-
The ESP8266 or ESP32 hub is powered by a standard USB connector/ power supply. Gameplay can be activated using buttons or using the web interface of the built-in web server. You can defined in the source if pressing a button
48-
generates a 1 (high) or 0 (low). In the picture below I use TTP223 based touch button modules for the switches (https://www.aliexpress.com/item/32964219843.html).
49+
The ESP8266 or ESP32 hub is powered by a standard USB connector/ power supply. Gameplay can be activated using buttons or using the web interface of the built-in web server. In the picture below, standard switches are used
50+
as buttons. In the ESP32 version the capacitive "Touch" feature of the ESP32 chip is used, so you only need to
51+
feed the wires from the "Touch" pins to the outside of your box.
4952

5053
![Quiz Hub ESP8266](img/QuizHub_ESP8266.png?raw=true "Quiz Hub ESP8266")
5154

52-
![Quiz Hub ESP32](img/QuizHubESP32A.png?raw=true "Quiz Hub ESP32")
53-
54-
![Quiz Hub ESP32](img/QuizHubESP32B.png?raw=true "Quiz Hub ESP32")
55+
![Quiz Hub ESP32 Inside](img/QuizHubESP32Inside.png?raw=true "Quiz Hub ESP32 Inside")
5556

56-
Hardware schematics will be added soon
57+
TODO: Adding hardware schematics
5758

5859
## Getting started with the 3rd generation (ESP8266/ESP32)
5960

@@ -76,7 +77,7 @@ https://github.com/earlephilhower/arduino-esp8266littlefs-plugin/releases)
7677
Steps for each button:
7778
- Add the circuit to allow measurement of the battery voltage (optional) and current driver for the external LED
7879
- Compile and upload the QuizNode8266 sketch (optionally change the source in case you want to the use the built in LED instead of an external LED)
79-
- Once the button restarts, you should see an entry appear on the web server interface of the hub and you can assign a name and MP3 file to play when the given button wins. The MP3 file will be played on the phone or web browser used to control the quiz hub
80+
- Once the button restarts, it will connect to the quizhub WiFi network and ping the server.
8081

8182
## Web Interface
8283

@@ -86,11 +87,13 @@ When the QuizHub can not connect to the WiFi the Blue LED stays on and the confi
8687

8788
You can also force the WiFi portal but keeping the Start/Hot button pressed while rebooting.
8889

89-
As soon as a Quiz Node is booted and connected to your WiFi, you get to the QuizHub web server by pointing your browser (phone/computer/tablet) to http://quiz.local. Any new node should show up in the table:
90+
As soon as a Quiz Node is booted and connected to your configured WiFi, you get to the QuizHub web server by pointing your browser (phone/computer/tablet) to http://quiz.local. The quizhub will also keep the quizhub WiFi
91+
up for the nodes. Any new node that boots should show up in the table:
9092

9193
![Quiz Hub Web site](img/QuizHubWeb.png?raw=true "Quiz Hub Web Site")
9294

93-
You can assign a name and optional sound to each button by clicking on a row in the table. The configured sound will play through the speakers of the device showing the web site. The team name and selected sound are stored within the browser local storage. Please note that on IOS (Apple) devices you should play a sound once (manually) by clicking one of the play button before sounds work.
95+
You can assign a name and optional sound to each node by clicking on a row in the table. The configured sound will play through the speakers of the device showing the web site. The team name and selected sound are stored within the browser local storage so the names are kept for your next quiz session.
96+
Please note that on IOS (Apple) devices you should play a sound once (manually) by clicking one of the play button before sounds work.
9497

9598
The statistics button allows you to see the battery level of all hubs and various communication statistics:
9699

img/QuicHubEsp32Inside.png

1.05 MB
Loading

img/QuizHubESP32A.png

-3.07 MB
Binary file not shown.

img/QuizHubESP32B.png

-3 MB
Binary file not shown.

img/QuizHubEsp32Outside.png

473 KB
Loading

0 commit comments

Comments
 (0)