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.
– 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
|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|
This example needs the Adafruit IO python library installed – https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black
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)
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>
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
After running you should see something like this.
debian@beaglebone:/var/lib/cloud9/iain$ sudo python fsr.py
[sudo] password for debian:
The increase in values is me pressing the force sensitive resistor harder and harder.