Iteration 4/5 Jack - Improving Sensor Values readouts and Finalising.
Introduction:
This iteration involved updating the code and improving the outputs for both the Pulse Sensor and Breathing iterations of the project. This iteration is also the final one where everything is being closed off. I was responsible for upgrading and improving the functionality of the sensors while Dominik worked on sorting out the cloud connectivity with MQTT and the hardware side of the hat.
Changes:
The sensors need to be adjusted to work better. Some general adjustments were made to the systems to function more consistently. These changes ranged from adjustments to values like thresholds/slopes or even adding flags and triggers to the system.
I also needed to add a few more value outputs to the system, including:
- Pulse Sensor BPM
- Breathing In Time
- Breathing Hold Time
- Breathing Out Time
- Breaths per Minute
Pulse Sensor BPM:
The BPM of the pulse sensor was pretty easy to calculate. The system already counted the pulses so I just had to count every second one. This was because each heartbeat has 2 main peaks ber beat which the system picks up.
Due to the fact that the system picks up 2 peaks per beat (the "dun dun" of the heartbeat) this only calculates the BPM on every second "beat" reading that the system picks up.
Breathing Values:
Getting the values for the breathing was a bit more difficult. The set up I ended up going with was a counter system. A counter would count from 0 to 3 and then reset. For each value on this counter the previous time between counts was stored and a different calculation was made. Below is an example of how a breath is split up.
For the first count for example that was the breath in time, so it would be calculated using the previous count time, and the same for the hold and out times for the second and third respectively.
On the final count, the total time of the count would be held and used to calculate the breaths per minute.
All together this system looks like this:
Finished Product:
Here is a video of the final steampunk hat in action:
The hat has a bellows controlled by the breathing, a heart light controlled by the pulse sensor level and MQTT to allow for many of the sensor readings to be accessible on the cloud. Overall it is a pretty cool and functional piece of wearable tech!
Pulse Sensor Code: https://makecode.microbit.org/_deyJPxApfiAA
Breathing Code 1: https://makecode.microbit.org/_HEAV8t4oUMUg
Breathing Code 2: https://makecode.microbit.org/98564-45141-22974-62247
Comments
Post a Comment