Luc Paquin
Published © CC BY

Project #15: Environment - KY-039 - Mk32

Project #15: Environment - KY-039 - Mk32

BeginnerFull instructions provided1 hour54
Project #15: Environment - KY-039 - Mk32

Things used in this project

Hardware components

Elecrow Crowduino Uno - SD
×1
Elecrow Crowtail - Base Shield
×1
Elecrow Crowtail - I2C LCD
×1
KY-039 Heartbeat Sensor Module
×1
Elecrow Crowtail - LED(Green)
×1
USB Battery Pack
×1
SparkFun USB Mini-B Cable - 6 Foot
SparkFun USB Mini-B Cable - 6 Foot
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Fritzing

Code

DL2506Mk04p.ino

Arduino
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment - KY-039 - Mk31
DL2506Mk04p.ino
DL2506Mk04
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - I2C LCD
1 x KY-039 Heartbeat Sensor Module
1 x Crowtail - LED(Green)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"

// KY-039 Heartbeat
int iHeartbeat = A0;
// Pulse
float pulse;
// Sum
int sum = 0;

// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);

// LED Green
int iLEDGreen = 6;

// EEPROM Unique ID Information
String uid = "";

// Software Version Information
String sver = "15-31";

void loop() {

  // Heartbeat
  // isHeartbeat
  isHeartbeat();

  // Display Heartbeat
  isDisplayHeartbeat();

  // Delay
  delay( 100 );

}

getDisplay.ino

Arduino
// getDisplay
// Crowbits - OLED 128X64 UID
// Display UID
void isDisplayUID(){

  // Set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Don Luc Electron");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD.
  lcd.print( sver );

}
// Display Heartbeat
void isDisplayHeartbeat(){

  // Clear
  lcd.clear();
  // Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print( "Heartbeat" );
  // Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print( pulse );
  
}

getEEPROM.ino

Arduino
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 7; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getHeartbeat.ino

Arduino
// KY-039 Heartbeat
// isHeartbeat
void isHeartbeat(){

  // Sum
  sum = 0;
  
  // KY-039 Heartbeat
  for (int i = 0; i < 20; i++){
  
    sum += analogRead(iHeartbeat);

  }

  // Pulse
  pulse = sum / 200.00;

}

setup.ino

Arduino
// Setup
void setup()
{
 
  // Delay
  delay(100);
  
  // isUID EEPROM Unique ID
  isUID();
  
  // Delay
  delay(100);

  // Initialize the LED Green
  pinMode(iLEDGreen, OUTPUT);
  // LED Green
  digitalWrite(iLEDGreen, HIGH);

  // Delay
  delay(100);

  // KY-039 Heartbeat
  pinMode(iHeartbeat, INPUT);

  // Delay
  delay( 100 );

  // Display UID
  isDisplayUID();
  
  // Delay 10 Second
  delay( 10000 );

}

Credits

Luc Paquin
44 projects • 4 followers
Teacher, Instructor, E-Mentor, R&D and Consulting -Programming Language -Microcontrollers -IoT -Robotics -Machine Learning -AI -Sensors

Comments