In this article we look at a Force Sensitive Resistor connected to a Beaglebone first of all lets look at the FSR.
FSRs are basically a resistor that changes its resistive value (in ohms Ω) depending on how much it is pressed. The FSR is made of 2 layers separated by a spacer. The more one presses, the more of those Active Element dots touch the semiconductor and that makes the resistance go down.
Features:
– No load resistance: >1000kOhm
– Load resistance: <1kOhm @50N
– Working Voltage VCC: 5.5 VDC(MAX)
– Working Current: 5 mA(MAX)
– Pressure Scale: 0-50N
– Response time: < 10ms
– Recovery Time: < 40ms
– Sensing area diameter: 9mm
– Total length: 40mm
Now the Beaglebone only supports 1.8v input as a maximum on the ADC pins, this is not a problem in this case as we are using the 1.8v reference from VDD_ADC on P9_32 and we will use one of the AIN pins.
You can see this in the image below on the P9 header
The concept is straightforward you use a resistor network as voltage dividers, and then let each button feed a different voltage to the analog pin. So by detecting the voltage you can tell which button has been pressed. You can only detect one button at a time
Parts Required
Name | Link |
Beaglebone | BeagleBone Black TI AM3358 Cortex-A8 development BB-Black Rev.C |
Force Sensitive Resistor | Round Film Force Sensitive Resistor 50N/5kg FSR Pressure Sensor |
Connecting wire | Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire |
Schematic/Connection
Code Example
This example needs the Adafruit IO python library installed – https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black
[codesyntax lang=”python”]
import Adafruit_BBIO.ADC as ADC import time sensor_pin = 'P9_40' ADC.setup() print('Reading\t\tVolts') while True: reading = ADC.read(sensor_pin) volts = reading * 1.800 print('%f\t%f' % (reading, volts)) time.sleep(1)
[/codesyntax]
Save this as fsr.py, I used the Cloud 9 IDE
Now for a gotcha, if you click on the Run button you will see something like this
Traceback (most recent call last):
File “/var/lib/cloud9/iain/fsr.py”, line 6, in <module>
ADC.setup()
RuntimeError: Unable to setup ADC system. Possible causes are:
– A cape with a conflicting pin mapping is loaded
– A device tree object is loaded that uses the same name for a fragment: helper
You need to run the python script using administrator privileges, open a terminal and enter the following
sudo python fsr.py
Output
After running you should see something like this.
debian@beaglebone:/var/lib/cloud9/iain$ sudo python fsr.py
[sudo] password for debian:
Reading Volts
0.000488 0.000879
0.003663 0.006593
0.508913 0.916044
0.524542 0.944176
0.545055 0.981099
0.557753 1.003956
0.488889 0.880000
0.000488 0.000879
0.000244 0.000440
The increase in values is me pressing the force sensitive resistor harder and harder.