How To Connect A Force Sensor To Arduino - An Introduction For Beginners

Поделиться
HTML-код
  • Опубликовано: 9 сен 2024

Комментарии • 30

  • @Gowtham-yt9iw
    @Gowtham-yt9iw Год назад +1

    Bro I didn't got the code but somehow I managed thanks for the video it helped for my college project work thank you so much be happy

    • @BMonsterLaboratory
      @BMonsterLaboratory  Год назад

      Congrats on your project! Thanks for taking time to watch the video and leave a mssg! Take care 👍

    • @michaelmassajr.9996
      @michaelmassajr.9996 Год назад +1

      Hey nice. I'm gonna use this for my senior design this semester too (credit included to here!). Didn't expect comments to be active on this vid

    • @BMonsterLaboratory
      @BMonsterLaboratory  Год назад

      Thanks! I appreciate it. Good luck with your design 👊👊

  • @katebenfield8481
    @katebenfield8481 Год назад +2

    Did you calculate the force from your resistance output values? It would be nice to see what the force is rather than the output being "Light, Medium, Big". If so, how close were they to actual values? Thanks! Great video :)

    • @BMonsterLaboratory
      @BMonsterLaboratory  Год назад

      hi there! The sensor's resistance is read using the analogRead() function, which returns a value between 0 and 1023, corresponding to the voltage level at the analog pin. The SensorRead value is compared against different thresholds, and the LEDs are lit up in response to the different force levels.
      The Arduino represents the sensor reading as a number between 0 (no pressure) and 1023 (maximum pressure). We should be able to map this range (0-1023) to the force range (1/16 lbs - 22 lbs) for this sensor. The value displayed on your LCD would be approximate and you would have to calibrate it depending on your project setup. I can make a video for this.... no problem. sorry about the delayed response.
      I wanted to update this answer. I was able to display force in pounds and after calibrating the sensor, it did a pretty good job. There is some sensor drift over time where you'll see the values change. So, you can get a readout in lbs, but it's not ideal. Also, Sparkfun has a great tutorial and code example for Force and Resistance data using a sensor similar to this. check it out here learn.sparkfun.com/tutorials/force-sensitive-resistor-hookup-guide?_gl=1*7fadl3*_ga*NDE5NjE2NTQ2LjE2Nzc3Mjc2NzE.*_ga_T369JS7J9N*MTY5MDQwNzQ1NS40LjEuMTY5MDQwNzQ2OC40Ny4wLjA.&_ga=2.11488948.1420561945.1690407456-419616546.1677727671
      If you want better accuracy, check out some load cell sensors. More expensive, but more accurate and repeatable results.. hope this helped.

    • @katebenfield8481
      @katebenfield8481 Год назад +1

      @@BMonsterLaboratory Thank you for the reply! The link provide is very interesting I will need to look into it more for my application! Would you be able to provide the code for the calibration? I am curious how you did it. Thanks!

    • @BMonsterLaboratory
      @BMonsterLaboratory  Год назад

      Sure! This code reads the force sensor that's connected to analog pin A0, converts the sensor reading to force in lbs using the calibration factor and offset, and displays the sensor reading and the calculated force on the I2C LCD display. When I mapped force to lbs I looked at the reading when there was no load vs when there was a known weight of 1lb on the force sensor. When there was no load X1=67 and when there was a known weight of 1lb on the sensor x2=766. X1 and X2 are the raw sensor readings. Then I use the scale factor and offset to convert raw sensor readings to force in lbs. You can see this at the bottom of the loop. You'll see some drifting in the measurements and that's why I said a load cell would be better for this application. There are probably more complex ways to get a better reading... I hope you find this helpful.
      #include
      #include
      #define SensorPin A0
      LiquidCrystal_I2C lcd(0x27, 20, 4); // Set the LCD address to 0x27 for a 20x4 display
      void setup() {
      Wire.begin();
      lcd.begin(20, 4);
      lcd.backlight();
      lcd.setCursor(0, 0);
      lcd.print("Pressure Sensor:");
      Serial.begin(9600);
      }
      void loop() {
      int SensorRead = analogRead(SensorPin);
      float forceInLbs = mapForceToPounds(SensorRead);
      Serial.print("Sensor Reading: ");
      Serial.print(SensorRead);
      Serial.print(" - Force: ");
      Serial.print(forceInLbs);
      Serial.println(" lbs");
      lcd.setCursor(0, 1);
      lcd.print(" "); // Clear line
      lcd.setCursor(0, 1);
      lcd.print("Reading: ");
      lcd.print(SensorRead);
      lcd.setCursor(0, 2);
      lcd.print(" "); // Clear line
      lcd.setCursor(0, 2);
      lcd.print("Force: ");
      lcd.print(forceInLbs, 2); // Print with 2 decimal places
      lcd.print(" lbs");
      delay(200);
      }
      float mapForceToPounds(int SensorRead) {
      // Two points from calibration
      float x1 = 67, y1 = 0; // First point (x1, y1) when no load is applied
      float x2 = 766, y2 = 1; // Second point (x2, y2) when 1lb load is applied
      // Calculate scale and offset
      float scale = (y2 - y1) / (x2 - x1);
      float offset = y1 - scale * x1;
      // Apply scale and offset to the sensor reading
      float forceInLbs = scale * SensorRead + offset;
      return forceInLbs;
      }

  • @user-ov4ye5xq6s
    @user-ov4ye5xq6s Месяц назад +1

    Hi I want to measure heavier force like 20kg, wondering if I can use other sensor RP-S40-ST Thin Film Pressure Sensor , are most of the connection and code be the same?
    :))))))))))

    • @BMonsterLaboratory
      @BMonsterLaboratory  Месяц назад

      Check out Sparkfun list of load cell products. They have great tutorials and usually some code to start you off. www.sparkfun.com/search/results?term=load+cell checkout the hookup guide

  • @user-ov4ye5xq6s
    @user-ov4ye5xq6s Месяц назад +1

    hi I saw that in circuit diagram there is a amplifier, And I dont think you connect one, wonder why?

    • @user-ov4ye5xq6s
      @user-ov4ye5xq6s Месяц назад +1

      Also wondering if you can help me on, is the circuit connection correct using voltage divider like you did? because it is not using the Wheatstone bridge circuit like strain gauge sensor.

    • @BMonsterLaboratory
      @BMonsterLaboratory  Месяц назад

      Hey there! I decided not to use an amplifier with my force sensing resistor because the primary purpose of the video was to detect the presence of force to trigger actions, specifically lighting up LEDs. Since the sensor's resistance change was easily detectable by the Arduino, I didn't include one. I wanted to create a basic project using the force sensor and it worked well.
      The HX711 is pretty popular, perhaps I should get one and try it out. it should improve the accuracy and reliability of force measurements with an Arduino and would come in handy if you need more precision.

    • @BMonsterLaboratory
      @BMonsterLaboratory  Месяц назад

      Force sensing resistrs are resistive sensors that change their resistance based on the force applied to them. As force increases, the resistance decreases. This change in resistance can be easily measured using a voltage divider circuit. Unlike strain gauges or load cells, they use a Wheatstone bridge config to measure small changes in resistance more accurately while force sensing resistors can be used with simpler circuits, usually involving a voltage divider.

  • @shakirzufayri4310
    @shakirzufayri4310 3 месяца назад +1

    Will the sensor pin damage if it touches the solder?

    • @BMonsterLaboratory
      @BMonsterLaboratory  3 месяца назад

      Quickly solder and place wires. May be able to add shrink tubing or light glue coat to make it good stronger. Only solder the metal pads. Maybe tin the contacts before placing 👍

    • @shakirzufayri4310
      @shakirzufayri4310 3 месяца назад

      @@BMonsterLaboratory thanks

  • @carlosmor3254
    @carlosmor3254 Год назад +1

    Great video!
    I assume it's resistive and not capacitive, or is it both?
    On the other hand would it detect a bunch of beach sand?
    Thanks

    • @BMonsterLaboratory
      @BMonsterLaboratory  Год назад

      Hey Carlos, great to hear from you! This is the FSR Model 406 Force Sensor from Interlink Electronics. It's a force-sensing resistor that shows a decrease in resistance when there is an increase in the force applied. It would detect beach sand if it applied between 0.2N to 20N of pressure to the sensor - somewhere between 20 grams and 2kg. I hope that helped! 👍

    • @BMonsterLaboratory
      @BMonsterLaboratory  Год назад

      by the way, here's a link to their website buyinterlinkelectronics.com/ They also sell some sensors on Amazon.

    • @carlosmor3254
      @carlosmor3254 Год назад +1

      @@BMonsterLaboratory Thank you very much

    • @BMonsterLaboratory
      @BMonsterLaboratory  Год назад

      @@carlosmor3254 you're welcome. Take care!

  • @user-dc8sx7br4e
    @user-dc8sx7br4e Год назад +1

    can you please help me with this?
    I have a similar sensor with these features:
    Actuation Force: 0.1 Newtons
    Force Sensitivity Range: 0.1 - 10.02 Newtons
    Non-Actuated Resistance: 10M W
    what should be the resistor values in the voltage divider circuit for the above specifications?

    • @BMonsterLaboratory
      @BMonsterLaboratory  Год назад +1

      Hi Vaishali! Great to hear from you. I can take a look at it. Can you send me the code and the model of sensor you have? If you have found messages over Facebook work well with posting code. Email is fine if that's the only option. Happy to help where I can 👍

    • @user-dc8sx7br4e
      @user-dc8sx7br4e Год назад

      @@BMonsterLaboratory Hi where can I email you at? I'm not on Facebook. Thank you

  • @mehwishismail
    @mehwishismail Год назад +1

    how to connect two FSR to single aurdino

    • @BMonsterLaboratory
      @BMonsterLaboratory  Год назад

      HI there. you could add new integer variables like you did for the first one:
      int SensorPin1 = 0;
      int SensorPin2 = 1;
      int SensorRead1;
      int SensorRead2;
      void setup
      (add your new LEDs here) if you're using new LEDs
      void loop
      (add sensor 2 in the loop with sensor 1)
      SensorRead2 = analogRead(SensorPin2);
      (add some conditional statements like you did for the first sensor)
      if (SensorRead2 < 10) {
      Serial.println(" - No pressure (Sensor 2)");
      } else if (SensorRead2 < 400) {
      digitalWrite(ledPin1, HIGH);
      Serial.println(" - Light pressure (Sensor 2)");
      } else if (SensorRead2 < 750) {
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      Serial.println(" - Light force (Sensor 2)");
      } else if (SensorRead2 < 1000) {
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin3, HIGH);
      Serial.println(" - Medium force (Sensor 2)");
      } else {
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin3, HIGH);
      digitalWrite(ledPin4, HIGH);
      Serial.println(" - Big force (Sensor 2)");
      }
      also, be sure to check the specs on your board so you stay within the current and voltage parameters store-usa.arduino.cc/collections/boards/products/arduino-mega-2560-rev3 👍
      I don't have a 2nd sensor to test the code, but I believe this is what it would look like.

  • @rohitkumarmurmu7654
    @rohitkumarmurmu7654 Год назад +1

    Bro I need code

    • @BMonsterLaboratory
      @BMonsterLaboratory  Год назад +1

      Here a go!
      int SensorPin = 0;
      int SensorRead;
      int ledPin1 = 9;
      int ledPin2 = 10;
      int ledPin3 = 11;
      int ledPin4 = 12;
      void setup(void)
      {
      Serial.begin(9600);
      pinMode(ledPin1, OUTPUT);
      pinMode(ledPin2, OUTPUT);
      pinMode(ledPin3, OUTPUT);
      pinMode(ledPin4, OUTPUT);
      }
      void loop(void) {
      SensorRead = analogRead(SensorPin);
      Serial.print("Pressure Reading is ");
      Serial.print(SensorRead);
      digitalWrite(ledPin1, LOW);
      digitalWrite(ledPin2, LOW);
      digitalWrite(ledPin3, LOW);
      digitalWrite(ledPin4, LOW);
      if (SensorRead < 10) {
      Serial.println(" - No pressure");
      } else if (SensorRead < 400) {
      digitalWrite(ledPin1, HIGH);
      Serial.println(" - Light pressure");
      } else if (SensorRead < 750) {
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      Serial.println(" - Light force");
      } else if (SensorRead < 1000) {
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin3, HIGH);
      Serial.println(" - Medium force");
      } else {
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin3, HIGH);
      digitalWrite(ledPin4, HIGH);
      Serial.println(" - Big force");
      }
      delay(200);
      }

    • @BMonsterLaboratory
      @BMonsterLaboratory  Год назад +1

      most code is posted on Facebook. Just look for # in video description. Hope this helps. Enjoy! 👊👊