If you search, you will find many reference articles. I also referred to it from the following URL. http://qiita.com/okadate/items/c36f4eb9506b358fb608 First, put a simple sample code regardless of the pulse sensor. If you do this, data.csv will be created in the same folder as this python code, and the numbers from 0 to 99 will be lined up vertically. Finally, make this number the pulse rate.
csvSample.py
import csv
f = open('data.csv', 'w')
for i in range(0, 100):
writer = csv.writer(f, lineterminator='\n')
writer.writerow([i])
f.close()
If you can confirm that it works, instead of using the for statement, match it with the sample code created in "3. Confirm with python" two times before.
sample.py
import smbus
import time
import threading
import csv
I2C_ADDRESS = 0x48
bus = smbus.SMBus(1)
f = open('data.csv', 'w')
def loop(count):
count = count+1
bus.write_byte(I2C_ADDRESS, 0xFF)
value = bus.read_byte(I2C_ADDRESS)
print value
writer = csv.writer(f, lineterminator='\n')
writer.writerow(value)
if count < 100 :
t = threading.Timer(0.1, loop, args=(count,))
t.start()
else :
f.close()
print 'finish'
t = threading.Thread(target=loop, args=(0,))
t.start()
Now, when the pulse sensor can be wired (last time) and the above python code can be executed, we will measure it. The trick is to release your finger a little.
If you can safely create csv data in Raspberry Pi, you are successful. Transfer data to your PC. The method is free, but I used ftp software (Cyberduck because it is a mac). It is also possible to insert a USB memory into the Raspberry Pi.
It seems that my data wasn't working. Below is a graph image comparing when the finger is placed and when it is not placed at all.
Wiring, environment, data acquisition interval too wide ... If hoe ... is already dead ...?
Whatever the result, this is a semi-forced end. Improvement I would like to continue to improve. It's been a long time, but thank you for your hard work.
Recommended Posts