Temperature/Force Sensor Sample
This sample uses SPI communication. A temperature/force sensor is connected to a ADC, then ADC is connected to raspberry Pi2 through SPI Pins. Raspberry Pi2 reads the sensor analog input data and output it to the screen. This is basically a simplified version of Potentiometer sensor sample, which has a LED light as an extra output. You can also use a Force sensor in this sample. Try to press the Force sensor gentle or hard to see the data output difference. This sample only has C# version.
Read before start
This sample assumes that RaspBerry has been pre-setted up with below:
- Pi2 has been connected to HDMI monitor
- A SD image card has been plugged to Pi2
- An Ethernet cable has been plugged to Pi2
- Pi2 has been powered on
Parts needed
- 1 MCP3002 I/P ADC Converter
- Or 1 MCP3208 CI/P ADC Converter
- 1 Temperature sensor
- Or 1 Force sensor
- Raspberry Pi2 board
- 1 breadboard and a couple of wires
- HDMI Monitor
Parts Review
- MCP3002
The below lists the pin Layout of MCP3002
, and also it is the A/D converter that we are using in this sample
.
You can also use MCP3208 which are 16 pins. We will list its connections with Raspberry Pi2 as well in later section.
Parts Connection
- Connects the temperature Sensor to MCP3002;
Sensor output pin
(the mid pin) should be connected toCH0
on MCP3002;
If you are using a Force sensor which only has two legs, set the left leg to 5V, and connect the other Leg to CH0
on MCP3002
With each model of RaspBerry Pi2, the pin layout might be a little different. But the pin connection with MCP3002 should be as below:
- MCP3002: VDD/VREF – 5V on RaspBerry Pi2
- MCP3002: CLK – “SPI0 SCLK” on RaspBerry Pi2
- MCP3002: Dout – “SPI0 MISO” on RaspBerry Pi2
- MCP3002: Din – “SPI0 MOSI” on RaspBerry Pi2
- MCP3002: CS/SHDN – “SPIO CS0” on RaspBerry Pi2
- MCP3002: DGND – GND on RaspBerry Pi2
- MCP3002: CH0- Sensor Output Pin
2.Alternative: If you are using MCP3208
Connect the temperature Sensor to MCP3208; Sensor output pin
(the mid pin) should be connected toCH0
on MCP3208.
For more detail: Temperature Sensor Sample