Main Content

Log UV & weather data on an SD card to train an Edge Impulse model. Then, run it to get informed of sun damage over BLE via an Android app.

Although many of us enjoy a sunny day in our leisure time, the glaring sun can affect our health detrimentally, especially for the elderly, children, and people with light skin. Excess sun exposure can cause minor health conditions such as sunburn, dehydration, hyponatremia, heatstroke, etc. In more severe cases, excess sun exposure can engender photoaging, DNA damage, skin cancer, immunosuppression, and eye damage, such as cataracts[1]. Therefore, it is crucial to detect sun damage risk levels so as to get prescient warnings regarding potential health risks to mitigate the brunt of inadvertent excess sun exposure.

The sun emits energy over a broad spectrum of wavelengths: visible light, infrared radiation generating heat, and UV (ultraviolet) radiation hidden from our senses. Although UV radiation affects our health positively in moderation, such as instigating the production of vitamin D, sun damage is mostly engendered by overexposure to UV radiation since it has a higher frequency and lower wavelength than visible light.

The UV region covers the wavelength range of 100-400 nm and is divided into three bands:

- UVA (315-400 nm)
- UVB (280-315 nm)
- UVC (100-280 nm)

After perusing recent research papers on UV radiation, I decided to utilize UV index (UVI), temperature, pressure, and altitude measurements denoting the amount of UV radiation from the sun so as to create a budget-friendly BLE smartwatch to forecast sun damage risk levels in the hope of prewarning the user, especially risk groups, of potential sun damage risk to avert severe health conditions related to excess sun exposure, such as immune system damage and melanoma (skin cancer).

The ultraviolet index (UV index) is an international standard measurement of the strength of the sunburn-producing UV (ultraviolet) radiation. In other words, the UV index forecasts the strength of the sun’s harmful rays. Since it is designed as an open-ended linear scale, directly proportional to the intensity of UV radiation, the higher the number, the greater the chance of sun damage. An increase in the UV index value corresponds to a constant decrease in time to sunburn. Therefore, higher values represent a greater risk of sunburn and excess UV radiation exposure.

Even though UV index, temperature, pressure, and altitude measurements provide insight into detecting sun damage, it is not possible to extrapolate and construe sun damage risk levels precisely by merely employing limited data without applying complex algorithms since sun damage risk levels fluctuate according to various phenomena, some of which are not fully fathomed yet. Hence, I decided to build and train an artificial neural network model by utilizing the empirically assigned sun damage risk classes to forecast sun damage risk levels based on UV index, temperature, pressure, and altitude measurements.

Since XIAO BLE (nRF52840) is an ultra-small size Bluetooth development board that can easily collect data and run my neural netwrok model after being trained to forecast sun damage risk levels, I decided to employ XIAO BLE in this wearable smartwatch project. To obtain the required measurements to train my model, I utilized a UV sensor (Grove) and a BMP180 precision sensor. Since the XIAO expansion board provides various prototyping options and built-in peripherals such as an SSD1306 OLED display and a MicroSD card module, I use the expansion board to make rigid connections between XIAO BLE and the sensors.

Since the expansion board supports reading and writing information from/to files on an SD card, I stored the collected data in a CSV file on the SD card to create a data set. In this regard, I was able to save data packets via XIAO BLE without requiring any additional procedures.

After completing my data set, I built my artificial neural network model (ANN) with Edge Impulse to make predictions on sun damage risk levels (classes) based on UV index, temperature, pressure, and altitude measurements. Since Edge Impulse is nearly compatible with all microcontrollers and development boards, I had not encountered any issues while uploading and running my model on XIAO BLE. As labels, I employed the empirically assigned sun damage risk classes for each data record while collecting data outdoors:

After training and testing my neural network model, I deployed and uploaded the model on XIAO BLE. Therefore, the smartwatch is capable of detecting precise sun damage risk levels (classes) by running the model independently. Also, after running the model successfully, I employed XIAO BLE to transmit (advertise) the prediction (detection) result and the recently collected data over BLE.

Then, I developed a complementing Android application from scratch to obtain the transmitted (advertised) information over BLE from the smartwatch so as to inform the user of potential sun damage risk.

Lastly, to make the smartwatch as sturdy and robust as possible while enduring harsh conditions outdoors, I designed an Ultimatrix-inspired smartwatch case with a sliding (removable) top cover (3D printable).

So, this is my project in a nutshell 😃

In the following steps, you can find more detailed information on coding, logging data on the SD card, transmitting data packets over BLE, building a neural network model with Edge Impulse, and running it on XIAO BLE.”

Link to article