Heart rate sensor BH1790

Hi ,
i am working on a project and am using a heart rate sensor BH1790 GLC, i used the code given by
the constructor but i get nothing in the output;
am using an arduino UNO card with my optical sensor , can anyone help plz;
Thnx in advance

Do you have code that is written, that you could post, so that others can see what was done, now this could be the best part, someone could look at, quite possibly, and see see the issue you are having, and give suggestions on possible fixes.

Oh, and those things called schematics, could you post one of your project, those fritznuts things are not schematics.

And as a bonus, could you post a few images of your wired project?

And you know that's not a proper way to describe your issue, right?

Hi , thank you for response
the code is the Following ;

#include <Wire.h>
#include <BH1790GLC.h>
#include <FlexiTimer2.h>

extern "C" {
#include <hr_bh1790.h>
}

#define SAMPLING_CNT_32HZ (32)

BH1790GLC bh1790glc;
volatile bool timer_flg;
void timer_isr(void);

static uint8_t s_cnt_freq = 0;

void setup() {

uint16_t ret16 = ERROR_NONE;

timer_flg = false;
Serial.begin(115200);
while (!Serial);

Wire.begin();
Wire.setClock(400000L);

s_cnt_freq = 0;

ret16 = hr_bh1790_Init();
if (ret16 == ERROR_NONE) {
Serial.println(F("BPM, wearing"));
FlexiTimer2::stop();
FlexiTimer2::set(250, 1.0/8000, timer_isr); // 32Hz timer
FlexiTimer2::start();

ret16 = hr_bh1790_StartMeasure();
if (ret16 != ERROR_NONE) {
  Serial.println(F("Error: hr_bh1790_StartMeasure function"));
  Serial.print(F("ret16 = "));
  Serial.println(ret16, HEX);      
}

} else {
Serial.println(F("Error: hr_bh1790_Init function"));
Serial.print(F("ret16 = "));
Serial.println(ret16, HEX);
}
}

void loop() {

uint8_t bpm = 0U;
uint8_t wearing = 0U;
uint16_t ret16 = ERROR_NONE;

if (timer_flg) {
ret16 = hr_bh1790_Calc(s_cnt_freq);
if (ret16 == ERROR_NONE) {
s_cnt_freq++;
if (s_cnt_freq >= SAMPLING_CNT_32HZ) {
s_cnt_freq = 0;
hr_bh1790_GetData(&bpm, &wearing);
Serial.print(bpm, DEC);
Serial.print(F(","));
Serial.println(wearing, DEC);
}
} else {
Serial.println(F("Error: hr_bh1790_Calc function"));
Serial.print(F("ret16 = "));
Serial.println(ret16, HEX);
}
timer_flg = false;
}
}

void timer_isr(void) {
timer_flg = true;
}

int8_t bh1790_Write(uint8_t adr, uint8_t *data, uint8_t size)
{
byte rc = 0;
int8_t ret = 0;

rc = bh1790glc.write(adr, data, size);
if (rc == 0) {
ret = BH1790_RC_OK;
} else {
ret = BH1790_RC_I2C_ERR;
}

return (ret);
}

int8_t bh1790_Read(uint8_t adr, uint8_t *data, uint8_t size)
{
byte rc = 0;
int8_t ret = 0;

rc = bh1790glc.read(adr, data, size);
if (rc == 0) {
ret = BH1790_RC_OK;
} else {
ret = BH1790_RC_I2C_ERR;
}

return (ret);
}

i have tried also an other code but its gives the same results
#include <Wire.h>
#include <BH1790GLC.h>
#include <FlexiTimer2.h>
#include <stdio.h>

BH1790GLC bh1790glc;
volatile bool timer_flg;
char str[100];

void timer_isr(void);

void setup() {
byte rc;

timer_flg = false;
Serial.begin(115200);
while (!Serial);

Wire.begin();
Wire.setClock(400000L);

rc = bh1790glc.init();
if (rc != 0) {
Serial.println("BH1790 initialize failed");
} else {
Serial.println("LEDON Data, LEDOFF Data");
FlexiTimer2::stop();
FlexiTimer2::set(250, 1.0/8000, timer_isr); // 32Hz timer
FlexiTimer2::start();
}
}

void loop() {
byte rc;
unsigned short val[2];

if (timer_flg) {
rc = bh1790glc.get_val(val);
if (rc == 0) {
sprintf(str, "%d, %d\n", val[1], val[0]);
Serial.print(str);
}
timer_flg = false;
}

}

void timer_isr(void) {
timer_flg = true;
}

You skipped the part about posting your code in code tags. Could you edit your posted code and add in code tags?

Honestly, if you'd read the hints posted on this site, we'd be much further along with troubleshooting your issue. Give it a try read and do some reading by clicky clicky

What did you set your Monitors serial baud rate at?

Put the ISR before the setup().

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.