Blast With Focus

by Upside Down Labs in Circuits > Sensors

29 Views, 0 Favorites, 0 Comments

Blast With Focus

focus.gif
2026-10-28 16-05-14_1.gif

What if you could light a Diwali patakha just by concentrating? In this project, an NPG Lite headset reads your brain's EEG signals and calculates a focus score. Cross the threshold, and a cracker lights up.

There are two ways to build it, and you can do either one or both:

  1. Mode 1: Virtual Patakha (Web). Your focus lights a cracker on a web page. No soldering, no fire, safe for kids and classrooms.
  2. Mode 2: Real Patakha (Hardware). Your focus fires an electric arc lighter that lights a real, store-bought cracker. This needs a small igniter board that you build yourself.

Supplies

NPG PHOTO.png


Hardware Requirements

  1. NPG Lite by Upside Down Labs
  2. 3 snap cables + gel electrodes (or BioAmp cables with alligator clips)
  3. Alcohol Swabs
  4. USB-C cable
  5. Laptop (for flashing and the dashboard)

Igniter board

  1. Seeed Studio XIAO ESP32-C6
  2. Optocoupler, 4-pin (for example PC817)
  3. 220 Ω resistor (current limit for the optocoupler LED)
  4. 100 µF electrolytic capacitor (across the XIAO's 3.3 V and GND)
  5. Rechargeable electric arc lighter (we use its driver board, high-voltage coil and arc electrodes)
  6. 3.7 V 500 mAh LiPo battery (powers both the XIAO and the lighter)
  7. Perfboard, hook-up wire, heat-shrink
  8. Soldering iron and solder
  9. Legal, store-bought crackers with a fuse (anaar, phuljhadi, chakri and so on)
  10. A bucket of water or sand

Software Requirements

  1. Arduino IDE 2.x
  2. Espressif ESP32 board package 3.x (tested with 3.1.1 and 3.2.0). Version 2.x does not support the ESP32-C6.
  3. Libraries:
  4. Adafruit NeoPixel
  5. OneButton (by Matthias Hertel)
  6. ESP-DSP (FFT), already included in the ESP32 3.x package
  7. Firmware files (must sit in the same folder):
  8. BCI-Focus-Patakha-Remote.ino: reads the EEG, calculates focus, talks to the XIAO and runs the web server
  9. index_html.h: the whole dashboard (HTML, CSS and JavaScript). It is kept out of the .ino because the Arduino IDE's prototype generator breaks on JavaScript inside a sketch file.

Arduino IDE Setup

  1. Install Arduino IDE 2.x.
  2. Open File → Preferences and add this URL to Additional boards manager URLs: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  3. Open Tools → Board → Boards Manager, search esp32 and install esp32 by Espressif Systems, version 3.x.
  4. Open Sketch → Include Library → Manage Libraries, install Adafruit NeoPixel, then OneButton (by Matthias Hertel).

+

How It Works?

focus.gif
2026-10-28 16-05-14_1.gif

When you concentrate, the share of beta waves (13–30 Hz) in your EEG usually rises. The NPG Lite measures that share 4 times a second and treats it as your focus score.

Three parts work together:

  1. NPG Lite on your head: reads the EEG, calculates focus, hosts the web dashboard and decides when to fire.
  2. Laptop: shows the live focus gauge, the threshold slider, a 30-second graph and an animated cracker.
  3. XIAO ESP32-C6 igniter board: receives ON/OFF over Wi-Fi and triggers an electric arc lighter through an optocoupler.

No router or internet is needed. The NPG Lite creates its own Wi-Fi hotspot NPG-Focus-Light and everything connects to it. The laptop reads live data from it for the dashboard, while the XIAO gets a fire or stop message every 100 ms on a separate channel (UDP), so a slow browser never delays the igniter.

If you adapt this project to ignite real physical firecrackers using an electric lighter coil, exercise extreme caution:

  1. Keep the setup outdoors in an open, clear space on a non-flammable surface.
  2. Maintain a safe distance once the system is live—accidental focus spikes can trigger ignition unexpectedly.
  3. Always keep a fire extinguisher or bucket of sand nearby, and never place physical pyrotechnics indoors.

Note: This project is strictly for educational and experimental purposes.

Build the Igniter Board

circuit.jpeg
focus_patakha_wiring.png

1. Connect the resistor: Connect XIAO D6 (GPIO16) to one end of the 220 Ω resistor.

2. Connect the optocoupler: Connect the other end of the resistor to pin 1 of the optocoupler. Connect pin 2 to XIAO GND.

3. Connect the fire-button connection: Connect optocoupler pins 3 and 4 to the two push-button pads on the lighter's driver board. The optocoupler keeps the XIAO electrically isolated from the lighter circuit.

4. Connect the battery: Connect the LiPo battery to the XIAO's battery input and the lighter board's battery input, following the circuit diagram.

5. Add the capacitor: Connect the 100 µF capacitor across the XIAO's 3.3 V and GND pins. The positive leg goes to 3.3 V, and the striped negative side goes to GND.

6. Connect the electrodes: Keep the lighter's original high-voltage coil and electrodes in place. Ensure the high-voltage section remains separate from the low-voltage electronics.

Secure the connections: Insulate exposed joints and keep the wiring neatly arranged.

Flash the XIAO ESP32-C6

Screenshot 2026-10-31 162443.png
  1. Connect the XIAO to your computer using a USB-C cable.
  2. Open the NPG Lite Flasher Web in Chrome or Edge.
  3. Click Connect and select the XIAO's USB JTAG serial device.
  4. Click Get from GitHub and select BCI-Focus-Patakha-Client.
  5. Flash the firmware and press the XIAO's RESET button.

Flash the NPG Lite

Screenshot 2026-10-31 162711.png
  1. Connect the NPG Lite to your computer using a USB-C cable and switch it on.
  2. Open the same NPG Lite Flasher Web.
  3. Click Connect and select the NPG Lite's USB JTAG serial device.
  4. Click Get from GitHub and select BCI-Focus-Patakha-Remote.
  5. Flash the firmware and press the RESET button.

Flashing the NPG Lite and XIAO

Both the NPG Lite and XIAO ESP32-C6 need their respective firmware to communicate with each other. You can upload the firmware using the Web Flasher or Arduino IDE.

Step 1: Install Arduino IDE (if using Arduino IDE)

  1. Download and install Arduino IDE 2.x.
  2. Open File → Preferences and add this URL under Additional Boards Manager URLs:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  1. Open Tools → Board → Boards Manager, search for esp32, and install esp32 by Espressif Systems (3.x).
  2. Open Sketch → Include Library → Manage Libraries and install Adafruit NeoPixel and OneButton.


Using Arduino IDE (Alternative Method)

If you want to modify the firmware instead of using the Web Flasher:

  1. Open BCI-Focus-Patakha-Client.ino for the XIAO firmware.
  2. Select Tools → Board → XIAO_ESP32C6 and choose the correct port.
  3. Click Upload and open Serial Monitor at 115200 baud.
  4. For the NPG Lite, open BCI-Focus-Patakha-Remote.ino. Keep index_html.h in the same folder.
  5. Select ESP32C6 Dev Module, enable USB CDC On Boot, and choose the correct port.
  6. Click Upload and open Serial Monitor at 115200 baud.

Check the Connection

npg on-off gif.gif
  1. Switch on the NPG Lite.
  2. Check the NPG Lite Serial Monitor for Hotspot "NPG-Focus-Light" up.
  3. Check the XIAO Serial Monitor for Connected! XIAO IP: 192.168.4.x.
  4. Once connected, the two boards can communicate over Wi-Fi.

For safety, test the communication and output using an LED or buzzer rather than a real firecracker igniter. Do

Connection

NPG Connection Diagram.png
  1. Skin Preparation: Apply a small amount of NuPrep gel to each electrode site and gently rub for a few seconds to reduce skin impedance. Clean the areas thoroughly with an alcohol wipe and allow them to dry completely.
  2. Electrode Placement: Position the electrodes according to the standard montage:
  3. A0P (Channel 1 +): Place on your forehead, just above one eyebrow (Fp1 or Fp2)
  4. A0N (Channel 1 −): Place behind one earlobe.
  5. REF (Reference): Place behind the opposite earlobe.
  6. For optimal signal clarity and to minimize mains electrical noise, operate the NPG Lite device on battery power rather than connecting it to a plugged-in laptop.
  7. Sit in a comfortable position, relax your facial muscles and jaw, and minimize unnecessary movement, talking, or blinking to ensure a clean, artifact-free EEG signal.


Threshold

2026-10-28 16-05-14.00_01_42_15.Still005.00_00_24_03.Still002.png
2026-10-28 16-05-14.00_01_42_15.Still005.00_00_28_11.Still003.png
2026-10-28 16-05-14.00_01_42_15.Still005.00_00_06_09.Still001.png
2026-10-28 16-05-14.00_01_59_21.Still006.png

1. Open the Dashboard and Set Your Focus Level

  1. Switch on the NPG Lite and the igniter board.
  2. On your laptop, connect to the Wi-Fi network NPG-Focus-Light using the password 12345678.
  3. Open a browser and visit http://focus-light.local. If the page doesn't load, try http://192.168.4.1 instead. Some Windows laptops and Android phones may not support .local addresses.
  4. Check the two status indicators in the top-right corner:
  5. NPG · 5 ms · 512 Hz: The dashboard is receiving live EEG data at 512 Hz.
  6. XIAO · 10/s: The igniter board is responding around 10 times per second. Red means offline, while amber indicates a weak connection.
  7. Find your baseline: Sit comfortably with your eyes open and relax for about one minute. Watch the focus gauge and 30-second graph to understand your normal focus level.
  8. Set your threshold: Use the slider or + / − buttons to set the threshold a few points above your relaxed focus level. The white mark on the gauge and the dashed line on the graph show your selected threshold. The setting saves automatically.
  9. Test your focus: Start concentrating by counting backwards from 100 in sevens or solving simple maths problems in your head. When your focus score crosses the threshold, the gauge turns gold and the system sends a trigger signal.
  10. Choose a mode using the dashboard buttons:
  11. Auto: Activates the output when your focus reaches the set threshold.
  12. Always Lit: Keeps the output active for testing the signal connection. Use this mode only for testing with the igniter disconnected.
  13. Off: Disables the output from the dashboard.
  14. Check the NPG Lite LEDs: The NeoPixels also show your focus level. Three lit LEDs indicate that you have reached the threshold, all six indicate double the threshold, and all six turn bright white during a trigger event.

Customising the Igniter Board

You can change the following settings at the top of the BCI-Focus-Patakha-Client.ino code:

  1. LED_PIN = 16: Sets the output pin used to control the optocoupler (D6).
  2. LINK_TIMEOUT_MS = 1500: Sets the fail-safe timeout. If the board does not receive a message for 1500 ms, the output automatically turns off.
  3. AP_SSID = "NPG-Focus-Light": Sets the Wi-Fi network name. It must match the network name configured in the NPG Lite firmware.
  4. AP_PASS = "12345678": Sets the Wi-Fi password. It must also match the password configured in the NPG Lite firmware.

Safety Note: This is an experimental educational project for learning about EEG signals.

Reboot

chkri.gif

The NPG Lite's BOOT button lets you adjust the focus threshold and test the system without wearing EEG electrodes.

  1. Single click: Decreases the threshold by 2.5% (minimum 5%).
  2. Double click: Increases the threshold by 2.5% (maximum 30%).
  3. Hold for 0.7 seconds: Starts a simulated focus test. The score increases by 5% every second until it reaches the threshold. The dashboard displays Button test. Release to return to real EEG readings.
  4. A high beep confirms a change, while a low beep indicates the minimum or maximum limit.
  5. Changes save automatically. If dashboard mode is Off, the output remains disabled.

LED Indicators

The six NeoPixels show the selected threshold for two seconds after a button click.

  1. Each blue LED = 5%.
  2. Each green LED = 2.5%.
  3. 5% = one blue LED.
  4. 7.5% = one blue + one green.
  5. 30% = six blue LEDs.

Sound and Vibration Feedback

  1. Each lit LED plays a musical note (Do, Re, Mi, Fa, Sol, La).
  2. The third LED marks the focus threshold.
  3. A low tick plays when an LED turns off.
  4. During a trigger, all six LEDs turn white and the buzzer plays a sound effect.
  5. When XIAO connects, the LEDs flash green and the motor buzzes once.
  6. If disconnected for 1.5 seconds, the LEDs flash red and the motor buzzes twice.

Customise the Settings

Change these values in BCI-Focus-Patakha-Remote.ino:

  1. SOUND_ON = 1: Enable or mute buzzer sounds.
  2. BEEP_ON_DOWN = 1: Enable or disable low ticks.
  3. FIRE_BRIGHTNESS = 180: Set LED brightness (maximum 255).
  4. MOTOR_PIN = 7: Set the vibration motor pin.
  5. HYSTERESIS = 1.0: Prevent rapid ON/OFF switching near the threshold.


Light a Real Patakha

focus.gif
  1. Place the cracker on flat, open ground outdoors.
  2. Rest its fuse in the arc gap of the electrodes.
  3. Move the slide switch on the lighter board to ON (armed), then step back at least 3 m.
  4. Focus. When you cross the threshold on the NPG Lite dashboard, the arc lights the fuse.
  5. Disarm the slide switch before you go near the igniter again.

Tip: use the dashboard's Always lit mode (with no cracker in place) to test the wiring, and Off to keep the igniter disarmed from the dashboard.