Arduino与MAX30100模块无法通讯怎么解决?

MX30100 Arduino库文件下载地址:https://codeload.github.com/oxullo/Arduino-MAX30100/zip/master

前几天在淘宝买了个MAX30100心率检测模块,据说可以检测心率与血氧,模块才七八块钱一片,我就买来玩玩。

模块大概就长这样:

然后还买了个Arduino Mni Pro开发板,也是六七块钱一个。想着Arduino那么有名,而我至今还没玩过,就买来试试。

Arduino Mni Pro开发板长这样:

(PS: 这个应该是符合国情的改良版本,正版的可能不止六七块)

收到货以后,一顿操作猛如虎,焊接,连线,装开发环境下载代码等等一气呵成,结果MAX30100模块楞是没跑起来...What The F..F....FFF,折腾了半天怀疑是模块坏了,决定用STM32试试,结果STM32就没问题,模块顺利跑起来并且数据监测也OK。

神啊!主啊!!机器猫啊!!!为何Arduino就不行了呢!?

思来想去,猛然发现STM32的GPIO是3.3V逻辑电平,而Arduino Mni Pro本质上用的是ATMAGE 328P,这哥们是5V逻辑电平的,这个是有区别的。

于是检查了下MAX30100模块的IIC引脚上拉电阻是不是电平不够,果然发现它是直接上拉到1.8V而非3.3V或5V。

那么问题就解决了。本期结束,下期再见。

............

............

............

还是讲完它吧,看图:

把图片中标出来的三个4.7K的电阻用电烙铁取下来。然后在SDA、SCL引脚处再焊接两个4.7K的电阻接到VIN引脚,这样就可以和Arduino通讯了。

如果项目中需要用到INT引脚,那么还需要把INT引脚也焊接一个4.7K的电阻连接到VIN引脚。

这样一来就可以和Arduino通讯了,一点毛病也没有。

先别急着点右上角的叉叉关网页,还有更粗暴的解决方法,稍微懂硬件的朋友应该会直接把右边那颗“65K9”的输出脚那根线割断,然后在最右边那颗4.7K的电阻右端飞根线到VIN引脚,这就完事儿了,人狠话不多,简单粗暴。

另外,附上测试代码:

/*
Arduino-MAX30100 oximetry / heart rate integrated sensor library
Copyright (C) 2016  OXullo Intersecans <x@brainrapers.org>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <Wire.h>
#include "MAX30100_PulseOximeter.h"

#define REPORTING_PERIOD_MS     1000

// PulseOximeter is the higher level interface to the sensor
// it offers:
//  * beat detection reporting
//  * heart rate calculation
//  * SpO2 (oxidation level) calculation
PulseOximeter pox;

uint32_t tsLastReport = 0;

// Callback (registered below) fired when a pulse is detected
void onBeatDetected()
{
    Serial.println("Beat!");
}

void setup()
{
    Serial.begin(115200);

    Serial.print("Initializing pulse oximeter..");

    // Initialize the PulseOximeter instance
    // Failures are generally due to an improper I2C wiring, missing power supply
    // or wrong target chip
    if (!pox.begin()) {
        Serial.println("FAILED");
        for(;;);
    } else {
        Serial.println("SUCCESS");
    }

    // The default current for the IR LED is 50mA and it could be changed
    //   by uncommenting the following line. Check MAX30100_Registers.h for all the
    //   available options.
    // pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);

    // Register a callback for the beat detection
    pox.setOnBeatDetectedCallback(onBeatDetected);
}

void loop()
{
    // Make sure to call update as fast as possible
    pox.update();

    // Asynchronously dump heart rate and oxidation levels to the serial
    // For both, a value of 0 means "invalid"
    if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
        Serial.print("Heart rate:");
        Serial.print(pox.getHeartRate());
        Serial.print("bpm / SpO2:");
        Serial.print(pox.getSpO2());
        Serial.println("%");

        tsLastReport = millis();
    }
}

要让这套代码跑起来,需要在Arduino IDE里面安装MAX30100的库文件:

然后就没啥了,祝大家玩得开心。今天的砖头依然很烫手,对面小卖部冰箱里的冰镇可乐依然是我遥不可及的梦想,我要继续搬砖了。

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 精致技术 设计师:CSDN官方博客 返回首页