(1/4) BPM (Pulse Sensor) and Pedometer (ADXL345 Accelerometer) Wearable Device with OLED Display


As technology moves forward, components get smaller. As components get smaller, humanity’s creativity expands towards infinity.

Wearables are a product of miniaturized electronic components, relentless creativity, and quick prototyping microcontroller boards (such as Arduino Minis or Nano).

To demonstrate the power of modern technology,we are going to make a prototype fitness tracker. For this purpose, we are integrating a 128×32 OLED with a Heartbeat Sensor  and a ADXL345 Accelerometer as a Pedometer.

As how babies learn to how to walk, we’ll be dissecting each element into parts. For this first part of this mini-project series, we are going to explore how to display texts to a 128×32 OLED display.

Hardware Used

For the course of this mini-project, the following will be used :

  • Arduino Uno R3 (Robotdyn)

  • Heart Rate Pulse Sensor
  • ADXL345 Accelerometer module
  • 128×64  0.96″OLED display 
  • Jumper Wires
  • Breadboard

    You can buy all this Hardware at Createlabz.

    Software Used

    Library Used

    SPI.h and Wire.h are both built-in Arduino libraries that are ready to use. The Adafruit_GFX and Adafruit_SSD1306 needs to be imported either manually or via the Arduino Library Manager.

    • SPI.h

    This library allows you  to communicate with the Serial Peripheral Interface (SPI) Devices

    • Wire.h

    This library allows you to communicate with the Inter-Integrated Circuit (I2C)/ Two Wire Interface (TWI) Devices

    The base library that contains the necessary function calls for Adafruit_SSD1306 or similar display devices

    This library is a simplified compilation of function calls from the Adafruit_GFX

    Application Description

    Defined by howstuffworks.com, OLEDs are solid-state devices composed of thin films of organic molecules that create light with the application of electricity. OLEDs can provide brighter, crisper displays on electronic devices and use less power than conventional light-emitting diodes (LEDs) or liquid crystal displays (LCDs) used today.

    The 128×32 Organic Light-Emitting Diode (OLED) Display is an monochromatic electronic display that, unlike a traditional LCD, has no backlight.

    So how does an OLED work?

    Organic Light-Emitting Displays are made up of pixels. Each pixels have a subpixels which are Red, Green, and Blue LEDs.

    1. To turn on a subpixel, we attach a voltage across the negative and positive terminal.
    2. As electricity starts to conduct, the cathode receives electrons, and the anode loses them. (n-type semiconductors have “electrons” as carriers, p-type semiconductors have “holes” as carriers)
    3. The flow of electrons make the emissive layer more negatively charged (gaining electrons), while the conductive layer is becoming more positively charged (losing electrons)
    4. When the voltage across a subpixel is high enough to overcome the PN Junction barrier, the holes and electrons meet up (which is called recombination). This process releases a brief burst of energy or photons.

    Set-up the Hardware


    • GND – Common Ground
    • VCC – 5V
    • SCL – A4 / SCL
    • SDA – A5 / SDA


    Initially, we should scan the address of our I2C device using the following code:

    // --------------------------------------
    // i2c_scanner
    // Version 1
    //    This program (or code that looks like it)
    //    can be found in many places.
    //    For example on the Arduino.cc forum.
    //    The original author is not know.
    // Version 2, Juni 2012, Using Arduino 1.0.1
    //     Adapted to be as simple as possible by Arduino.cc user Krodal
    // Version 3, Feb 26  2013
    //    V3 by louarnold
    // Version 4, March 3, 2013, Using Arduino 1.0.3
    //    by Arduino.cc user Krodal.
    //    Changes by louarnold removed.
    //    Scanning addresses changed from 0...127 to 1...119,
    //    according to the i2c scanner by Nick Gammon
    //    http://www.gammon.com.au/forum/?id=10896
    // Version 5, March 28, 2013
    //    As version 4, but address scans now to 127.
    //    A sensor seems to use address 120.
    // Version 6, November 27, 2015.
    //    Added waiting for the Leonardo serial communication.
    // This sketch tests the standard 7-bit addresses
    // Devices with higher bit address might not be seen properly.
    #include <Wire.h>
    void setup()
      while (!Serial);             // Leonardo: wait for serial monitor
      Serial.println("\nI2C Scanner");
    void loop()
      byte error, address;
      int nDevices;
      nDevices = 0;
      for(address = 1; address < 127; address++ ) 
        // The i2c_scanner uses the return value of
        // the Write.endTransmisstion to see if
        // a device did acknowledge to the address.
        error = Wire.endTransmission();
        if (error == 0)
          Serial.print("I2C device found at address 0x");
          if (address<16) 
          Serial.println("  !");
        else if (error==4) 
          Serial.print("Unknown error at address 0x");
          if (address<16) 
      if (nDevices == 0)
        Serial.println("No I2C devices found\n");
      delay(5000);           // wait 5 seconds for next scan

    If the scanned I2C Address does not match the default 128×32 OLED Display (0x3C), change the address in display.begin();

    #include <SPI.h>
    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>
    #define OLED_RESET 4
    Adafruit_SSD1306 display(OLED_RESET);
    #if (SSD1306_LCDHEIGHT != 32)
    #error("Height incorrect, please fix Adafruit_SSD1306.h!");
    void setup()   {                
      // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
      display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
      // init done
      // Show image buffer on the display hardware.
      // Since the buffer is intialized with an Adafruit splashscreen
      // internally, this will display the splashscreen.
      // Clear the buffer.
    void loop(){
            display.println("Hello World !");
            display.println("2nd Line Test");
            display.println("3rd Line Test");


    Code Breakdown


    void display();

    Clears the OLED Display. Use this to update/refresh the screen.

    void clearDisplay(void);

    Clears the OLED Display. Use this to update/refresh the screen.


    Sets the starting point of the text.

    display.println("String Here");

    Display the text “String Here” in the OLED display.

    void drawPixel(int16_t x, int16_t y, uint16_t color);

    Basically draws a dot in the screen.


    An Organic Light-emitting diode Display is one of the many electronic devices employed to make a device more human-friendly. It creates a view-able onscreen user interface that can interact with the user. For systems that relays data to the user, an OLED display is a device that can be considered.






    The post (1/4) BPM (Pulse Sensor) and Pedometer (ADXL345 Accelerometer) Wearable Device with OLED Display appeared first on CreateLabz.

    128x64AccelerometerAdxl345ArduinoDisplayHeart rateKnowledgebaseOledPulse sensorSsd1306

    Leave a comment

    All comments are moderated before being published