Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: AmbientLib SimpleIoTBoardLib mbed
Fork of AmbientHeartRateMonitor by
main.cpp
- Committer:
- aramon
- Date:
- 2018-04-19
- Revision:
- 5:018a96030e83
- Parent:
- 2:dd2248c73ad5
File content as of revision 5:018a96030e83:
/* * Every 5 seconds, send the BPM value to Ambient. * Turn on and off the LED. */ #include "mbed.h" #include "math.h" #include "ESP8266Interface.h" #include "TCPSocketConnection.h" #include "SoftSerialSendOnry.h" #include "Ambient.h" ESP8266Interface wifi(dp16,dp15,dp4,".KSUISIC-12621-2","0926735432",115200); // TX,RX,Reset,SSID,Password,Baud SoftSerialSendOnry pc(dp10); unsigned int channelId = 3920; const char* writeKey = "7b76d2af7cd9d0da"; Ambient ambient; extern void interruptSetup(); // Volatile Variables, used in the interrupt service routine! extern volatile bool QS; // becomes true when Arduoino finds a beat. extern volatile int BPM; // int that holds raw Analog in 0. updated every 2mS int main() { TCPSocketConnection socket; pc.baud(9600); wifi.init(); //Reset wifi.connect(); //Use DHCP pc.printf("IP Address is %s\r\n", wifi.getIPAddress()); ambient.init(channelId, writeKey, &socket); interruptSetup(); while (true) { char bpmbuf[12]; if (QS == true){ // A Heartbeat Was Found // BPM and IBI have been Determined // Quantified Self "QS" true when mbed finds a heartbeat sprintf(bpmbuf, "%3d", BPM); pc.printf("BPM:%s\r\n", bpmbuf); ambient.set(1, bpmbuf); ambient.send(); QS = false; // reset the Quantified Self flag for next time } wait(5); // take a break } }