Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Archer

Pages: 1
1
Wirelings / Help with code
« on: January 11, 2022, 04:57:02 PM »
I was wondering why this piece of code doesn't ever have the red light in the pulse ox sensor turn on. I know it is very finicky for values in heart rate but the sensor isn't even turning on even though the code says it is plugged in and detected.

#include <Wire.h>
#include <Wireling.h>
#include <BMA250.h>
#include <SPI.h>
#include <SD.h>
#include <MAX30101.h>

#if defined (ARDUINO_ARCH_AVR)
#define Serial Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define Serial SerialUSB
#endif

const int chipSelect = 10;


MAX30101 pulseSensor = MAX30101();
int pulseSensorPort = 0;
BMA250 accel_sensor;
int x, y, z, xNew, yNew, zNew, hr, walkingTime, runningTime, playingTime, restingTime;
File myFile;
void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  Serial.print("Initializing SD card...");
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");
  Serial.begin(115200);
  Wire.begin();
  Wireling.begin();
  Wireling.selectPort(1);
  accel_sensor.begin(BMA250_range_2g, BMA250_update_time_64ms);
  accel_sensor.read();
  x = accel_sensor.X;
  y = accel_sensor.Y;
  z = accel_sensor.Z;
  if (x == -1 && y == -1 && z == -1) {
    while (true) {
    Serial.println("ERROR! NO BMA250 DETECTED!");
    delay(1000);
    }
  } else {
    Serial.println("Complete");
  }
  delay(250);
  Serial.begin(9600);
  Wire.begin();
  Wireling.begin();
  delay(200);
  while (!Serial && millis() < 5000);
  Wireling.selectPort(pulseSensorPort);
  if (pulseSensor.begin()) {
    while (true) {
      Serial.println("MAX30101 Wireling not detected!");
      delay(1000);
    }
  } else {
    Serial.println("Complete");
  }
  pulseSensor.begin();
}

void loop() {
  Wireling.selectPort(pulseSensorPort);
  pulseSensor.begin();
  myFile = SD.open("test.csv", FILE_WRITE);
  x = accel_sensor.X;
  y = accel_sensor.Y;
  z = accel_sensor.Z;
  hr = pulseSensor.BPM();
  delay(150000);
  xNew = accel_sensor.X;
  yNew = accel_sensor.Y;
  zNew = accel_sensor.Z;
  if (hr > 80 && hr < 120 && xNew - x > 2743.2 || yNew - y > 2743.2) {
    walkingTime = walkingTime + 5;
    myFile.println(walkingTime);
    Serial.println(walkingTime);
  } else if (hr > 120 && xNew - x > 2743.2 || yNew - y > 2743.2) {
    runningTime = runningTime + 5;
    myFile.println(runningTime);
    Serial.println(runningTime);
  } else if (xNew - x < 2743.2 && yNew - y < 2743.2 && zNew - z < 2743.2 && hr > 80 && hr < 200) {
    playingTime = playingTime + 5;
    myFile.println(playingTime);
    Serial.println(playingTime);
  } else if (xNew - x < 914.4 && yNew - y < 914.4 && zNew - z < 914.4 && hr < 90) {
    restingTime = restingTime + 5;
    myFile.println(restingTime);
    Serial.println(restingTime);
  } else if (xNew - x > 2743.2 || yNew - y > 2743.2) {
    walkingTime = walkingTime + 5;
    myFile.println(walkingTime);
    Serial.println(walkingTime);
  }
  else
  {
    restingTime = restingTime + 5;
    myFile.println(restingTime);
    Serial.println(restingTime);
  }
  myFile.close();
  delay(150000);
}

2
Wirelings / Help with MAX30101 Library
« on: December 28, 2021, 11:37:27 AM »
I need some help downloading the MAX30101 library. I downloaded the Emotbit MAX30101 library but it only pulled up code for the MAX30105 sensor. i was wondering if someone could provide the MAX30101 library instructions.

3
Wirelings / Accelerometer Units/Dog Fitbit
« on: December 21, 2021, 11:14:21 AM »
I am trying to build a Fitbit style fitness tracker for my 4 month old puppy. I am using a TinyZero processor, Pulse Ox sensor, Accelerometer sensor, and SD card shield. My plan is to classify activity into 4 different categories. The first would be walking which would be determined by lots of change in X and Y and a heart rate between 80-120. the next is running which is classified the same way as walking but the heart rate is between 120 and 200. the next category is playing which is classified by moderate change in X, Y, and Z with a heart rate between 80 and 200. The last category is resting which is classified by low to no change in X and Y with a heart rate below 90.

I was wondering if someone knew what the units for x, y, and z captured by the Accelerometer Wireling are so that I can get an accurate view of what moderate and high change in the x and y values is actually like in the real world.

Thanks in advance

Pages: 1
SMF spam blocked by CleanTalk