Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define USE_ARDUINO_INTERRUPTS true
- #include <Adafruit_MLX90614.h>
- #include <Adafruit_GFX.h>
- #include <Adafruit_SSD1306.h>
- #include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library.
- #define SCREEN_WIDTH 128 // OLED display width, in pixels
- #define SCREEN_HEIGHT 64 // OLED display height, in pixels
- #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
- #define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.
- Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
- Adafruit_MLX90614 mlx = Adafruit_MLX90614();
- double temp_amb;
- double temp_obj;
- double calibration = 2.36;
- const int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
- const int LED13 = 13; // The on-board Arduino LED, close to PIN 13.
- int Threshold = 550; // Determine which Signal to "count as a beat" and which to ignore.
- // Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting.
- // Otherwise leave the default "550" value.
- PulseSensorPlayground pulseSensor; // Creates an instance of the PulseSensorPlayground object called "pulseSensor"
- void setup()
- {
- Serial.begin(9600);
- mlx.begin(); //Initialize MLX90614
- display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
- // Double-check the "pulseSensor" object was created and "began" seeing a signal.
- if (pulseSensor.begin()) {
- Serial.println("We created a pulseSensor Object !"); //This prints one time at Arduino power-up, or on Arduino reset.
- }
- //Serial.println("Temperature Sensor MLX90614");
- pulseSensor.analogInput(PulseWire);
- pulseSensor.blinkOnPulse(LED13); //auto-magically blink Arduino's LED with heartbeat.
- pulseSensor.setThreshold(Threshold);
- display.clearDisplay();
- display.setCursor(25,15);
- display.setTextSize(1);
- display.setTextColor(WHITE);
- display.println(" Thermometer");
- display.setCursor(25,35);
- display.setTextSize(1);
- display.print("Initializing");
- display.display();
- delay(2500);
- }
- void loop(){
- //Reading room temperature and object temp
- //for reading Fahrenheit values, use
- //mlx.readAmbientTempF() , mlx.readObjectTempF() )
- temp_amb = mlx.readAmbientTempC();
- temp_obj = mlx.readObjectTempC();
- int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an "int".
- // "myBPM" hold this BPM value now.
- if (pulseSensor.sawStartOfBeat()) // Constantly test to see if "a beat happened".
- // Serial.println("♥ A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened".
- Serial.print("BPM: "); // Print phrase "BPM: "
- Serial.println(myBPM); // Print the value inside of myBPM.
- //Serial Monitor
- Serial.print("Room Temp = ");
- Serial.println(temp_amb);
- Serial.print("Object temp = ");
- Serial.println(temp_obj);
- display.clearDisplay();
- display.setCursor(0,10);
- display.setTextSize(1);
- display.print("BPM: ");
- display.print(myBPM);
- display.setCursor(0,20);
- display.setTextSize(1);
- display.print("Ruangan: ");
- display.print(temp_amb);
- display.print((char)247);
- display.print("C");
- display.setCursor(0,40);
- display.setTextSize(1);
- display.print("Suhu: ");
- display.print(temp_obj + calibration()>37;
- display.print((char)247);
- display.print("C");
- delay(2000);
- display.display();
- //delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement