VCC sets the voltage
While the spring touches its rod, the switch connects SIGNAL straight to VCC, so the voltage on VCC is the voltage your pin receives. Beside an ESP32, an ESP32-S3 or a Pico that has to be 3V3. Beside an Uno, 5V. Getting this wrong is the one way this block can damage a board.
Nothing between VCC and your pin
When the spring touches the rod, it joins the switch's two legs, which on this board are VCC and SIGNAL. Nothing on the block changes the level on the way through: no resistor, no diode. So during a touch, SIGNAL is VCC. Put 5 V on VCC and your pin gets 5 V. Put 3.3 V on it and your pin gets 3.3 V.
3V3 beside a 3.3 V board
An ESP32, an ESP32-S3 and a Raspberry Pi Pico run their pins at 3.3 V, and none of them is built to take 5 V. Pick 5V in the figure with one of them selected: it reads HIGH, the knock sensor works, and the pin is past its rating several times on every knock. That damage is slow and it does not announce itself, which is why the wiring is the rule rather than a suggestion.
Connect VCC to the board's 3V3 pin. The block works exactly the same from it. Only the red LED is dimmer, and the capacitor takes a little longer to fall below the LOW line, as the last article showed.
5V beside an Uno
The Uno's pins run at 5 V, so its 5V pin is the right supply. 3V3 would work too, since the ATmega328P reads anything above 3.0 V as HIGH, but that leaves 0.3 V of margin to gain nothing.
VCC left off
With VCC unconnected, the switch has nothing to join SIGNAL to. Knock as hard as you like: the pull-down holds SIGNAL at 0 V and your pin reads LOW. The red LED does not flash either, which is the quickest way to tell this apart from a sketch problem.
When it does not work
No. During every touch, SIGNAL carries whatever is on VCC to your pin, and the ESP32's pins are built for 3.3 V. It will seem to work, which is the problem: the pin is past its rating several times per knock. Connect VCC to 3V3. The block works just as well from it.
It will read HIGH. The ATmega328P treats anything above 0.6 of its 5 V supply, 3.0 V, as HIGH, so 3.3 V clears it by 0.3 V, and the capacitor's tail drops below that sooner. That is a thin margin for no benefit. Use the Uno's 5V pin, and the red LED is brighter too.
That is what should happen. The switch has nothing to connect SIGNAL to, so the pull-down holds it at 0 V however hard you knock, and the red LED never flashes. Connect VCC and it works.
Only if it is at your board's logic voltage and shares its GND. VCC is not so much a power input for the block as the level it hands back to your pin, so the simplest and safest source is the board's own 3V3 or 5V pin. The block draws under 4 mA, and only during a touch.
Edit this page — content/books/knock-sensor/vcc-sets-the-voltage.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Knock Sensor
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.