当前位置:网站首页>STM32 MCU uses ADC function to drive finger heartbeat detection module
STM32 MCU uses ADC function to drive finger heartbeat detection module
2022-07-23 22:11:00 【wanglong3713】
One 、 Module introduction
A treasure or a lot , Twoorthree yuan each , Here's the picture .
The module adopts ultra bright infrared LED And phototransistor to detect the pulse of the finger , Place your finger between the transmitter and receiver , Blood pressure changes with the pulse , The light received by the receiving end will change accordingly , Therefore, it can be used to detect heartbeat .
Two 、STM32MX Cube To configure
use STM32F103C8T6 Minimum system board ,STM32MX Cube Configure the system and automatically generate code .
stay ADC1 in , We choose IN1 passageway , namely PA1 Pin , Other configurations are shown in the figure , Basically, the default configuration , There is no need to choose . When all configuration is complete , Generate engineering code , This article will not introduce in detail .
3、 ... and 、 Main code
ADC The initialization code for is in MX_ADC1_Init() in , Generated main Function will automatically call :
MX_ADC1_Init();
It's going on AD On conversion , You need to call HAL_ADC_Start(&hadc1) The function starts to convert , We don't use interrupts , adopt while (HAL_ADC_PollForConversion(&hadc1,10) != HAL_OK) To wait for the conversion to complete , And then through HAL_ADC_GetValue(&hadc1) Function to obtain AD value ,HAL_ADC_Stop(&hadc1) Function ends the conversion . Each of the above processes 10ms Do it once , Sampling frequency 100Hz.
HAL_ADC_Start(&hadc1);
while (HAL_ADC_PollForConversion(&hadc1,10) != HAL_OK)// Wait for the conversion to complete
{
}
HeartBeat_RawData = HAL_ADC_GetValue(&hadc1);//RAW_DATA_LENGTH Is the number of data saved
HAL_ADC_Stop(&hadc1);
printf("%d\n", HeartBeat_RawData);
In the above code printf Function to print data to serial port . see , You need to write your own code , Not many lines .
Four 、 Running effect

The above figure is through the serial port drawing software VOFA+ The original drawing AD The graph of values , It can be seen that the data is messy , The green line in the figure below is the effect after simple filtering :
5、 ... and 、 summary
1. Actual test findings , This module has a great impact on the environment , Day 、 night , turn on the light 、 Turning off the lights will have a great impact on the data , And data often drift ;
2. Just read the data , Simple filtering , From the time domain diagram , I can't find any rules ;
3. If it's just for learning ADC Use , You can use this module to practice , These data can also be used to learn the filtering algorithm 、 Fourier transform, etc , But I want to use it to detect the heartbeat more accurately , I still don't recommend .
边栏推荐
- synthesizable之Verilog可不可综合
- Neo4j应用
- Multithreading problem: why should we not use multithreading to read and write the same socket connection?
- JMeter performance comprehensive practice - sign in and batch sign in
- Providers and consumers tags in zfoo
- ApplicationContext introduction
- zk 是如何解决脑裂问题的
- SQL injection attack
- 实验设计
- 除了钱,创业者还需要什么?专访明月湖创赛创投机构
猜你喜欢

Introduction to I2C Principle & Application of esp32

MySQL index transaction

Neo4j application

MySQL如何对SQL做prepare预处理(解决IN查询SQL预处理仅能查询出一条记录的问题)

LeetCode高频题62. 不同路径:机器人从左上角到右下角的路径有多少条?纯概率排列组合问题,而不是动态规划题

记第一次挖洞交洞历程

Cookie 和 Session

University database creation and query practice -- database table design

Uniapp uses canvas to write a circular progress bar

记忆化搜索 - DP
随机推荐
JS object array de duplication
详解NAT技术
ApplicationContext introduction
How to add an operator in ONEFLOW
Pulsar open source message queue_ Understand pulsar --- pulsar work notes 001
zk 是如何解决脑裂问题的
Construction and application progress of ten billion level knowledge map of meituan brain
软件体系结构期末复习六十题
Cookie 和 Session
Uniapp uses canvas to write a circular progress bar
机器学习习题——对率回归
[hiflow] Tencent cloud's new generation of automation assistant, which I used to complete the enterprise epidemic prompt (no code)
二分函数细节
除了钱,创业者还需要什么?专访明月湖创赛创投机构
LeetCode高频题62. 不同路径:机器人从左上角到右下角的路径有多少条?纯概率排列组合问题,而不是动态规划题
JDBC programming of MySQL
LeetCode高频题53. 最大子数组和,具有最大和的连续子数组,返回其最大和
[acwing] weekly competition
Altium designer—Arduino UNO原理图&PCB图(自制Arduino板)
Given an array composed of numbers, realize the name whose output ID is a number and sorted from small to large