

Sswingg bat
Bat sensor for SwingLab (CricPro): ESP32-C3 Super Mini, BMI160, LiPo and TP4056. Circuit diagrams, staged Arduino sketches and a build guide.
- Size
- 48.3 × 60 mm
- Copper layers
- 2
- Thickness
- 1.6 mm
- Parts
- 13
- Nets
- 23
- Pads
- 50
- Tracks, vias
- 36, 0
- Routed
- Yes
- KiCad
- KiCad 10.0 (file 20260206)
- Created
- 11 Oct 2026
- Updated
- 22 Oct 2026
Overview
Sswingg bat is an open-source printed circuit board by gaurav3611, from the gaurav3611/Cric-Pro-Hardware repository on GitHub. It is a 2-layer board of 48.3 × 60 mm with 13 parts on 23 nets, routed with 36 tracks and 0 vias.
Its parts include 3 ICs, 2 capacitors, 2 resistors, 1 diode and 1 connector. It belongs with the sensors and measurement boards and the ESP32 and RISC-V boards of this library.
README
README.mdSSwinGG bat sensor: hardware and firmware, step by step
A small sensor that sits on a cricket bat and sends every movement of the bat to the SSwinGG dashboard over Bluetooth. This folder holds the circuit, the firmware, and a guide that builds it one stage at a time, so that each stage is tested before the next part is added.
It is written for someone who has not done this before. Each stage says what to wire, what to upload, what you should see, and what is going on between the parts.
What has been checked, and what has not
- Checked: every sketch compiles for the ESP32-C3 Super Mini, with no warnings. Stages 1 to 8 have also been run on a computer against a pretend sensor, battery and dashboard, and what they print, send and do with the light was checked there. The 14-byte Bluetooth packet was read back with the web app's own code.
- Not checked: nothing here has run on real hardware yet. The pin orders in the drawings come from published pinouts, not from your boards, the battery circuit has not been built, and the printed circuit board has not been made.
So follow the stages in order, and trust the labels printed on your own boards over any drawing.
Versions
0.2.0, 2026-10-21. C2, a 220 µF capacitor that steadies the 5V line, added to both zero PCB layouts and the full circuit. A proposed impact sensor: a piezo disc wired without diodes, not yet read by the firmware. The continuity tester also runs on an ESP32 DevKit. The phone app moved to mobile_app_swing.
0.1.0, 2026-10-17. First version: the circuit, nine stages, the guides as PDF, the one-file firmware and the layout without the diode.
Parts
| Part | Notes |
|---|---|
| ESP32-C3 Super Mini | The small board with a USB-C socket and eight pins on each side. |
| GY-BMI160 | The motion sensor board: acceleration and rotation on three axes each. |
| LiPo cell, 3.7 V, 1500 mAh | One cell with two leads. Buy one with a built-in protection board, which is the usual kind. |
| TP4056 charger module with protection | The version with six pads: IN+ IN- B+ B- OUT+ OUT-. See the question about the charger. |
| Slide switch | Three pins in a row, 2.54 mm apart, for example the SS12D00. |
| Diode 1N5817 | A Schottky diode. A 1N5819 also works and loses a little more voltage. |
| Zero PCB | At least 20 by 16 holes. The common 5 by 7 cm board is big enough. |
| Female header strips | Two with 8 pins, one with 7. With them the two boards can be unplugged. |
| Insulated hook-up wire | Thin single-strand wire. |
| USB-C cable that carries data | Charge-only cables give no serial port. |
| Phone charger, 5 V and 1 A or more | To charge the cell through the TP4056. |
| Only for stage 7 | Two 100 kilohm resistors and one 100 nanofarad ceramic capacitor. |
Tools: a soldering iron and solder, a multimeter, wire cutters, insulating tape or heat-shrink tube, and double-sided foam tape for mounting.
docs/parts-to-buy.pdf is the shopping list: the exact name to search for, how many, and what to check before paying.
Before you touch the battery
A LiPo cell stores a lot of energy and can catch fire when it is mistreated.
- Never let the red and the black lead touch. Cut and solder them one at a time, never both together.
- Check which lead is plus with a multimeter before soldering. Red is normally plus, but plugs are wired both ways.
- Charge it only through the TP4056, on a surface that cannot burn, and not unattended.
- Do not use a cell that is swollen, dented or punctured.
- Protect it on the bat. Mount it away from where the ball hits, with foam under it.
The stages
Do them in order. Each folder under stages/ holds one sketch and a page, README.pdf, with the steps. The links in the table open those pages.
| Stage | What you add | What you learn | It works when |
|---|---|---|---|
| 1. Blink | The ESP32 board and a USB cable | Uploading, the Serial Monitor, outputs and inputs | The light blinks and lines appear |
| 2. I2C scan | The sensor, on five wires | What I2C is, and addresses | It prints RESULT: PASS |
| 3. Read the sensor | Nothing | Registers, bytes, counts and units | Four checks pass and z reads 1 g |
| 4. Swing speed | Nothing | Calibration, and the speed formula | A swing prints a speed |
| 5. Bluetooth | Nothing | Advertising, connecting, notifications, the packet | The test page shows 50 readings a second |
| 6. Battery | Cell, charger, switch, diode | Where the power flows, charging, brownouts | It runs with no cable and counts no brownouts |
| 7. Battery level | Optional: two resistors, one capacitor | Measuring a voltage | The printed voltage matches a multimeter |
| 8. The bat firmware | Nothing | How it all fits together | The dashboard records a shot |
| 9. WiFi | Optional: nothing | WiFi, HTTP and JSON | The API lists the bat as online |
Stages 1 to 5 run from the USB cable. The battery comes in at stage 6, when everything else is known to work.
The whole circuit
| From | To | What it carries | Added in |
|---|---|---|---|
3V3 | VIN of the sensor | Power for the sensor, 3.3 volts | Stage 2 |
GND | GND of the sensor | Ground | Stage 2 |
GPIO4 | SCL | I2C clock | Stage 2 |
GPIO3 | SDA | I2C data | Stage 2 |
SAO of the sensor | GND | Fixes the sensor's address at 0x68 | Stage 2 |
| Cell, red lead | B+ of the charger | Battery plus | Stage 6 |
| Cell, black lead | B- of the charger | Battery minus | Stage 6 |
OUT+ of the charger | Switch, an end pin | Battery plus, protected | Stage 6 |
| Switch, middle pin | Diode, plain end | Battery plus, switched | Stage 6 |
| Diode, striped end | 5V | Power into the ESP32 board | Stage 6 |
OUT- of the charger | GND | Ground | Stage 6 |
| Switch, middle pin | R1 | Battery plus, switched | Stage 7 |
GPIO0 | middle of R1 and R2 | Half the battery voltage. C1 goes from here to ground. | Stage 7 |
| R2, other end | GND | Ground | Stage 7 |
Leave the sensor's 3V3, CS, INT1, INT2 and OCS pins unconnected.
More drawings:
- What each pin of the ESP32 is used for
- The sensor on five wires
- Where the power flows
- Measuring the battery
- Zero PCB layout, hole by hole, with the steps in docs/build-on-zero-pcb.pdf
- The same layout without the diode, with a wire in its place
- The printed circuit board, designed in KiCad: the schematic, the parts side and the solder side, with ordering and soldering steps in docs/order-the-pcb.pdf. No board has been made yet.

