Skip to content

Commit 42ce303

Browse files
committed
added images edited
1 parent 57fd1e6 commit 42ce303

6 files changed

+17
-7
lines changed

PulseSensor_C_Pi/PulseSensor_C_Pi.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Pulse Sensor + C + Raspberry Pi
2-
The example code here is written in C to run on Raspberry Pi
3-
There are two programs. They both rely on the wiringPi library, which should have been included in your OS distribution. If not, go to [wiringPi](http://wiringpi.com/) to download it.
2+
The example code here is written in C to run on Raspberry Pi. There are two programs: **Pulse Sensor Timer** and **Pulse Sensor Gnuplot**. They both rely on the WiringPi library, which should have been included in your OS distribution. If not, go to [wiringPi](http://wiringpi.com/) to download it. You might want to update it while you're at it. Open a terminal window and type in `sudo get-apt update wiringPi`
43

54
## Things you'll need
65

@@ -11,23 +10,34 @@ There are two programs. They both rely on the wiringPi library, which should hav
1110
* LED & Resistor (220ohm - 1K)
1211
* Jumper wires (male/female)
1312

14-
There are many was to set up your Pi. We used [Adafruit's](https://learn.adafruit.com/series/learn-raspberry-pi) tutorial to get set up. Once you have the Pi OS up and running, you will want to make sure that your configuration settings allow us to connect the Arduino. In the GUI, select `Raspberry Pi Configuration`, then open the `Interfaces` tab and enable Serial Port.
13+
There are many was to set up your Pi. We used [Adafruit's](https://learn.adafruit.com/series/learn-raspberry-pi) tutorial to get set up. Once you have the Pi OS up and running, you will want to make sure that your configuration settings allow us to connect to the hardware SPI bus. In the GUI, select `Raspberry Pi Configuration`, then open the `Interfaces` tab and enable SPI.
1514

16-
![Conf_Window_Serial_Enable]()
15+
![ConfWindowSerial](../images/PiConfigWindowSPI.png)
1716

1817
To do this on the command line, you need to edit your config file. Open a terminal window and type in
1918

2019
sudo raspi-config
2120

22-
This will open up a configuration panel. Use the arrow keys to move down to `Interfacing Options` then press the right arrow to highlight `<Select>` and press either the space bar or Enter/Return. In the next pane, arrow down to the Serial Port option and enable it. Pi may ask you to reboot, so go ahead and do that, otherwise arrow your way to `<Finish>` and get out of the config menu.
21+
This will open up a configuration panel. Use the arrow keys to move down to `Interfacing Options` then press the right arrow to highlight `<Select>` and press either the space bar or Enter/Return.
22+
23+
![InterfaceOptions](../images/InterfacingOptions.png)
24+
25+
In the next pane, arrow down to the SPI option and enable it.
26+
27+
![EnableSerial](../images/EnableSPI.png)
28+
29+
Pi may ask you to reboot, so go ahead and do that, otherwise arrow your way to `<Finish>` and get out of the config menu.
2330

2431

2532
## Connect your Pulse Sensor to Raspberry Pi
2633
The Pulse Sensor outputs an analog signal, which the RasPi cannot natively handle. In the examples below, we are using an Analog to Digital Converter (ADC) IC to digitize the Pulse Sensor signal. As of this writing, the code below supports the MCP3008 ADC IC. (You could use the MCP3004 if you like). The Wiring Pi library has functions that enable us to easily access data from the MCP3008. You can pick one up at [Mouser](https://www.mouser.com/ProductDetail/Microchip-Technology/MCP3008-I-SL?qs=BYQkrObauiuZK6Atf%2FfReA%3D%3D&gclid=CjwKCAjwhbHlBRAMEiwAoDA343G0yGlECsWZ5zo-5UbrMk58sLaK11XtHWNU8w9fzKlpIiY343y0YBoCrBgQAvD_BwE) or [SparkFun](https://www.sparkfun.com/products/15099) or [Adafruit](https://www.adafruit.com/product/856).
2734

28-
The RasPi interfaces the MCP3008 via the hardware SPI bus. Here's a diagram to help you assemble the circuit. In addition to the MCP3008, you will need a [breadboard](https://www.adafruit.com/product/64) and some [male/female jumper cables](https://www.adafruit.com/product/826). We want to blink an LED, so you should have one of those handy, along with a resistor (220ohm to 1K should work fine).
35+
The RasPi interfaces the MCP3008 via the hardware SPI pins. Here's a diagram to help you assemble the circuit.
36+
37+
![Fritzing Diagram](../images/PulseSensor_RasPi_MCP3008_fritz.png)
38+
39+
In addition to the MCP3008, you will need a [breadboard](https://www.adafruit.com/product/64) and some [male/female jumper cables](https://www.adafruit.com/product/826). We want to blink an LED, so you should have one of those handy, along with a resistor (220ohm to 1K should work fine).
2940

30-
![Fritzing Diagram]()
3141

3242
## Pulse Sensor Timer
3343
In order to get accurate BPM data from the Pulse Sensor, it is important to have fast and regular reading of the Pulse Sensor analog signal. By fast, we mean 500Hz (1 sample every 2 milliseconds). By regular, we mean 1 sample every 2 milliseconds. Period. Not 2.5 milliseconds, not 1.8 milliseconds, not whenever the OS decides to get around to it. This is much easier to do on a microcontroller where you are not running with an operating system. Arduino, for example, has no problem setting its hardware timer to sample data every 2 milliseconds on the dot. But we're not in Arduino, we're in RasPi, and things are different.

images/EnableSPI.png

-657 KB
Loading

images/InterfacingOptions.png

-663 KB
Loading

images/PiConfigWindowSPI.png

-701 KB
Loading

images/PiConfigWindowSerial.png

-813 KB
Loading
258 KB
Loading

0 commit comments

Comments
 (0)