Wednesday, April 17, 2019

Cumulative Stress Monitor

Here's how I think a "Cumulative Stress Monitor" could be made from existing Adafruit Classic Circuit Playground (CP) “Meditation Trainer” Sketch (Arduino related)....

I'm working on my own model and will keep the world updated as I progress, via this blog post.  Otherwise, you can always contact me at  tgideas@gmail.com

Here is the Meditation Trainer Sketch that is to be modified.  Please note that it will verify/compile only on Arduino IDE 1.8.5 or below.  The sketch will not compile on more recent IDE’s.  I have a “fix” for this, if you need it. 

Please look at the code above before reading further.

Here is general information on the Meditation Trainer to help you better understand the concept.  Here is general information on the Classic Circuit Playground (CP)

Meditation Trainer Sketch Changes or Additions:  (make new variables as needed)

1.    Change relaxation blue color to yellow color (moderate relaxation).  This relates to “else (tCoh >= 3)” in sketch. See Using the LED Display to understand concept.  Might this help you code yellow?

2.    Change so that Breathing Pacer pixels only work when tCoh >= 3 and do not work when tCoh < 3.  See Breathing to understand concept. 

3.    Measure the ongoing time durations of each of these variables – in each ongoing 30 minutes:

a.     tCoh >= 6, (Hi Stress Level)

b.    tCoh >= 3 and <6, (Medium Stress Level)

c.    tCoh < 3. (Low Stress Level)

4.    Add code – (If (tCoh >= 6 time duration) minus 1/2 (tCoh < 3 time duration)) > 15 minutes, then turn on the onboard CP Buzzer.  Or, (If (tCoh >= 3 and <6 time duration) minus (tCoh < 3 time duration)) > 15 minutes, then turn on the onboard CP Buzzer. 

The concept above is to make a Cumulative Stress Alert.  Examples of concept above….(Make code do the task below, please)

·         30 minutes Hi Stress – ½ X 30 minutes Low Stress = 15 minutes (Buzzer off)

·         30 minutes Hi Stress – ½ X 20 minutes Low Stress = 20 minutes (Buzzer on)

·         30 minutes Medium Stress – 1X 15 minutes Low Stress = 15 minutes (Buzzer off)

·         30 minutes Medium Stress – 1X 10 minutes Low Stress = 20 minutes (Buzzer on)

When conditions are met above, please make the buzzer beep on and off (1 second intervals) at 1000 hz. for a duration of 5 seconds, every 30 minutes, until the “if/then coding” above turns off the buzzer (tCoh conditions above are not met). 

5.    Add code for a tCoh potentiometer, to test the operation of the concepts.  Please use D9 / A9 - This pin can be digital I/O, or Analog Input.  Might this Analog Input Information help you code?  With this Potentiometer, I’d like to change from tCoh = 1 to tCoh=7 from min to max of potentiometer.  I’d also like to view all the time the tCoh on the Arduino IDE Serial Monitor, whether in the test mode (potentiometer) or in actual use.  I’ll use a Panel Mount 10K Potentiometer.

6.    Add code for Bluetooth so that any Bluetooth device can at least read the following:

a.    Analog signal from Circuit Playground pin #6 – (int pulsePin = 7;  // Pulse Sensor purple wire connected to analog pin 7) (D6 / A7 - This pin can be digital I/O, or Analog Input.) – This analog signal is a waveform of the sensed heartbeat.  This could also be a Square Wave, too, depending on Pulse Sensor D/A switch position. 

b.    tCoh – (coherence values total)

Please add Comments in the code how to add future variables, I/O pins, etc. for future “reading” by other Bluetooth Devices.  

I’m using a Flora Bluefruit LE with my CP.  I’m planning on using another Flora Bluefruit LE with another CP.  The two CP’s would “Bluetooth talk” to one another.  In addition, the BLE should be able to wirelessly link to other Bluetooth devices such as Medical Equipment, Computers, Phones, etc.

Might this information help you code?  Circuit Playground & Bluetooth Low Energy and iOS Setup | Bluefruit LE Connect for iOS |

7.    If possible - When conditions are met to activate Buzzer above (#4), add code to send text message to a smartphone.  The text should read “Stress/Pain Alert – Patient 34-2”.  Repeat sending message every 30 minutes until conditions are not met to activate Buzzer.  If not easily possible – please make a digital pin go high when conditions (#4) are met above.  (I’ll interface this digital pin to an existing Nurse Call System) 

General Notes –

·         Please let me know if you have questions – either now or when coding.  Also, feel free to suggest better ways of doing the above.  I’d like to use the parts I mentioned above and the original “Meditation Trainer” Sketch as a start though.

·         Please add comments as you code. 

·         Please try not to block sketch execution with unnecessary delays.

The big picture in doing all this above is to make a Stress/Distress/Pain Monitor for both Patients and Healthcare Workers.  The above is an improved version of my previous Model.  The improved model above uses heart rate variability, instead of skin conductance as used in the previous model, and has additional features not in the previous model.

Thanks

Tom Garz



Disclaimer - Article is for information only and is not medical advice.