<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: micro:bit pulse oximeter</title>
	<atom:link href="http://www.suppertime.co.uk/blogmywiki/2021/09/microbit-pulse-oximeter/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.suppertime.co.uk/blogmywiki/2021/09/microbit-pulse-oximeter/</link>
	<description>reading, writing, coding, making</description>
	<lastBuildDate>Tue, 24 Oct 2023 13:43:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: blogmywiki</title>
		<link>http://www.suppertime.co.uk/blogmywiki/2021/09/microbit-pulse-oximeter/#comment-103291</link>
		<dc:creator>blogmywiki</dc:creator>
		<pubDate>Mon, 06 Jun 2022 16:24:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.suppertime.co.uk/blogmywiki/?p=4127#comment-103291</guid>
		<description>Hi Mike - yes that&#039;s right, the HEX file was built for a V2 micro:bit so would not work on a V1. You may be able to use the Arduino IDE and the Oxullo library to target a V1 micro:bit instead of a V2 when you compile the code. I can&#039;t test this but I had a go at recompiling it for a V1 micro:bit here: &lt;a href=&quot;https://raw.githubusercontent.com/blogmywiki/microbit-MAX30100/main/max30100.ino.BBCmicrobit.hex&quot; rel=&quot;nofollow&quot;&gt;https://raw.githubusercontent.com/blogmywiki/microbit-MAX30100/main/max30100.ino.BBCmicrobit.hex&lt;/a&gt;

My program, including the OLED display, looked like this:
&lt;code&gt;
#include &lt;Wire.h&gt;
#include &quot;MAX30100_PulseOximeter.h&quot;
#include &lt;Adafruit_SSD1306.h&gt;
#include &lt;Adafruit_GFX.h&gt;
//#include &lt;splash.h&gt;
//#include &lt;Adafruit_Microbit.h&gt;
//Adafruit_Microbit_Matrix microbit;

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     -1 // Reset pin # (4 or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C 
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &amp;Wire, OLED_RESET);
 
#define REPORTING_PERIOD_MS     1000
 
// PulseOximeter is the higher level interface to the sensor
// it offers:
//  * beat detection reporting
//  * heart rate calculation
//  * SpO2 (oxidation level) calculation
PulseOximeter pox;
 
uint32_t tsLastReport = 0;
 
// Callback (registered below) fired when a pulse is detected
void onBeatDetected()
{
    Serial.println(&quot;Beat!&quot;);
    display.setCursor(100, 0);
    display.write(3);
    display.display();
}
 
void setup()
{
    Serial.begin(115200);
//    microbit.begin();
    Serial.print(&quot;Initializing pulse oximeter..&quot;);

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F(&quot;SSD1306 allocation failed&quot;));
    for(;;); // Don&#039;t proceed, loop forever
  }
    display.clearDisplay();
    delay(1000);

    // Initialize the PulseOximeter instance
    // Failures are generally due to an improper I2C wiring, missing power supply
    // or wrong target chip
    if (!pox.begin()) {
        Serial.println(&quot;FAILED&quot;);
        for(;;);
    } else {
        Serial.println(&quot;SUCCESS&quot;);
    }
 
    // The default current for the IR LED is 50mA and it could be changed
    //   by uncommenting the following line. Check MAX30100_Registers.h for all the
    //   available options.
    // pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
 
    // Register a callback for the beat detection
    pox.setOnBeatDetectedCallback(onBeatDetected);
}
 
