ESP32 - Force Sensor
The force sensor is called force sensitive resistor, the force sensing resistor, or FSR. This tutorial instructs you how to use ESP32 with the force sensor. In detail, we will learn:
- How the force sensor works.
- How to connect the force sensor to ESP32.
- How to program for ESP32 to read value from a force sensor.
Hardware Used In This Tutorial
|1||×||ESP-WROOM-32 Dev Module|
|1||×||USB Cable Type-C|
|1||×||10 kΩ resistor|
|1||×||(Optional) DC Power Jack|
|1||×||(Recommended) ESP32 Screw Terminal Adapter|
Or you can buy the following sensor kit:
|1||×||DIYables Sensor Kit 30 types, 69 units|
Introduction to Force Sensor
A force sensor is a resistor that its resistance is in inverse proportion to how much force it is given. The more force gives to the sensor, the smaller the sensor's resistance is. The force sensor is good for application that detects physical squeeze, pressure. However, it is not good for the application that finds how many pounds of weight
Force Sensor Pinout
A force sensor has two pins. Just like a resistor, we do NOT need to differentiate these pins.
Wiring Diagram between Force Sensor and ESP32
This image is created using Fritzing. Click to enlarge image
If you're unfamiliar with how to supply power to the ESP32 and other components, you can find guidance in the following tutorial: How to Power ESP32.
How To Program Force Sensor
The resistance is in proportion to voltage. We can use the ESP32's analog input pin to measure voltage.
By connecting a pin of the force sensor to an analog input pin, we can read the analog value from the pin ⇒ voltage ⇒ resistance ⇒ force (all í in relative value)
- If this is the first time you use ESP32, see how to setup environment for ESP32 on Arduino IDE.
- Copy the above code and paste it to Arduino IDE.
- Compile and upload code to ESP32 board by clicking Upload button on Arduino IDE
- Press the force sensor
- See the result on Serial Monitor. It looks like the below:.
Making video is a time-consuming work. If the video tutorial is necessary for your learning, please let us know by subscribing to our YouTube channel , If the demand for video is high, we will make the video tutorial.