My Idea is to create a Heart Rate Monitor that measures a patients Beats Per Minute (BPM). The Heart rate monitor will take a patients Pulse and Display the beats per Minute on a display screen. BPM readings will be stored on the Cloud for BPM history analysis.
I will connect a Heart Rate sensor and a OLED display to the Spresense+Expansion board The Heart Rate sensor, will be used to sense the pulse of the patent. The OLED, will be used to display the Beats Per Minute being taken. This will be done in Firmware developed and embedded on the Spresense.
Research & ExperimentationSince I have not used the Spresense+expansion board before I will need to research and experiment with the board. I needed to get an overview of the Spresense in order to better understand its capabilities. I started by going to on the Spresense Documents page. And followed the Introduction to the SpreSense and how to use the SpreSense board.
I only had the Main Board and the Expansion board, but I needed to attach them together and cover a component on the main board with a shield. This is described in Section 2.3 You will need to attach the main board to the expansion board (described in section 2.3.2) and cover the IC4 with the provided shading seal provided (described in section 2.3.1)
In section 2.1.1 and 2.1.2 , I found hardware information on the main board and the extension board. Most helpful are the Pin assignments.
It is recommended to attach the USB connector to the Main board connector, as described in section 2.3.6. Other power options are given in this section.
I needed to get knowledge on how to develop firmware using the Arduino IDE. The following links were very helpful to get me started on developing firmware for the SpreSense.
Section 3 Software, describes the 3 software environments available for the board. I opted for the Arduino Library development environment, since I was most familiar with this environment. Sect 3.1, describes and gives helpful links in getting a development environment setup to use the Arduino IDE. Follow the links to get yourself up and running on the board. Spresense Arduino Library Getting Started Guide
The following paragraphs describes my notes that allowed me to setup a software environment using the Arduino IDE version 1.8.13
Prerequisites· Download and install the Arduino IDE for your operating system: https://www.arduino.cc/en/Main/Software Already had 2 versions of the ide install so I did not do this install.
· Download and install the USB-to-serial drivers that correspond to your operating system from the following link CP210x USB to serial driver for Windows 10
INSTALLED THIS ANYWAYS I THINK I HAD IT ALREADY INSTALLED?
o FOLLOWED INSTRUCTIONINS IN README FILE AND RIGHT CLICKED ON silabser.inf
· Section 3 – install Arduino Library. There are two installation methods to choose from:
o FOLLOW SECTION 3.1 Installation through Arduino IDE Board Manager We recommend installing through the Arduino IDE Board Manager for ease of use.
o 1ST TRIED ON VERSION 1.8.13
o SECT 3.1 completed ok … The Spresense Arduino Library is now installed.
· Next Follow Section 4
4.1. Identify the serial port used by Spresense board … Connect your PC to the Spresense main board USB connector and check that the power LED turns on. The serial port driver may install at this point if it has not done so already.
4.2. Install Bootloader…
1 .Select the Spresense board in the tools menu. ([Tools→Boards→Spresense Boards→Spresense] in Arduino IDE 1.8.13 or later)
2. Select the serial port used by Spresense from the menu [Tools→Port]
3. If you are using the Spresense board for the first time, or if you are using an updated version of the Spresense Arduino Library, update the boot loader by selecting [Tools→Programmer→Spresense Firmware Updater].
4. Then select [Tools→Programmer→Burn Bootloader]. I did get an error on the port, but was able to resolve it by unplugging/Pluging the USB and was able to continue.
5. Review and accept the EULA by following the dialog.
6. Once the upload completes, this is how it should look like the screenshot in this section
BOOTLOADER WAS COMPLETED.
4.3. Build your first sketch to verify installation…You have now finished setting up the board. To verify the setup is correct, follow the steps in Subsection 4.3.1 – 4.3.5 to compile and upload a test sketch to the SpreSense using the Arduino IDE.
Spresense Arduino Sketch App Development· To quickly get started writing sketches you can use the example files. These examples are included in the Spresense Arduino Library and are available at File > Examples > Spresense.
· Many existing Arduino sketches and libraries run on Spresense. Some of these sketches are for different hardware. You will need to modify these sketches. For an overview of the hardware features, see Differences between Spresense and Arduino Uno.
· Some other help documents to read thru.
o Spresense Arduino Examples & Tutorials
§ This document contains specific Sparsesense examples for Audio, Sensing, LTE ,multi-core and Signal Processing.
o Spresense Arduino Library Developer Guide
§ A detailed document covering Arduino Sketch Development and details on each of the individual libraries.
o Spresense Hackster’s Projects
§ Here you find a set of sample projects made with Spresense. They are a good source for inspiration and to get started with Spresense development. Find more creative Spresense projects at Hackster.io.
· I will be experimenting with a few example sketches.
Connecting the Heart Rate Sensor to the Spresense· This section describes how I connected and tested the Heart Rate Sensor.
- The heart sensor is connected to the Spresense with 3 wires
- The 3 wires are wired to the pins on the Spresense Main board
- Purple – DATA to Pin A2
- Red – to Pin 3v3
- Black – Pin GND
- Connect these wires to the left pins on the spresense board as described below.
To test the connection I used a script from the vendor page for the sensor. Refer to the code in SpreSense_GettingStartedProject.ino in the code section below. Load this sketch into the Arduino IDE and compile it. The website is in the sketch if you would like to explore more. this sketch is a very simple test to confirm that the sensor is wired to the MCU properly. It seems to work although I need to reverse the led section as commented in the code.
Note that the 2 static variables are changed from the example to use pin A2 and blink the LED0 on the Spresense main board. It seems to be working, as you can see by the flashing LED in the video below. I commented out the serial connection in the code and the flashing seemed more consistent. I will need to experiment with the threshold value. I do have a heart condition called AFib, which could explain the jumping beats
Running test sketch show LED0 flashing.
Connecting the OLED Display (SSD1306) to the Spresense- This section describes what I did to wire an SSD1306 to the Spresense.
- I wrote a sketch to test the Spresense to the OLED Display (SSD1306). This sketch will display a counter value incremented in the main loop function. A function is called to display the values of the counter.
- The code is in OLED_Test.ino
My breadboard circuit has the OLED display with 4 jumper wires connected to the pins on Spresence Main and Expansion boards.
- The 4 pins are described next
- To power The VCC and GND pins on the SSD1306, I’m using the pins on the expansion board. POWER JP3 header
- VCC RED to Vout5v pin
- GND BLACK to GND pin
- For the I2C SDA And SDL Pins on the SD1306, I’m using the 2 I2C0 pins on the Main Board.
- SCL BLUE to I2C0_SCL pin
- SDA GREEN to I2C0_SDA pin
- 📷
· Here is a photo showing the wiring and the sketch running.
This section will describe the Design of my idea.
Block diagramThe block diagram is simple. Basically the heart rate sensor and the OLED Display are attached to the Spresense . The heart rate signal from the sensor is read by the firmware on the Spresense. Then the BPM value is sent to the OLED Display as it changes in the firmware.
The components (Heart rate Sensor & OLDED) wired to a breadboard. And jumper wires to the Spresense+ Ext Board
- UML Sequence Diagram
The following flow chart is also used to describe the design logic of the Firmware.
The sketch used to implement this design is BPM_SpreSense.ino (refer to code attachment below)). It follows the logic described in the section above The Pulsesensor code is taken from an example on the pulsesensor.com website at _
The code example uses the Arduino interrupts and the PulseSensorPlayground.h and associated library. I used the same sketch for another project on element14.com. which included a 10 blog series that ran on the Arduino Nano IOT.
Design Challenge: Design For A Cause 2021 - Design Challenge . A 5 blog Design challenge using the Arduino Nano 33 IoT Board My first blog entry: BLOG# 1 - Beats Per Minute Nano - INTRODUCTION, contains an introduction and a list of links to the other blogs. I've listed them as follows for you convenience.Blog#2 Beats Per Minute Nano - Research & Experimentation · Blog#3 Beats Per Minute Nano - System Design · Blog#4 Beats Per Minute Nano - System Implementation and Testing · Blog#5 Beats Per Minute Nano - Conclusions and Future Enhancements
The Working SystemWhen I tried to compile the code in the sketch BPM_SpreSense.ino, I received a compile error?
I am stuck here and will try to get it running before the deadline. I’m not it because of the interrupts, or a library is not installed? The end of the error log is listed in APPENDIX A at the end of this post.
The 2 error are in the disable interrupt code and 2 function cli() and sei() are out of scope
Run ApplicationHere is a video of the same sketch running on an Arduino Nano https://players.brightcove.net/1362235890001/default_default/index.html?videoId=6254293702001
Conclusions and Future EnhancementsConclusionsDid everything work as designed? The only thing that did not work was the sketch that ran on the Arduino did not compile for the SpreSense?
What were the biggest hurdles you had to overcome? The biggest hurdle I had to overcome was getting the PulseSensor lib and Arduino Library to compile on the SpreSense. Also learning a a new board that has the same form factor as the Arduino.
Future EnchantmentsIn addition to the Arduino IDE, use VS Studio with the PlatformIO extension, which is claimed to function like the Arduino IDE
BPM readings will be stored on the Cloud for BPM history analysis.
Appendix A – end of error log for BPM_SpreSense.com"C:\\Users\\skrug\\AppData\\Local\\Temp\\arduino_build_966831\\libraries\\PulseSensor_Playground\\PulseSensorPlayground.cpp.o"
In file included from C:\Users\skrug\Documents\Arduino\libraries\PulseSensor_Playground\src/PulseSensorPlayground.h:439,
from C:\Users\skrug\Documents\Arduino\libraries\PulseSensor_Playground\src\PulseSensorPlayground.cpp:16:
C:\Users\skrug\Documents\Arduino\libraries\PulseSensor_Playground\src\PulseSensorPlayground.cpp: In member function 'boolean PulseSensorPlayground::sawNewSample()':
C:\Users\skrug\Documents\Arduino\libraries\PulseSensor_Playground\src/utility/Interrupts.h:72:41: error: 'cli' was not declared in this scope; did you mean 'cbi'?
72 | #define DISABLE_PULSE_SENSOR_INTERRUPTS cli()
| ^~~
C:\Users\skrug\Documents\Arduino\libraries\PulseSensor_Playground\src\PulseSensorPlayground.cpp:105:5: note: in expansion of macro 'DISABLE_PULSE_SENSOR_INTERRUPTS'
105 | DISABLE_PULSE_SENSOR_INTERRUPTS;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\skrug\Documents\Arduino\libraries\PulseSensor_Playground\src/utility/Interrupts.h:73:40: error: 'sei' was not declared in this scope; did you mean 'sbi'?
73 | #define ENABLE_PULSE_SENSOR_INTERRUPTS sei()
| ^~~
C:\Users\skrug\Documents\Arduino\libraries\PulseSensor_Playground\src\PulseSensorPlayground.cpp:108:5: note: in expansion of macro 'ENABLE_PULSE_SENSOR_INTERRUPTS'
108 | ENABLE_PULSE_SENSOR_INTERRUPTS;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using library Wire at version 1.2.0 in folder: C:\Users\skrug\AppData\Local\Arduino15\packages\SPRESENSE\hardware\spresense\2.5.1\libraries\Wire
Using library Adafruit_GFX_Library at version 1.10.7 in folder: C:\Users\skrug\Documents\Arduino\libraries\Adafruit_GFX_Library
Using library Adafruit_SSD1306 at version 2.4.4 in folder: C:\Users\skrug\Documents\Arduino\libraries\Adafruit_SSD1306
Using library SPI at version 1.2.1 in folder: C:\Users\skrug\AppData\Local\Arduino15\packages\SPRESENSE\hardware\spresense\2.5.1\libraries\SPI
Using library PulseSensor_Playground at version 1.5.1 in folder: C:\Users\skrug\Documents\Arduino\libraries\PulseSensor_Playground
Using library Adafruit_BusIO at version 1.7.3 in folder: C:\Users\skrug\Documents\Arduino\libraries\Adafruit_BusIO
exit status 1
Error compiling for board Spresense.
Comments