Intro: Arduino Pressure Sensor (FSR) With LCD Display
This instructable will (hopefully) demonstrate how to construct an Arduino-based pressure sensor that displays the measured pressure on a small LCD screen. I incorporated elements, both hardware and software, from various sources (I will provide references at the relevant junctures- I hope I don't leave anyone out). All of the parts used came from the Sparkfun Inventor's Kit V3.2, a.k.a. my long awaited, somewhat delayed Christmas present from my folks.
Since this is my first crack at Arduino and electronics, I expect that I've goofed up on some elements of this project. Please advise me on how to rectify, improve, streamline, etc. etc.
Step 1: Parts List
- 1x Arduino Uno (or Sparkfun Reboard)
- 1x breadboard
- 1x LCD (16x2)
- 1x potentiometer (little blue twisty knob)
- 1x 10K ohm resistor
- 1x small square of capacitive foam (from IC packaging)
- 19x jumper wires (or regular wires)
- 1x power supply/USB cable
- 1x computer with Arduino IDE
As I mentioned in the intro, I got all of these parts in the Sparkfun SIK. I'm sure it's less expensive to buy them individually, but I went for the kit.
Step 2: Build the Force Sensitive Resistor (FSR)
My FSR was constructed following the directions of this brilliant instructable by hiskeyd.
Take the square of conductive foam (the integrated circuit comes poked into the foam) and poke two wires into the side. I poked them in about one cm apart.
That's pretty much all there is to it. A little tape might help the wires stay in the foam better, but it doesn't seem to be absolutely necessary.
hiskeyd's instructable suggests using a multimeter to test the resulting resistor. Set the multimeter to 20K ohms, touch one lead to the non-foam end of each of the wires, and squeeze the foam. The multimeter should spike briefly.
Step 3: Wire Everything Up
Note: the image shows a commercial FSR. the Fritzing program doesn't seem to have an icon for "chunk of foam".
I have the gizmo set up as follows:
The LCD is plugged into breadboard column J, from rows 15-30. The potentiometer (for LCD contrast) is column E, rows 7-9. The FSR is columns B,D,E, row 1. The Arduino 5V and GND pins attach to the breadboard 5V and GND columns.
Attach Arduino pins to breadboard coordinates:
2 to F17, 3 to F18, 4 to F19, 5 to F20, 11 to F25, 12 to F27
Attach 5V/grounds on the breadboard:
5V: F29, F16
GND: F30, F26, F15
Connect the LCD to the central potentiometer pin on the breadboard: F28 to B8
B7=5V, B8=LCD, B9=GND,
One wire goes to the 5V
The other connects to E1
D1 connects to pin A0 on the Arduino. This is the analog input that the Arduino reads.
A 10K ohm resistor (brown, black, orange, gold) connects B1 to GND.
With a minor adjustment to the code, one can just read the FSR values in the Arduino serial window. In that case, none of the LCD/potentiometer stuff is needed.
Step 4: Code
I borrowed pretty much the all of the code from these sources:
the Adafruit "FSR simple testing sketch" (link)
the Sparkfun LCD sketch (link)
the Arduino calibration instruction page (Link)
and then I tweaked it a bit in order to combine the elements I wanted.
Right now, it measures the pressure every quarter second. Change the value in line #51 to adjust the timing. I have the pressure displayed on an arbitrary 0-10 scale (change lines 43 and 45 to adjust). I think that it could ultimately be calibrated to display a relatively accurate pressure in kg or lbs, but this is good enough for the time being.
Code is in the attached file.
Step 5: Use It
1) Upload the sketch to the Arduino.
Note: I unplug the 5V connector from the 5V Arduino pin to the breadboard while uploading. My laptop has abruptly reset itself with the circuit plugged in, which makes me think that something isn't quite right somewhere in my circuit. Don't break your computer.
2) Unplug the Arduino from the USB, attach the 5V, and plug in the DC adapter.
3) Once the Arduino is powered up, you've got 5 seconds to calibrate the FSR. Starting from not touching the FSR, push on it, exerting a bit more force than you expect to measure, and then release. I have no idea what the operating limits of a bit of foam with wires poked in is, so do some experimenting.
4) Use it. Press, squeeze, tap, or otherwise touch the foam square, and marvel as the LCD tells you how hard (on a scale of 0-10) you are pressing.
That's it. I hope someone finds this useful If anyone has any advice or ideas for improvement, please comment.