- Impact sensor, a proposal: a piezo disc on the blade, wired without diodes. The firmware does not read it yet.
Is the TP4056 the right charger?
Yes. The chip is called TP4056. There is no common charger called TP4050, so that is almost certainly the module you have.
- What it does. It charges one LiPo cell from 5 volts. It holds the current steady until the cell reaches 4.2 volts, then holds 4.2 volts until the current has dropped to a tenth, and then stops.
- Get the version with protection. It has six pads instead of four, and two extra small chips. They disconnect the cell when it is drained below about 2.4 volts, charged above about 4.3 volts, or shorted.
- The charging current is 1 amp as sold. That suits a 1500 mAh cell: cells are normally charged at up to their capacity per hour, which here is 1.5 amps. A full charge takes about two hours. To charge more gently, see docs/make-changes.pdf.
- The ESP32-C3 Super Mini has no charger of its own, which is why this module is needed.
- It is not a switch and not a regulator. The slide switch turns the bat off. The regulator on the ESP32 board makes the 3.3 volts.
Set up the Arduino IDE
- Install the Arduino IDE, version 2, from arduino.cc.
- Add the ESP32 boards: Tools > Board > Boards Manager, search for
esp32, and install "esp32 by Espressif Systems". This kit was compiled with version 3.3.11. - Choose the board: Tools > Board > esp32 > Nologo ESP32C3 Super Mini.
- Choose the port: Tools > Port, the one that appears when the board is plugged in. On a Mac its name starts with
/dev/cu.usbmodem. - Open a sketch with File > Open and pick the
.inofile inside a stage folder. - Upload, then open Tools > Serial Monitor and set it to 115200 baud.
No library has to be installed. Everything the sketches need is in their own folders.
If an upload cannot connect: hold the BOOT button, press and release RESET, release BOOT, and upload again. Press RESET once afterwards to start the sketch.
How it works, and how to change it
- docs/parts-to-buy.pdf is the shopping list.
- docs/phone-app.pdf explains the phone app.
- docs/how-it-works.pdf explains the whole chain: what the sensor measures, the I2C conversation, the packet, Bluetooth, the arithmetic of the dashboard, and the power circuit.
- docs/make-changes.pdf says what else has to change when you change a pin, a part, the name, the rate or the battery.
- docs/build-on-zero-pcb.pdf is the soldering guide.
- docs/order-the-pcb.pdf is the same build on a printed circuit board: how to order it and solder it.
- docs/troubleshooting.pdf lists what can go wrong, by what you see.
What is in this folder
| Path | What it is |
|---|---|
stages/01_blink to stages/09_wifi_to_api | One Arduino sketch per stage, each with its own page, README.pdf. |
stages/08_sswingg_bat/ | The firmware that stays on the bat. Its settings are in config.h. |
app/ | The same recorder as a web page. recorder.js holds its logic, which tools/check.mjs tests. |
sswingg_bat_one_file/ | The same firmware as one file, for opening or pasting into the Arduino IDE on its own. tools/make_one_file.mjs makes it from stage 8. |
stages/*/bmi160.h | The sensor driver. The same file in three folders, because the Arduino IDE only compiles files inside a sketch's own folder. |
stages/*/swing_packet.h | Builds the 14-byte packet. This is the agreement with the web app. |
stages/*/battery.h | Battery voltage to percent. |
diagrams/ | Every drawing as SVG, and make_diagrams.py, which draws them. |
docs/ | The seven guides listed above, as PDF. |
pcb/ | The printed circuit board as a KiCad 10 project, sswingg-bat.kicad_pro, with its own library of the kit's parts. sswingg-bat-gerbers.zip is what you upload to a maker, bom.csv the parts list. |
tools/make_pcb_files.mjs | Runs KiCad's checks on the board and makes the Gerber zip, the parts list and the board drawings from the KiCad design. Needs KiCad. |
diagrams/diagrams.pdf | All drawings in one file, one per page, for printing. |
tools/ble_test.html | A page that connects to the bat from a browser and shows what it sends. |
tools/check.mjs | Checks the whole kit without hardware. |
tools/make_pdfs.mjs | Makes the PDFs from their Markdown sources. Those sources are kept out of the repository. This README is the only Markdown document in it. |
tools/sim/ | The simulator that check.mjs uses to run the sketches on a computer. |
Check the kit without hardware
After changing a sketch, a pin or a drawing, run:
node tools/check.mjs # under a minute
node tools/check.mjs --board # also compiles every sketch for the ESP32-C3, several minutesIt needs Node 22 or newer and a C++ compiler. It confirms that the copies of the shared files are identical, that every sketch, the drawings and this README use the same pins, that the packet is what the web app expects, and that every sketch behaves as its stage describes when run in the simulator. When KiCad is installed, it also runs KiCad's checks on the PCB and confirms that its schematic is the circuit of the drawings. It cannot check soldering, radio range or a real battery.
You can also run a single sketch in the simulator and watch what it prints:
tools/sim/run.sh stages/04_swing_speed "swing@3000:400:900:1,end@6000"The words of the scenario are listed at the top of tools/sim/sim_main.cpp.
The phone app
mobile_app_swing holds SSwinGG recorder, an Android app written in Flutter, in its own repository. It connects to the bat, records each shot between Start and Stop, guesses the type of shot, and saves every reading as a CSV file in a folder per type, named like pull_shot/pull_shot_001.csv. Its README says how to build and install it.
app/ is the same recorder as a web page for Chrome on Android, for phones where installing an app is not wanted. docs/phone-app.pdf explains it.
Using it with the dashboard
- Open the SSwinGG dashboard in Chrome or Edge and sign in. The web app is in the Cric-Pro-FE repository.
- Switch the bat on and wait for the slow blink.
- Press Connect Sensor and choose
SwingLab-Bat. - Press START SHOT, swing, then press STOP & SAVE SHOT. The dashboard reads the sensor only between those two presses.
Only one program can be connected to the bat at a time. Close the test page first.
Parts
13| Qty | Value | Footprint | References |
|---|---|---|---|
| 3 | M2 | MountingHole:MountingHole_2.2mm_M2 | H1, H2, H3 |
| 2 | 100k 1% | Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal | R1, R2 |
| 1 | 100nF | Capacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mm | C1 |
| 1 | 1N5817 | Diode_THT:D_DO-41_SOD81_P10.16mm_Horizontal | D1 |
| 1 | 220uF 10V | Capacitor_THT:CP_Radial_D6.3mm_P2.50mm | C2 |
| 1 | Battery | Connector_JST:JST_PH_B2B-PH-K_1x02_P2.00mm_Vertical | J1 |
| 1 | ESP32-C3 Super Mini | sswingg:ESP32-C3_SuperMini_Socket | U1 |
| 1 | GY-BMI160 | sswingg:GY-BMI160_Socket | U2 |
| 1 | SS12D00G3 | sswingg:SW_Slide_SS12D00G3 | SW1 |
| 1 | TP4056 module | sswingg:TP4056_Module_Wired | U3 |
Similar boards
- 2 layers40 × 20 mm

- 2 layers74.9 × 49.5 mm

- 2 layers35 × 29 mm

MagSpoofTC
samyk/magspoof
A portable device that can spoof/emulate any magnetic stripe, credit card or hotel card "wirelessly", even on standard magstripe (non-NFC/RFID) readers.
13 parts4.2k - 2 layers20.6 × 23.6 mm

AO-03 signal amplifier
fossasia/pslab-scripts
Pocket Science Lab - Scripts for Sensor Experiments
13 parts1.6kApache-2.0 - 2 layers47 × 35.6 mm

- 2 layers95 × 95 mm

Cube batteryboard
willem-pennings/balancing-cube
A cube that balances itself in a corner or edge using reaction wheels
13 parts1.1kGPL-3.0 - 2 layers15.2 × 20.3 mm

Pt100stick
VoronDesign/Voron-Hardware
Cool Hardware designed by the Voron Design group
13 parts1.1kGPL-3.0 - 2 layers53.9 × 23.2 mm

Buffer
hoglet67/RGBtoHDMI
Bare-metal Raspberry Pi project that provides pixel-perfect sampling of Retro Computer RGB/YUV video and conversion to HDMI
13 parts1kGPL-3.0
Questions
How big is the Sswingg bat PCB?
It measures 48.3 × 60 mm and has 2 copper layers, 1.6 mm thick.
What parts does the Sswingg bat use?
13 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
Where can I download the Sswingg bat KiCad files?
From the gaurav3611/Cric-Pro-Hardware repository on GitHub, at the commit this page was made from: the board is pcb/sswingg-bat.kicad_pcb and its schematic pcb/sswingg-bat.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Can I use the Sswingg bat design in my own project?
Its repository states no licence, so its author keeps all rights: ask gaurav3611 before reusing the design.