This project seeks to ease hot flashes which is a common Menopause symptom, it is an IOT system made of a wearable device tracking user's skin temperature and movement during sleep. The wearable device sends temperature and movement data to a fan controller over Bluetooth LE (BLE), the fan is activated when skin temperature increases and data is logged on a cloud service. The user can also use Google Assistant to change fan speed.
Keep in mind this project will not prevent you from having hot flashes but could make you feel relieved, always consult with your doctor. We think the project can not only be beneficial for women during Menopause but people who suffer from night sweats, thus improving sleep quality.
We wanted to build something with boards/sensors having already at home due to COVID-19 quarantine it made it harder to get more materials. I will try to describe how Abraham and I developed this work in progress project, some of the challenges we had and how we tried to solve them.
The wearable deviceThe project is built around STMicroelectronics STEVAL-BCN002V1Bdevelopment kit a.k.a. BlueTile.
The STEVAL-BCN002V1B Bluetooth LE enabled sensor node development kit features the STEVAL-BCN002V1 multi-sensor board based on BlueNRG-2 SoC Bluetooth Low Energy application processor. This sensor board has accelerometer, gyroscope, magnetometer, pressure, humidity, Time-of-Flight and microphone sensors, and is powered by a common CR2032 coin battery[1].
TheBlueNRG-2 SoC on the sensor board can connect to your smart phone using STMicro Sensor Demo App available for Android and iOS using the default program.
These are some of the features you can do with the Sensor Demo App you can even log data, this feature sends CSV file to your e-mail.
To program the sensor board we used the STEVAL-BCN002V1Dprogramming board available when you get the kit. There are many ways you can program the the sensor board, here is a user manual.
We used the BlueNRG-2 Navigator to get familiar with the sensor board, there are a bunch of examples you can use. Here is a data brief.
The BlueNRG-2 Navigator projects are available for Keil and Atollic. The program running on the sensor board is the Sensor Demo App
. First we attempted to change the device local name in sensors.c
, just to make sure modifying the source code and program the board was feasible.
To achieve this, we used the BlueNRG-1_2 flasherutility after generating hex file using Keil.
Is worth mentioning that before flashing the application, one must load the Service Manager OTA
first using the flasher utility, then the generated hex file for the application.
The actual device name is BCN-002, but not sure what is the difference with local name.
In the Sensor_DeviceInit()
function in the sensors.c
file changed the aci_gap_set_authentication_requirement
to remove the pin pairing. Just change the USE_FIXED_PIN_FOR_PAIRING
to DONOT_USE_FIXED_PIN_FOR_PAIRING
To build a BLE client for the sensor board, you have to get the Service UUID and Characteristic UUID more on BLE here.
ST Micro has documentation on how to program the BlueNRG-2and details about the services, but we used BLE scanner to search for available services and characteristics.
BlueNRG-2has 3 services, but sensor data is under service 00000000-0001-11E1-9AB4-0002A5D5C51B
. Service 00000000-000E
and 00000000-000F
are debug and configuration. More here on section 3.
These are the characteristics available under service 00000000-0001-11E1-9AB4-0002A5D5C51B
001c0000-0001-11E1-AC36-0002A5D5C51B
- Environmental00000100-0001-11E1-AC36-0002A5D5C51B
- SensorFusion40000000-0001-11E1-AC36-0002A5D5C51B
- ?00000400-0001-11E1-AC36-0002A5D5C51B
- Accelerometer Event00020000-0001-11E1-AC36-0002A5D5C51B
- Gauge (for battery level)00000040-0001-11E1-AC36-0002A5D5C51B
- Compass20000000-0001-11E1-AC36-0002A5D5C51B
- LED08000000-0001-11E1-AC36-0002A5D5C51B
- Audio00E00000-0001-11E1-AC36-0002A5D5C51B
- Motion Sensor02000000-0001-11E1-AC36-0002A5D5C51B
- Proximity
We used DOIT Esp32 DevKit v1 to attempt a connection to the sensor board, based on Arduino BLE client example in the library manager for ESP32.
The program looks for Service 00000000-0001-11E1-9AB4-0002A5D5C51B
and 001c0000-0001-11E1-AC36-0002A5D5C51B
environmental characteristic.
// The remote service we wish to connect to.
static BLEUUID serviceUUID("00000000-0001-11E1-9AB4-0002A5D5C51B");
// The characteristic of the remote service we are interested in.
static BLEUUID char1UUID("001c0000-0001-11E1-AC36-0002A5D5C51B"); //Env
While scanning BLE devices, ESP32 was able to see the sensor board but not able to connect to it.
To make sure the ESP32 sketch was working, we used a fitness band (server) and ESP32 (client) and connection was successful, but it hanged when creating the client.
We came across to Neil Kolban's ESP32-snippets it seems the Arduino Library had an issue with semaphores, so we built the new library and reprogrammed the ESP32.
But still ESP32 was unable to connect to the sensor board. We attempted a connection using the MAC address instead, which was determined at the time of BLE devices scanning.
std::string My_BLE_Address = "ec:4d:a6:01:a1:eb";
The BLE advertised device function is called when the MAC address is found instead of the Service UUID.
// We have found a device, let us now see if it contains the service we are looking for.
if (advertisedDevice.getAddress().toString()== My_BLE_Address ) {
Serial.println("Found DEVICE!");
BLEDevice::getScan()->stop();
myDevice = new BLEAdvertisedDevice(advertisedDevice);
doConnect = true;
doScan = true;
And then the ESP32 was able to create a connection with the sensor board, the connection didn't hang. We need to investigate why the Services are not visible in the sensor board when scanning.
The BLE client example has a Notify callback function, but the data was not being displayed correctly. Update the callback function was needed (done by Andreas Spiess ) to display raw data.
The gatt_db.c
file includes the functions to update the characteristics values.
/**
* @brief Update Environmental characteristic value
* @param int32_t Press Pressure in mbar
* @param uint16_t Hum humidity RH (Relative Humidity) in thenths of %
* @param int16_t Temp1 Temperature in tenths of degree
* @retval tBleStatus Status
*/
tBleStatus Environmental_Update(int32_t Press, uint16_t Hum, int16_t Temp) {
uint8_t BuffPos = 0;
We got some logs using the ST sensor demo app.
In the temperature log, 0x1B01
MSB is 0x01 = 283 dec
, but is expressed on "tenths of degrees" that would make it 28.3°C.
We used a similar approach to get humidity and pressure values. And then environmental data was displayed on the console in a much understandable way.
Included only two more characteristics:
The MotionSensor (MotionFX). This characteristic uses quaternions more on this here. this data would represent movement of the user during sleep hours, maybe this could be used to estimate sleep quality.
The MotionFX is a middleware library component of the X-CUBE-MEMS1 software and runs on STM32. It provides real-time motion-sensor data fusion. It also performs gyroscope bias and magnetometer hard iron calibration[2].
The Gauge. The gauge characteristic sends the voltage of the battery in mV.
All characteristics have properties: READ, NOTIFY, WRITE, etc. More on this here. The ESP32 BLE client on Arduino has a notify and read callbacks, the main difference is a notification is sent by the server when a characteristic value changes.
To get data, enabling and disabling notifications must be done, there sure is a better way to do this but it seems that sending NULL
will disable notify.
if(p1RemoteCharacteristic->canNotify())
p1RemoteCharacteristic->registerForNotify(NotifyCallback);
//Serial.println("Unregister for notifying!");
delay(100);
p1RemoteCharacteristic->registerForNotify(NULL);
At this point we were ready to configure the ESP32 to connect to Adafruit IO.
IFTTT AppletsSince we wanted to control an AC fan speed we thought it would be nice if can be voice controlled using Google Assistant.
We created the following applets on IFTTT: high speed, low speed,turnoff and automode to control the small fan that would be placed on a night stand table. Auto mode is intended to power on/off the fan based on skin temperature changes which could indicate hot flash episodes.
The DOIT Esp32 DevKit v1 board had only 4MB of memory so merging the BLE and MQTT didn't fit :(
Abraham had spare 16MB ESP32 WRover modules that he used in a different project.
We used Abraham's ODOROID-GO custom PCB, he hand soldered the minimum required components to enable the ESP32 WRover module: USB to Serial, USB connector, 3.3V LDO, etc.
Only a few GPIOs are used, so the header on the left (where a SPI tft screen is mounted) had enough GPIOs to control the relay boards.
The ESP32 GPIOs are not 5V tolerant so Abraham made this small shield for 2 relays, power supply and the reset button.
Buttons could be used in the future.
Controlling fanThe fan can be controlled with the following modes.
- Low speed.
- High speed.
- Auto mode. it will track temperature increases over 2°C powering fan to high speed for some time. If temperature is over 32°C it will power on the fan too.
We used hair dryer to increment the temperature that is why current temperature is over 41°C at the beginning of this video.
And we used Google Assistant to test the IFTTT applets we created. In the video voice commands appear in this order: low speed, high speed and auto mode.
Power off mode can be seen at the end of the video (00:43).
Logging dataWe are using Adafruit IO to log data of the sensors, these are our feeds:
- Temperature.
- Humidity.
- Pressure.
- User motion over time.
- Hot flashes episodes over time.
- Battery level.
Ten temperature points are averaged and then published, the current and last averaged values are compared, if there is an increment of 2°C this system assumes is a hot flash event as you can see in this video.
This feature still needs to be refined, perhaps averaging temperature notifications over a greater amount of time and not only after publishing. We used a hair dryer to increase the temperature, the first pulse is false hot flash when the board is powered, we need to fix that, but the next 2 temperature peaks represent hot flash events.
The sensor board is placed inside a 3D printed case.
The case has an opening for the temperature sensor and the reset button
Temperature sensor should be in contact with skin but we need to gather more information like if the HTS221 is the correct sensor for skin temperature. Additionally we need to figure out the correct location of the sensor, perhaps inside the wrist or closer to the chest.
Future workThe sensor board has many sensors that could be used to gather more information for instance:
- MEMS microphone could be used to monitor snoring.
- Motion FX sensor even the position of your sleep could be inferred.
- The BlueNRG-2 also has a characteristic for free fall detection.
Maybe a thermistor or an IR thermometer could be a better approach for skin temperature measurement. Additionally, the placement of the sensor is also important but it has to be non-invasive in order to be worn while sleeping.
In addition to the increase in the temperature of the skin, a hot flash may cause an increase in a woman's heart rate. This causes sudden perspiration as the body tries to reduce its temperature. This symptom may also be accompanied by heart palpitations and dizziness[3].
Heart rate measurements could make this project more robust and maybe could be used to predict hot flashes.
The use of small AC fan was chosen for simplicity, but biometric data could be used to trigger more sophisticated actuators.
We still need to fix the Arduino sketch for bugs and optimize it.
ConclusionHaving a nice breeze of fresh air at any time on a hot day is nice, but getting an immediate relief at the time of a hot flash is even nicer!
With this project we intended to address one of the most recurrent symptoms of menopause. Since the Automode is a simple ON/OFF control, no sophisticated algorithms and electronics were required.
Most of the time was spent figuring out how to get the BLE devices working as intended. We took advantage of the bluetile small size an low power consumption to build a small application that can be extended beyond of what we currently presented.
Hopefully you like it!
Comments