Advertisement
arduino fsr connection

Arduino FSR Experiment and a Garbage Bin

Integral to process control in many industries, level measurement sensors fall into two main types. Point level measurement sensors are used to mark a single discrete height (a preset level condition). Generally, this type of sensor functions as a high alarm, signaling an overfill condition, or as a marker for a low alarm condition. Continuous level sensors are more sophisticated and can provide level monitoring of an entire system. They measure level within a range, rather than at a one point, producing an analog output that directly correlates to the level in the container. To create a level management system, the output signal is linked to a process control loop and to a visual indicator.

Here is an introduction to level measurement using Arduino microcontroller. Why again Arduino? Obviously, with programming options, serial communications capability, flexible calibration, and efficient processing, Arduino offers reliable level measurements in distinct ways. The example project Arduino Bin Level Sensor presented here incorporates a simpe force sensitive resistor (FSR) for monitoring common bins with solids and some liquids whether conductive or nonconductive. We chose to ramp up a miniature working model of an ultra-simple pressure sensitive bin because it was most useful for our experiments, and we could imagine using it in everyday life for a number of dissimilar applications. The experiment uses only one force sensitive resistor to monitor the bin, and colored indicators to notify the user how much he/she have filled the bin.

The FSR

An FSR is just what it sounds like – a sensitive resistor that changes its resistance with applied force. So if you press it, its resistance changes. Since the FSR changes its resistance with force, ranges from near infinite when not being touched, to below 300-Ohms when pressed really hard, we can measure that change using one of the Arduino’s analog inputs. The analog input on your arduino will read “1023” at 5V (its max), and “0” at 0V (its min). So we can measure how much voltage is on the FSR using the analogRead and we will have our force reading.

fsr sensor

Experiment Setup

In the experiment, FSR was attached at the bottom of a small plastic bin with a piece of round –shaped cardboard (at the size of the sensor head) to apply pressure directly to the force sensing resistor. Next, the bin was placed on a small and flat woodblock as a support between the bottom of the bin and the top of the base. Finally, syrofoam was used to bridge the narrow gap between them so that the pressure from the bin was unifromly applied on the FSR.

arduino garbage bin experiment

Arduino Hookup

Only a voltage-divider is needed here to interface the FSR to Arduino. One branch of the proposed voltage-divider is the FSR itself, and the other is a fixed resistor with a value of 10K-Ohm (1%). See the hookup illustration shown here:

fsr arduino connection

Next, connect three LEDs and related components are shown in this wiring diagram:

arduino leds connection

The Arduino Sketch

In our experiment with some solid objects filled in the bin, we observed a reading on the Arduino between 512 (bin empty) and 716 (bin full). Arduino skecth (the code) prepared on this basis is shown below.

const int ledBlue = 2; // Level Medium
const int ledRed = 4; // Level Full
const int ledGreen = 7; // Level Min
int fsrPin = 0; // FSR and 10K pulldown are connected to A0
int fsrReading; // Analog reading from the Voltage-Divider
void setup(void) {
   // Debugging information via the Serial monitor
   Serial.begin(9600);
   pinMode(ledRed, OUTPUT);
   pinMode(ledBlue, OUTPUT);
   pinMode(ledGreen, OUTPUT);
}
void loop(void) {
   fsrReading = analogRead(fsrPin); // see fsrReading maths
   if (fsrReading <=512) {
      digitalWrite(ledRed, LOW);
      digitalWrite(ledGreen, LOW);
      digitalWrite(ledBlue, LOW);
   }
   if (fsrReading > 512 && fsrReading <= 600) {
      digitalWrite(ledRed, LOW);
      digitalWrite(ledGreen, HIGH);
      digitalWrite(ledBlue, LOW);
   }
   if (fsrReading > 600 && fsrReading <= 680) {
      digitalWrite(ledRed, LOW);
      digitalWrite(ledGreen, LOW);
      digitalWrite(ledBlue, HIGH);
   }
   if (fsrReading > 680) {
      digitalWrite(ledRed, HIGH);
      digitalWrite(ledGreen, LOW);
      digitalWrite(ledBlue, LOW);
   }
   Serial.print("Analog reading = ");
   Serial.println(fsrReading); // Raw analog reading
   delay(250); // Slow down the output for easier reading
}

(fsrReading) Maths

In the above code we are using “fsrReading” values like 512,600,680,etc. Obviously these values in your experiment might vary. How to add appropriate values in your own skecth? It is very simple; measure the dc voltages at A0 of your Arduino setup when bin level is minimum, medium, and full using a DMM, and make analog reading values using the formula “1024/5 x V”. For example, if you get 2V when the bin level is minimum then corresponding fsr value to be added in the sketch is 1024/5 x 2 = 409.6 (~ 410)!

Notes
The information contained in this article is prepared to provide general ideas and guidelines for experiments only and must not be treated as a full-fledged project for real-world application.

Always use a firm, flat and smooth mounting surface for the FSR. Do not apply excessive shear force. Note that, force sensitivity of a typical FSR lies in the <100g to >10kg range, dependent on mechanics

In India, FSRs are retailed by many online component vendors like RhydoLabz. Here is an eBay India link.

7 Comments

Join the conversation!

Error! Please fill all fields.
  • Sol

    Hey,sorry, I don’t have this code anymore. It was just a short test drive.I used the Hiduino FW + miefiodd Example Sketch, MIDI Library 4051 Mulitplexersketch.Take the incoming Multiplexer Values, define them as CC Messages and drop them out via USB. I uploaded an old sketch. I hope, this will help you.regardsPaul

  • Ramesh

    Sir ,
    It is very usefull project with new confept.
    Ramesh

  • Martin

    This is just the thing I was looking for as I have several rain barrels that catch and store rain water from my house roof. I have an arduino uno and wanted a method to see remotely how much water was in each barrel. If the barrel is full then I need to stop the rain water from going into it so it does not overflow near my house foundation walls. Also, When it is raining I will now be able to monitor as the barrel fills up.

    Thank you very much for your technical write up. I will definitely put it to good use.

    • T.K.Hareendran

      @Martin: Thanks again for your attention, and keen interest!

    • Martin

      …the problem I had when using metal probes in water to sense the water level is that they eventual get coated with residue or corrode and no longer sense properly. The FRS is the better approach since it is not in contact with the water and subject to corrosion and therefore should be able to sense, albeit indirectly, the water level via the weight of the barrel – Great idea, thanks for sharing your article.

    • T.K.Hareendran

      @Martin: Thank you very much for your sincere feedback. Wish you a nice DIY experience…

Looking for the latest from TI?