• Time to read 3 minutes
EspressoLite Bluetooth-based Pulse Sensor

EspressoLite Bluetooth-based Pulse Sensor

I wish to build a Bluetooth-based pulse sensor. Imagine a Fitbit that takes your pulse rate as you exercise and send this data real-time to your mobile phone.

Hardware

The Espressolite is a ESP8266 based microcontroller and the one that I feel the most passionate about; it is built as a collaboration between Espert Pte Ltd, a Singapore company, the folks from Chiang Mai Maker Club in Thailand, and based on the popular ESP8266 chip, developed by EspressIf Systems, based in Shanghai and also founded by a Singaporean. The Espressolite is manufactured by Cytron Technologies, from Penang in Malaysia. Whenever I need to tell a story about a collaborative invention, I share about the Espressolite. 

With the Espressolite, you build with the Arduino IDE like how you would with an Arduino UNO. It cost less than USD12 a piece and as a result, I kept buying more and more of them. Now I have 6.

The HM-10 is a Bluetooth 4.0 module that is often used to give the Arduino UNO bluetooth capabilities. It is a development board based on Texas Instrument's CC2541 Bluetooth Chip. The cool thing about the HM-10 is that it functions both as a central (or a master) and a peripheral (or a slave) device. If you connect 2 of theses to 2 Arduino UNOs, you could have them send and receive data between each other. 

Objective

The tricky problem to using commercial exercise bands like Fitbit is that it needs to pair with your mobile phone to receive data and it needs Wifi or 4G connection if you wish to send pulse rate to the cloud. My objectives for this project are slightly different:

  1. A bluetooth pulse sensor that can potentially be a wearable device. Something based on the Espressolite will work since it is cheap and small. I call this the Pulse Sender.
  2. A second device to receive  pulse from the Pulse Sender via bluetooth. It then needs to forward the pulse rate it received from the Pulse Sender to the cloud. Since the Espressolite uses the ESP8266 chip, this can be done via Wifi (with some limitations because it limits the environment that these devices can work in, for example definitely not in a national park). It could also be 4G but I prefer not to because this will increase its cost as well as the size of the device tremendously. I will stick to Wifi for now and use a 2nd Espressolite to do this. I call this the Pulse Receiver.

Wait a moment, couldn't I just do this with 1 Espressolite rather than 2 ? I could, but that will make my Pulse Sender a little too large to be wearable if I want to add more peripheral devices such as an UnaShield to send pulse through the Sigfox network, or locate where the pulse rate comes with a GPS. I envisioned the Pulse Sender to be something you will wear around your wrist, and the Pulse Receiver something you will feel comfortable to wrap around your waist. The Pulse Sender will send your pulse to the pulse receiver, which will then send it to the cloud. This is essentially the homebrew version of what the Fitbit could have done, but due to its proprietary nature, wouldn't.

Bill of Materials

  1.  Espressolite X 2
  2. HM-10 Bluetooth module X 2
  3. Pulse Sensor X 1
  4. OLED I2C Display X 1

Fritz

Pulse project_bb_0.png

Challenges and Solutions

There were a handful of challenges, mostly because I wasn't using Arudino UNOs. The following sections describe them.

Hooking up the HM-10 with the Espressolite

There are 2 libraries that let you code with the HM-10 and the Ardunio UNO, AltSoftSerial and SoftwareSerial. AltSoftSerial would have been my preference but it fixes the pin you could use to D8 and D9 which the Espressolite do not have. So I had to use SoftwareSerial which allows you to decide which GPIOs you want to use.

Picking up Pulse Rate in Beat-Per-Minute (BPM) from the Pulse Sensor

The folks who built the Pulse Sensor had a great sample project (see project on GitHub) that you could base on IF you were using the Arduino UNO. It picks up your Pulse Rate in BPM and displays it in Arduino IDE's serial monitor. Unfortunately, its usage of ISR2 Timer 2 Interrupt Service Routine that reads the pulse signal every 2 milliseconds is not supported by the Espressolite:

ISR(TIMER2_COMPA_vect){                         
  cli();                                      
  Signal = analogRead(pulsePin);              
  sampleCounter += 2;                         
  int N = sampleCounter - lastBeatTime;       

  if(Signal < thresh && N > (IBI/5)*3){       
    if (Signal < T){                       
      T = Signal;                        
    }
  }

  if(Signal > thresh && Signal > P){          
    P = Signal;                             
}    

Fortunately, Peter Mortan, a retired engineer from Scotland had a great idea to replace this using a Ticker library for the ESP8266. You can find his codes on Github here. This solved my problem reading pulse rate into the Espressolite.

Pairing the HM-10s & making them talk

The Pulse Sender will be the central device and the Pulse Receiver, the peripheral device. To pair them and to have the Pulse Sender send pulse to the Pulse Receiver, I depended tremendously on the guidance provided by Martyn Currey in his writing on HM-10s. You can read it here.

How It Looks

This really isn't how the Pulse Sender and Pulse Receive should look like in production. I mean, the Pulse Sender should strap around your wrist and the Pulse Receiver should hang around your waist.

pulse_0.jpg

This is the heart rate sensor on the pulse sender

esp8266connect_0.jpg

The OLED on the pulse receiver. The pulse rate will show up on the OLED screen

battery_0.jpg

I will get around to replacing the Power Banks with lithium ion batteries and 3D print the cases at some point I promise. 

 

Apologies for the video quality. This is how it looks like when wrapped around my finger. I could stick on my wrist and it will read my pulse too.

Codes

Find them in my Github repository here.

What's Next?

This project is obviously incomplete, but I have learnt all that I wished to for now. This is what I will do on the next iteration:

  1. Not hard code the HM-10 pairing codes. There should be a button to allow the Pulse Sender and Pulse Receiver to pair.
  2. Send pulse to cloud via Sigfox amd forget about Wifi and 4G altogether.
  3. Design and build cases for both Pulse Sender and Pulse Receiver.
  4. Add a GPS to the Pulse Receiver so that I know the user's location.

Photo by Andres Urena on Unsplash