Skip to content

Instantly share code, notes, and snippets.

@ceiborg
Last active November 26, 2019 20:36
Show Gist options
  • Save ceiborg/188f599a247e57419cce5417c68ae1dc to your computer and use it in GitHub Desktop.
Save ceiborg/188f599a247e57419cce5417c68ae1dc to your computer and use it in GitHub Desktop.
Display LCD + Modulo sensor de Temperatura y Humedad Dht11 + sensor pulso cardíaco
/*
#############%@
#### #########%
## #########&
#% ##########
### ############
################### ceiborg.com
################### tecnotextiles
##################
#################
##############
##
#
*/
//Display LCD + Modulo sensor de Temperatura y Humedad Dht11 + sensor cardíaco
//Librerias
#include <LiquidCrystal.h> //libreria LCD
#include <DHT.h> // Incluimos librería sensor Temperatura y Humedad
#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library.
//LCD pin to Arduino
const int pin_RS = 8;
const int pin_EN = 9;
const int pin_d4 = 4;
const int pin_d5 = 5;
const int pin_d6 = 6;
const int pin_d7 = 7;
const int pin_BL = 10;
LiquidCrystal lcd( pin_RS, pin_EN, pin_d4, pin_d5, pin_d6, pin_d7);
// sensor temperatura y humedad
#define DHTPIN 2 // Definimos el pin digital donde se conecta el sensor
#define DHTTYPE DHT11 // Dependiendo del tipo de sensor
DHT dht(DHTPIN, DHTTYPE); // Inicializamos el sensor DHT11
long previousMillis = 0; // will store last time LED was updated
int k = 0;
float h = 0;
float t = 0;
//Heart sensor
const int PulseWire = A3; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
int Threshold = 511; // Determine which Signal to "count as a beat" and which to ignore.
PulseSensorPlayground pulseSensor; // Creates an instance of the PulseSensorPlayground object called "pulseSensor"
#define UN_SEGUNDO 750
void setup() {
//LCD
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("HIPSIBIUS");
delay (2000);
lcd.clear();
// sensor DHT11
Serial.begin(9600); // Inicializamos comunicación serie
dht.begin(); // Comenzamos el sensor DHT
//heart sensor
pulseSensor.analogInput(PulseWire);
pulseSensor.setThreshold(Threshold);
// Double-check the "pulseSensor" object was created and "began" seeing a signal.
pulseSensor.begin();
}
void leerSensores() {
// sensor temperatura
// Leemos la humedad relativa
h = dht.readHumidity();
// Leemos la temperatura en grados centígrados (por defecto)
t = dht.readTemperature();
}
void actualizarDisplay() {
lcd.clear();
lcd.setCursor(0,0);
// Comprobamos si ha habido algún error en la lectura
if (isnan(h) || isnan(t)) {
lcd.print ("Error sensor Temp");
}else if(k<5){
lcd.print ("Humedad: ");
lcd.setCursor(1,1);
lcd.print (h);
lcd.setCursor(10,1);
lcd.print ("%");
}else if (k<10){
lcd.print ("Temperatura ");
lcd.setCursor(1,1);
lcd.print (t);
lcd.setCursor(10,1);
lcd.print ("C");
}else {
int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an "int". // "myBPM" hold this BPM value now.
pulseSensor.sawStartOfBeat();
Serial.println (myBPM);
if (myBPM>45){
myBPM = map(myBPM, 46, 100, 59, 100);
lcd.print ("BPM ");
lcd.setCursor(1,1);
lcd.print (myBPM);
lcd.setCursor(10,1);
}else{
lcd.print ("BPM ");
lcd.setCursor(1,1);
lcd.print ("sin datos");
lcd.setCursor(10,1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment