No Pause

Photo of knaveen

Made by knaveen

About the project

A non-invasive solution for hot flashes during menopause using machine learning

Project info

Difficulty: Difficult

Platforms: JupyterM5StackTensorFlow

Estimated time: 1 hour

License: Apache License 2.0 (Apache-2.0)

Items used in this project

Hardware components

Seeed Grove - Universal 4 Pin Buckled 5cm Cable Seeed Grove - Universal 4 Pin Buckled 5cm Cable x 1
Seeed Grove - Thermal Imaging Camera / IR Array MLX90640 55 degree Seeed Grove - Thermal Imaging Camera / IR Array MLX90640 55 degree x 1
Seeed Wio Terminal: ATSAMD51 Core Dev Board Seeed Wio Terminal: ATSAMD51 Core Dev Board x 1
M5Stack ATOM Matrix ESP32 Development Kit M5Stack ATOM Matrix ESP32 Development Kit x 1

Software apps and online services

Arduino IDE Arduino IDE
Jupyter Notebook Jupyter Notebook
TensorFlow TensorFlow



A hot flash is the sudden feeling of warmth in the upper body, which is usually most intense over the face, neck and chest. Although other medical conditions can cause them, hot flashes most commonly are due to menopause. In this project, I build a device which can be used to detect hot flashes and trigger some action to relieve the person, in this case turn on Air Conditioner cooling system using IR emitter. As its input, it takes multidimensional infrared thermal sensor data. Its output will be a simple classification that notifies us if person is recognized and there is a sudden change in temperature has recently occurred.

Hardware consideration

I wanted to make a wearable device which can read body temperature data. After doing some research and implementations I found wearing sensors all the time especially during sleeping is uncomfortable and not feasible in many cases. A hot flash can also cause sweating and wearing a battery powered device needs special housing to accurately measure data. Also, for cooling I investigated thermoelectric Peltier cooler modules and found most of them needs bulkier 12V battery to operate properly for optimal cooling and it is also unsafe if it is not controlled carefully and can cause burns. For a non-invasive solution, I found low resolution thermal camera can read temperature reliably from a distance and they can work in dark. Although the reading accuracy may be affected by distance but calculating continuous or sudden change in the thermal image data can be recorded accurately. I chose Atom Matrix as a microcontroller device because it is small, cheap, can run TensorFlow model and has an IR emitter which can be used as a remote control. I chose Wio Terminal to capture thermal camera data for training because it has an LCD screen with many buttons which is used to capture data for different categories.

Data collection for training

The first and the most important step in a machine learning project is to collect the training data in such a way that it should cover most of the representative cases for a given recognition task. The 3 buttons on the Wio Terminal was used to label the 3 classes.

The captured data is saved to the files on a micro SD card attached to the Wio Terminal. Each thermal image data was captured as a separate file. The file contains no header line, only the comma-separated 768 (24x32) temperature readings. An example readings file contents looks like as follows.


The visual representation of the captured data is as follows:

Thermal Images for 3 categories

An Arduino sketch (Thermal_camera_data_collection.ino) to capture training data is available at the Github repository mentioned in the code section.

Data collection session video

Data splits for training and validation

The data were captured for 3 categories: person (in different orientations and postures), hot or cold objects, and background (nearly uniform temperature for example, wall or empty room). A little over 100 samples for each classes were captured. The collected data has been split into training (60%), validation (20%), and testing (20%) datasets. Since the data was collected from the infrared temperature camera (MLX90640) which is already calibrated and they are already within a specified range so we can use the raw data as is for training and inferencing.

Model Architecture