void loop()
{
    // Make sure to call update as fast as possible
    pox.update();
 
    // Asynchronously dump heart rate and oxidation levels to the serial
    // For both, a value of 0 means &quot;invalid&quot;
    if (millis() - tsLastReport &gt; REPORTING_PERIOD_MS) {
        Serial.print(&quot;Heart rate:&quot;);
        Serial.print(pox.getHeartRate());
        Serial.print(&quot;bpm / SpO2:&quot;);
        Serial.print(pox.getSpO2());
        Serial.println(&quot;%&quot;);
        display.clearDisplay();
        display.cp437(true);         // Use full 256 char &#039;Code Page 437&#039; font
        display.setTextSize(1);      // Normal 1:1 pixel scale
        display.setTextColor(SSD1306_WHITE); // Draw white text
        display.setCursor(0, 6);    
        display.println(F(&quot;SpO2       %&quot;)); 
        display.setCursor(0, 38);    
        display.println(F(&quot;Heart           bpm&quot;)); 
        display.setTextSize(2);      // Normal 1:1 pixel scale
        display.setCursor(36, 0);
        display.println(pox.getSpO2()); 
        display.setCursor(36, 32);
        display.println(pox.getHeartRate(),1); 
        display.display();
         
        tsLastReport = millis();
    }
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Hi Mike &#8211; yes that&#8217;s right, the HEX file was built for a V2 micro:bit so would not work on a V1. You may be able to use the Arduino IDE and the Oxullo library to target a V1 micro:bit instead of a V2 when you compile the code. I can&#8217;t test this but I had a go at recompiling it for a V1 micro:bit here: <a href="https://raw.githubusercontent.com/blogmywiki/microbit-MAX30100/main/max30100.ino.BBCmicrobit.hex" rel="nofollow">https://raw.githubusercontent.com/blogmywiki/microbit-MAX30100/main/max30100.ino.BBCmicrobit.hex</a></p>
<p>My program, including the OLED display, looked like this:<br />
<code><br />
#include <wire .h><br />
#include "MAX30100_PulseOximeter.h"<br />
#include <adafruit_ssd1306 .h><br />
#include <adafruit_gfx .h><br />
//#include <splash .h><br />
//#include <adafruit_microbit .h><br />
//Adafruit_Microbit_Matrix microbit;</p>
<p>#define SCREEN_WIDTH 128 // OLED display width, in pixels<br />
#define SCREEN_HEIGHT 64 // OLED display height, in pixels<br />
#define OLED_RESET     -1 // Reset pin # (4 or -1 if sharing Arduino reset pin)<br />
#define SCREEN_ADDRESS 0x3C<br />
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &#038;Wire, OLED_RESET);</p>
<p>#define REPORTING_PERIOD_MS     1000</p>
<p>// PulseOximeter is the higher level interface to the sensor<br />
// it offers:<br />
//  * beat detection reporting<br />
//  * heart rate calculation<br />
//  * SpO2 (oxidation level) calculation<br />
PulseOximeter pox;</p>
<p>uint32_t tsLastReport = 0;</p>
<p>// Callback (registered below) fired when a pulse is detected<br />
void onBeatDetected()<br />
{<br />
    Serial.println("Beat!");<br />
    display.setCursor(100, 0);<br />
    display.write(3);<br />
    display.display();<br />
}</p>
<p>void setup()<br />
{<br />
    Serial.begin(115200);<br />
//    microbit.begin();<br />
    Serial.print("Initializing pulse oximeter..");</p>
<p>  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally<br />
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {<br />
    Serial.println(F("SSD1306 allocation failed"));<br />
    for(;;); // Don't proceed, loop forever<br />
  }<br />
    display.clearDisplay();<br />
    delay(1000);</p>
<p>    // Initialize the PulseOximeter instance<br />
    // Failures are generally due to an improper I2C wiring, missing power supply<br />
    // or wrong target chip<br />
    if (!pox.begin()) {<br />
        Serial.println("FAILED");<br />
        for(;;);<br />
    } else {<br />
        Serial.println("SUCCESS");<br />
    }</p>
<p>    // The default current for the IR LED is 50mA and it could be changed<br />
    //   by uncommenting the following line. Check MAX30100_Registers.h for all the<br />
    //   available options.<br />
    // pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);</p>
<p>    // Register a callback for the beat detection<br />
    pox.setOnBeatDetectedCallback(onBeatDetected);<br />
}</p>
<p>void loop()<br />
{<br />
    // Make sure to call update as fast as possible<br />
    pox.update();</p>
<p>    // Asynchronously dump heart rate and oxidation levels to the serial<br />
    // For both, a value of 0 means "invalid"<br />
    if (millis() - tsLastReport > REPORTING_PERIOD_MS) {<br />
        Serial.print("Heart rate:");<br />
        Serial.print(pox.getHeartRate());<br />
        Serial.print("bpm / SpO2:");<br />
        Serial.print(pox.getSpO2());<br />
        Serial.println("%");<br />
        display.clearDisplay();<br />
        display.cp437(true);         // Use full 256 char 'Code Page 437' font<br />
        display.setTextSize(1);      // Normal 1:1 pixel scale<br />
        display.setTextColor(SSD1306_WHITE); // Draw white text<br />
        display.setCursor(0, 6);<br />
        display.println(F("SpO2       %"));<br />
        display.setCursor(0, 38);<br />
        display.println(F("Heart           bpm"));<br />
        display.setTextSize(2);      // Normal 1:1 pixel scale<br />
        display.setCursor(36, 0);<br />
        display.println(pox.getSpO2());<br />
        display.setCursor(36, 32);<br />
        display.println(pox.getHeartRate(),1);<br />
        display.display();</p>
<p>        tsLastReport = millis();<br />
    }<br />
}<br />
</adafruit_microbit></splash></adafruit_gfx></adafruit_ssd1306></wire></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Tam</title>
		<link>http://www.suppertime.co.uk/blogmywiki/2021/09/microbit-pulse-oximeter/#comment-103256</link>
		<dc:creator>Mike Tam</dc:creator>
		<pubDate>Wed, 18 May 2022 09:54:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.suppertime.co.uk/blogmywiki/?p=4127#comment-103256</guid>
		<description>Dear Sir,

I am looking for a working code for reading the MAX30100 for Micro:Bit V1.

Your HEX file simply didn&#039;t work.

Thank you very much in advanced.</description>
		<content:encoded><![CDATA[<p>Dear Sir,</p>
<p>I am looking for a working code for reading the MAX30100 for Micro:Bit V1.</p>
<p>Your HEX file simply didn&#8217;t work.</p>
<p>Thank you very much in advanced.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
