Biofeedback Smartwatch Update

I’ve been busy recently, with finishing my doctorate and a month long trip. However, I now have a fully wireless biofeedback smartwatch prototype.

The picture is not fully assembled, but everything works other than the lack of a power switch, usb plug, and IC for charging the Li+ battery on the back. I’ve switched from using a naked nRF52810 IC to a TAIYO YUDEN module, it is more expensive, but I was having a lot of trouble getting antennas to work. The wires to the right are for programming with SWD, and the pair of magnet wires soldered to the board itself are for power so I don’t rundown the battery in testing. To the right of the module are two holes for debugging with UART; it’s been really helpful to use that and the logic analyzer to test things during development.

On the finger strap are two electrodes for the GSR voltage bridge, and the MAX30102 SPO2 sensor, which is soldered onto a PCB out of view.

I’m using the following program to activate the ADC and SPO2 sensor and broadcast data over bluetooth. I’m using the nordic UART profile, which contains two characteristics, a read and a write one. I’ve had to learn a lot more about bluetooth than I wanted to for this project.

You can see in the above picture I can stream to my laptop, which live plots the data with matplotlib. I’ve had issues with plot update speeds… it sounds like pyqtgraph is a lot faster but not what I want. I’m probably going to try gnuplot if this is still an issue.

On the plotting side, it’s the same as usual, except with the source of data being:

subprocess.Popen("sudo gatttool -i hci0 -t random -b (nrf mac address) --char-write-req -a 0x10 -n 0100 --listen",shell=True,stdout=subprocess.PIPE)

Which writes 1 (0100 reverse endian) to the handle of the characteristic to enable notifications (0x10). Again, there’s a better way to do this with the actual gatt libraries.

In the end I’m pretty happy with everyting. The GSR data is a lot better since switching to a TI adc (ads1246), and the setup is not that encumbering overall. I plan on working on more data analysis for biofeedback (e.g. getting actual SPO2 values, heart rate counters,…) before doing anything with a phone app.

Photoplethysmogram 3

I’ve gotten all of the sensors working at once now. One of the changes is that I’m now using a ’24’ bit differential external ADC. I’m using the NAU7802, which communicates with I2C and runs at a very slow 10-320 SPS. This is plenty fast and seems to be high enough resolution to measure GSR without any external amplifier. The ADC also has an internal PGA which hasn’t been nessesary so far.

More restricting than it could be

The spikes in graphs below for red and IR correspond to heart rate.

I’m currently using the MAX30102’s temperature sensor (which is meant for the LEDs) to measure finger temp. I will have to decide whether this is good enough.

I made several attempts dead-bug soldering the NAU7802. What worked best was to glue to face down on a peice of cardstock and then just solder to the prongs from there.

HX711 – Dynamometer part 1

Grip strength can be used as a measure of overtraining.

There are ADC + strain gauge meters on ebay for hobby bodyweight scales (HX711) that should be good for measuring up to around 200kgs. I ordered one and plan to put the gauges between a pair of half cylinders of wood to measure grip strength.

The HX711 can communicate with microcontrollers with a 2 wire interface like I2C. I’ve gotten this working with the Nucleo and tested it by having the Nucleo output a sin wave and reading the voltage that the HX711 measured.

project stuff here, remember that all the Nucleo stuff is compiled using the mbed compiler

Voltage measured by the HX711. Output is in two’s complement, which is why the sin wave is split between top and bottom. You can see the quantization in the DACs output because there’s a minimum 64 fold amplification for the HX711. This means that even a tiny voltage swing will saturate the output.

Galvinic Skin Response and Hand Temperature

Two biofeedback sensors I can probably get working faster than the EEG are hand temperature and galvinic skin response. Hand temperature biofeedback is mostly used to train relaxation. Adrenaline restricts bloodflow to the skin and hands, so by training yourself to warm your hands you can learn to reduce adrenaline levels. Galvinic skin response is similar. People sweat more when nervous, filling sweat ducts with sweat. This is most pronounced on the hands and feet. Sweating reduces skin resistance by providing a conductive channel into the skin. This effect happens in seconds, and is used in polygraphs to detect lies.

For the most part, the resistance inside the body is low enough not to matter when measuring galvinic skin response. The simplest way to measure skin resistance is to put a current through two electrodes in contact with the skin and measure the voltage difference. This is usually done with electrodes on the index and ring fingers.

(For much more detail on measuring galvinic skin response, see Electrodermal Activity by Wolfram Boucsein)

While high temperature measurements usually use thermocouples, the easiest way to measure hand temperature is by using thermistors. The thermistors linked go between about 80k-100k Ohms around 70-100F. They are incredibly small, which gives them really fast response times and makes it easy to keep them around skin temperature.

For measuring each of these resistances, I constructed voltage bridges with instrumentation amplifiers to increase the voltage range. I then used the integrated ADCs in the Nucleo microcontroller I have to measure the voltage.

Set up the voltage bridge with R3/R4 to be a bit below the lowest voltage between R1/R5. Select gain resistor so that Vout is below 3.3V when R1 at its highest. This setup can be used with both GSR and hand temp, but will require different resistors. GSR would probably benefit with variable resistors to set gain and comparison voltage.

See for example which reads the ADC 10 times a second and communicates it to a python program on a host which plots the output.

Plot of voltage measured for thermistor as I grabbed an icepack at t=50 and t=110.
Voltage for skin resistance, again grabbing an icepack at T=220

Like the EEG project, actually having a wearable probe is difficult. For GSR, I used the following copper coils:

I also tried mounting the thermistors in sections of pipe which I could use as GSR electrodes. While it looks neat, I think it will require rings which fit better.

First Post-Light Alarm Clock

Starting with a fringe health thing that sort of works–light alarm clocks. I’ll probably post more on light later. I think I actually got seasonal affective disorder unrelated to the seasons by being a shut-in. In short, blue light suppresses melatonin production and probably wakes you up in other ways so it’s good to have some in the mornings. There are alarm clocks meant to wake you up this way, but I ended up making my own because I have some decently high powered LEDs lying around.

Say hello to my little firehazard

I did this about a year ago, so I don’t remember what the LEDs actually are. They are probably 3-5W, Chinese ones from Ebay, and all hooked up in series to a cannibalized 15W wallwart power supply with a power MOSFET that I got from a broken computer power supply as a switch. The voltage drop of the combined LEDs was just about perfect for the power supply. I had those little heatsinks lying around but they probably aren’t nessesary. This is about as bright as a normal 60W incandescent bulb when at full power. I control the brightness using PWM with a raspberry pi. See the program here (, with instructions for use in the comments.

To tell the truth, I don’t use this any more. Even the tiny amount of light that gets past my blackout blinds signals daytime if I’m ready to get up, and I’ll stay in bed if not. What has worked is using orange safety glasses before bed, to aid in melatonin production, and a lightbox upon waking up.