I am looking to save pulse and SPO2 readings from the cooking hacks e-health sensor platform (link below) onto my Arduino Uno's EEPROM then remove the health shield and use an Ethernet shield to move the data. My code is as below:
#include <PinChangeInt.h>
#include <eHealth.h>
#include <EEPROM.h>
int cont = 0;
int addr = 0;
int BPM;
int SPO2;
void setup() {
Serial.begin(115200);
eHealth.initPulsioximeter();
//Attach the inttruptions for using the pulsioximeter.
PCintPort::attachInterrupt(6, readPulsioximeter, RISING);
}
void loop() {
Serial.print("PRbpm : ");
Serial.print(eHealth.getBPM());
BPM = eHealth.getBPM();
Serial.print(" %SPo2 : ");
Serial.print(eHealth.getOxygenSaturation());
SPO2 = eHealth.getOxygenSaturation();
Serial.print("\n");
Serial.println("=============================");
EEPROM.write(0,eHealth.getBPM());
delay(500);
}
//Include always this code when using the pulsioximeter sensor
//=========================================================================
void readPulsioximeter(){
cont ++;
if (cont == 50) { //Get only of one 50 measures to reduce the latency
eHealth.readPulsioximeter();
cont = 0;
}
}
The two readings I am trying to save and then load onto another sketch are BPM and SPO2, does the line: EEPROM.write(0,eHealth.getBPM());
make sense and how would I also save and send the second reading SPO2? Any help appreciated or any knowledge of why my idea will not work also appreciated, thanks.Cooking-hacks sensors shield
It look like you are trying to write to the EEPROM each measurement. EEPROM has limited amount of writes. Datasheet states 100k which would be wasted in 14 hours. Write less often, the values cannot change faster anyway.
topping25:
how would I also save and send the second reading SPO2?
Since BPM is an int it will take two bytes of EEPROM, addresses 0 and 1. So you would need to choose the address 2 or higher to use for writing the SP02 value to:
EEPROM.put(2, SPO2)
To read from those addresses:
int BPM;
EEPROM.get(0, BPM);
int SPO2;
EEPROM.get(2, SPO2);
It would seem to make sense to add an SD card module to your project and save the data on the SD card. Then you could remove the SD card, take it to any card reader, and download the data. They are pretty inexpensive, as shown here.
OMG read my signature
I know it is not your fault but why BPM is int??? Anyone expects to measure more than 255 BPM? On a human? With SpO2 meter? Very unlikely.
The same is true for SpO2 itself? It may be more than 100(%)?
I didn't consider whether the types were appropriate for the application or even what the application was. byte also makes the code a little more simple because you can use EEPROM.update() and EEPROM.read() instead of EEPROM.put() and EEPROM.get() and it's less confusing for addressing.