Skip to main content

Healthcare Tracking System for Dementia Patients and Elderly (Part 2)

In the first part, I have talked about the Hexiwear (923-6084) platform and how we can detect the falling using gyroscope and accelerometer data. I also mentioned that Hexiwear supports mbed platform which makes programming so easy. In this section, I am going to activate the OLED screen to notify user and Bluetooth to inform the emergency service. Then, I will mention how to create an android app using Evothings and connect the smartphone to the Hexiwear.

Let's start with the OLED display. Hexiwear has a 1.1” full-colour OLED display. It can be programmed to inform the user. In order to use the OLED display, we need to add the Hexi_OLED_SSD1351.h library file and initiate the driver. The code below sets the text properties, background colour and text position. Once the template is set, we only need to change the text.

void initOLED()

{

char text[20]; /* Text Buffer */


/* Get OLED Class Default Text Properties */

oled_text_properties_t textProperties = {0};

oled.GetTextProperties(textProperties);

 /* Turn on the backlight of the OLED Display */

oled.DimScreenON();


/* Fills the screen with solid black */

oled.FillScreen(COLOR_BLACK);


/* Change font color to Blue */

textProperties.fontColor = COLOR_BLUE;

oled.SetTextProperties(textProperties);


/* Display Bluetooth Label at x=15,y=0 */

strcpy((char *) text,"DesignSpark");

oled.Label((uint8_t *)text,15,0);


 /* Display Text at (x=20,y=15) */

strcpy((char *) text,"HexiCare");

oled.Label((uint8_t *)text,20,15);



/* Change font color to blue */

textProperties.fontColor = COLOR_BLUE;

oled.SetTextProperties(textProperties);



/* Set text properties to white and right aligned for the dynamic text */

textProperties.fontColor = COLOR_WHITE;

textProperties.alignParam = OLED_TEXT_ALIGN_RIGHT;

oled.SetTextProperties(textProperties);

 }

In a similar manner to OLED, we can also add Bluetooth just adding ready libraries and have connectivity. Libraries make programming easy but mbed not only supports huge repositories of libraries but also it brings hardware abstraction. It is kind of remove the complexities of the dealing with the underlying hardware technology and make you focus on the software algorithms.

#include "Hexi_KW40Z.h" // BLE

...

KW40Z kw40z_device(PTE24, PTE25); // BLE (UART TX, UART RX)

...

int main()

{

...

Thread txThread; // Thread to handle sending BLE

...

}

...

void txTask(void)

{

while (true)

{

// Send alarm data

kw40z_device.SendFaintAlarm(faintAlarmBLE);

Thread::wait(1000);

}

}

The previous faint detection algorithm changes the faintAlarmBLE variable. If faint is detected, faintAlarmBLE becomes one and it is transmitted to the phone every second. I prefer to send the data repeatedly to ensure it is transmitted. I know that this is a power hungry method but I haven't designed the whole system and there is no recovery in the transmission so I want to be sure data is transmitted in all cases.

After adding the BLE feature, the next thing is to create an Android App. I haven't written an Android app before so I prefer hybrid systems which provide flexibility of creating mobile apps using HTML and JavaScript. Evothings is one of the hybrid tools. I chose this because there is a webinar which explains how to create apps for Hexiwear.


 

It is a great tool you don't need to learn native Android but there are some problems. Evothings is a kind of cloud base, and I had to wait for the servers to be updated before starting the coding. If you have a deadline, it may affect your schedule. Second, Evothings doesn't have a built-in SMS option. I was looking to add this functionality but the program stoped working.

Luckily, my app is almost finished, I just need to add SMS or calling option. Although Evothings doesn't have a plugin for SMS, it supports Cordova plug-in. In this link, it describes how to add the SMS feature to the Evothings Studio. If you have experience with native mobile development, it might be better to write the app there. If you want to use the one I modified, it is also on the GitHub.

Mehmet is an Embedded Systems Engineer and he loves to play with new boards(toys). He is looking for PhD opportunities. Lately, he has created a website mehmetbozdal.com where he shares his knowledge and postgraduate experience.
DesignSpark Electrical Logolinkedin