We can think of the input data as an image of 24x36 pixels. A convolutional neural network is one of the best options suited for recognizing patterns in images and time-series sequence data. The first few layers are 2D convolution neural networks with few other regularization layers. The last layer is a fully connected dense layer with softmax activation which outputs a probability of all 3 classes. The summary of the model is given below.

  1. Model: "sequential"
  2. _________________________________________________________________
  3. Layer (type) Output Shape Param #
  4. =================================================================
  5. conv2d (Conv2D) (None, 24, 32, 8) 80
  6. _________________________________________________________________
  7. conv2d_1 (Conv2D) (None, 24, 32, 8) 584
  8. _________________________________________________________________
  9. max_pooling2d (MaxPooling2D) (None, 12, 16, 8) 0
  10. _________________________________________________________________
  11. dropout (Dropout) (None, 12, 16, 8) 0
  12. _________________________________________________________________
  13. conv2d_2 (Conv2D) (None, 12, 16, 8) 584
  14. _________________________________________________________________
  15. max_pooling2d_1 (MaxPooling2 (None, 6, 8, 8) 0
  16. _________________________________________________________________
  17. dropout_1 (Dropout) (None, 6, 8, 8) 0
  18. _________________________________________________________________
  19. conv2d_3 (Conv2D) (None, 6, 8, 16) 1168
  20. _________________________________________________________________
  21. max_pooling2d_2 (MaxPooling2 (None, 3, 4, 16) 0
  22. _________________________________________________________________
  23. dropout_2 (Dropout) (None, 3, 4, 16) 0
  24. _________________________________________________________________
  25. conv2d_4 (Conv2D) (None, 3, 4, 16) 2320
  26. _________________________________________________________________
  27. flatten (Flatten) (None, 192) 0
  28. _________________________________________________________________
  29. dense (Dense) (None, 64) 12352
  30. _________________________________________________________________
  31. dropout_3 (Dropout) (None, 64) 0
  32. _________________________________________________________________
  33. dense_1 (Dense) (None, 32) 2080
  34. _________________________________________________________________
  35. dropout_4 (Dropout) (None, 32) 0
  36. _________________________________________________________________
  37. dense_2 (Dense) (None, 3) 99
  38. =================================================================
  39. Total params: 19,267
  40. Trainable params: 19,267
  41. Non-trainable params: 0

Model Training and Evaluation

The training of the model was done on an Intel NUC with Linux and an eGPU (NVIDIA GTX 1080Ti). Although it just takes couples of minutes to train on a CPU but the development process becomes pretty slow while testing out different architectures and hyper-parameters. The TensorFlow 2.1 with Keras API is used for model creation and training process. I created a Jupyter notebook for data processing, training and the final model conversion. All code are available at Github repository which is mentioned in the code section. The training accuracy is 99% and evaluation accuracy on test data is 92.86% which can be further improved with more training datasets and model hyper-parameters tuning.

Inferencing on the device

The created model is converted to the TensorFlow Lite model and the converted model is transformed into a C array file for deploying with the inferencing code. The TensorFlow Lite Micro SDK is used to run inference on the device. I have created an Arduino sketch (Hot_flash_detector.ino available at Github repository) for inferencing and displaying the result. The microcontroller receives the samples continuously from the thermal camera sensor at the interval of 500ms and detect the sudden change in the temperature of the recognized person based on last 20 average maximum temperature readings.

Inferencing demo

The use cases for common benefit and cost

It is an easy to use low-powered device which can run on battery for weeks. It can be used safely for women facing hot flashes problem during day or night. This device is also low cost. The total cost of the final working product (Thermal camera + Atom matrix) is well below 50 USD and can be further reduced if it is mass produced.

Scope for improvement

The device can be used to detect sleeping problem by analyzing thermal images time-series data and can trigger a music system to play some soothing music or control smart lighting systems. Also, some analytics data can be saved locally at the Atom Matrix's SPI flash memory and can be synced using a mobile phone app over BLE for further analysis.

Schematics and circuit diagrams

Schematics 1


Hot Flash Detector


Photo of knaveen


Bioinformatician, Researcher, Programmer, Maker, Community contributor Machine Learning Tokyo


Leave your feedback...