Arduino Nano 33 IoT - Force Sensor

The force sensor is also known as the force sensitive resistor or FSR. This tutorial explains how to use the Arduino Nano 33 IoT with the force sensor. We will learn the following steps:

Arduino Nano 33 IoT FSR402 Force Sensor

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×Force Sensor
1×10 kΩ resistor
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of Force Sensor

A force sensor is a resistor that changes its resistance when force is applied. The harder you press it, the lower its resistance becomes. Force sensors work well for detecting squeezes or pressure, but they are not suitable for measuring weight.

Force Sensor Pinout

A force sensor has two pins. Like a resistor, you don't need to worry about which pin is which.

Force sensor pinout

Wiring Diagram between Force Sensor and Arduino Nano 33 IoT

The wiring diagram between Arduino Nano and 33 IoT Force

This image is created using Fritzing. Click to enlarge image

※ NOTE THAT:

Please note that the Arduino Nano 33 IoT pins A4 and A5 have built-in pull-up resistors for I2C communication. This can affect analog readings, so it is recommended to avoid using these pins with any devices/sensors that relies on ADC.

How To Program Force Sensor

The resistance changes along with the voltage. We can use the Arduino Nano 33 IoT’s analog input pin to check the voltage.

Connect one of the force sensor's wires to an analog input pin. This lets you measure a reading that turns into voltage, then resistance, and finally force. Keep in mind, these values are relative.

Arduino Nano 33 IoT Code

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-force-sensor */ #define FORCE_SENSOR_PIN A0 // The Arduino Nano 33 IoT pin connected to the force reistor void setup() { Serial.begin(9600); } void loop() { int analogReading = analogRead(FORCE_SENSOR_PIN); Serial.print("The force sensor value = "); Serial.print(analogReading); // print the raw analog reading if (analogReading < 10) // from 0 to 9 Serial.println(" -> no pressure"); else if (analogReading < 200) // from 10 to 199 Serial.println(" -> light touch"); else if (analogReading < 500) // from 200 to 499 Serial.println(" -> light squeeze"); else if (analogReading < 800) // from 500 to 799 Serial.println(" -> medium squeeze"); else // from 800 to 1023 Serial.println(" -> big squeeze"); delay(1000); }

Detailed Instructions

If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:

  • Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
  • Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
  • Launch the Arduino IDE on your computer.
  • Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
  • Copy the code above and paste it into the Arduino IDE.
  • Click the Upload button to compile and load the code onto your Arduino Nano 33 IoT board.
  • Press the force sensor.
  • Look at the Serial Monitor to see the result, which will look like the example shown below.
COM6
Send
The force sensor value = 0 -> no pressure The force sensor value = 0 -> no pressure The force sensor value = 132 -> light touch The force sensor value = 147 -> light touch The force sensor value = 394 -> light squeeze The force sensor value = 421 -> light squeeze The force sensor value = 607 -> medium squeeze The force sensor value = 791 -> medium squeeze The force sensor value = 921 -> big squeeze The force sensor value = 987 -> big squeeze The force sensor value = 0 -> no pressure The force sensor value = 0 -> no pressure
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Video Tutorial

Learn More

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!