Objective
The objective of this project is to provide an effective application for a Real-Time Health Monitoring and Tracking System. The system monitors the patient’s oxygen saturation content (SpO2) and sends a short message (SMS) to a mobile number with the following information:
- SpO2 Measurement
- Current GPS location of the patient
Materials
Hardware Tools
Tool | About | Purchase |
---|---|---|
| |
- Explorer 8 Development Board (Part Number: DM160228)
- PIC16F19175
- GSM-GPS Click: SIM808
- Heart rate click™: MAX30100
- GSM Antenna
- GPS Antenna
- Activated and Unlocked SIM card
- Nano to Micro SIM convertor
Software Tools
Tool | About | Installers |
Installation
Instructions |
||
---|---|---|---|---|---|
Windows | Linux | Mac OSX | |||
MPLAB® X
Integrated Development Environment |
| | | | |
![]() MPLAB® Code Configurator
Dynamic Code Generation |
| | |||
MPLAB® XC8
C Compiler |
| | | | |
Exercise Files
File | Download |
Installation
Instructions |
||
---|---|---|---|---|
Windows | Linux | Mac OSX | ||
Project and Source Files
|
| | | |
Connection Diagram
The Health Monitoring and Tracking System uses a PIC16F19175. The PIC16F19175 communicates with an SpO2/heart rate module through I²C.
The PIC16F19175 also communicates with the GSM-GPS module through a USART interface to read the patient’s current location. The PIC16F19175 then sends the measured SpO2 and location as an SMS to a phone number through GSM.
Jumper Configuration
Make sure the following jumpers are present on the Explorer 8 development board to ensure proper functionality:
- No need for any jumpers on components 1-3 in the image above.
- In component 4, configure the jumpers such that:
- J56: RB7 must be connected to the center pin to configure it as the microcontroller UART2 TX pin to the MCP2221 RX pin.
- No need for any jumpers on components 5-7 in the image above.
- In component 8, configure the jumpers as follows:
- J27: RB5 must be connected to the center pin to configure it as the microcontroller UART2 RX pin to the GSM-GPS module TX pin
- J44: RC6 must be connected to the center pin to configure it as the microcontroller UART1 TX pin to the GSM-GPS module RX pin
- No need for any jumpers on components 9-14 in the image above.
- In component 15, configure the jumpers such that:
- J30, J14: The board is supplied with 3.3 V.
- In component 16, configure the jumpers such that:
- J2: The board is supplied with 5 V power via the USB.
- In component 17, configure the jumpers such that:
- J51, J52: RB7 is connected to the center pin at J51 and RB6 is connected with the center pin at J52 to connect the PGD and PGC pins of the ICD to the PIC® MCU ICSPDAT and ICSPCLK, respectively for ICSP™.
- No need for any jumpers on component 18 in the image above.
- In component 19, configure the jumpers such that:
- J24: The two pins are connected to each other to supply a regulated 3.3 V output to the mikroBUS™.
- Hook the GSM-GPS module on J32 and the Heart Rate/SpO2 click on J35.
Procedure
The major steps to implement this project are as follows:
- Set up Project Recourses
- Set up the Heart Rate/SpO2 Modules
- Set up the EUSART
- Configure the Pin Manager
- Generate Code
- Add Functionality
- Program the Device
1
Create New Project
Create a new 'Standalone' project in MPLAB® X IDE for a PIC16F18875. If this is your first time using MPLAB X IDE, follow the instructions in the article, "Create a Standalone Project".
3
Set Up Project Resources
Click on 'System Module' in the 'Project Resources' tab.
The System section will appear.
To set the Oscillator configurations, follow these steps:
- Select 'EXTOSC' from the Oscillator Select drop-down menu.
- Select 'EC for 500 kHz to 8 MHz: PFM set to medium power' from the External Clock Select drop-down menu.
- Enter 4 MHz for External Clock.
- Select '4' from the Clock Divider drop-down menu.
- Check the 'Low-voltage Programming Enable' box to turn it on.
This will set the system clock at 1 MHz using the external oscillator.
5
Set Up Heart Rate/SpO2 click
The Heart Rate/SpO2 click needs to be set up. The heart rate module is shown in the MCC under 'Device Resources'. Choose 'Sensors' and then 'Heartrate' from the drop-down menu as shown below:
MikroElektronika's Heart Rate click sensor and its corresponding libraries are now added to the Project Resources. Select 'Heartrate' from the 'Project Resources' tab to set up the Heart Rate click.
Click on the 'Configuration' tab and select 'Pulse Oximeter Mode'. Set the number of samples to be taken as 100 SPS and the 'Pulse Width' to 1600 µs. IR and RED LED currents are programmable. IR and RED LED wavelengths vary depending on the set current values.
Set the 'IR LED Current' to 30.6 mA and 'RED LED Current' to 14.2 mA to get optimal value for the IR and RED values.
Under 'Interrupts', check the boxes for 'Heart Rate', 'Temperature', 'SPO2 Ready', and 'FIFO Buffer Almost Full'. Uncheck the 'Generate Example' box. The configuration for the Heart Rate board is shown below:
6
Set up the EUSART1
Under the 'Device Resources' tab of the MCC, select the 'EUSART1' peripheral.
The EUSART1 and its corresponding libraries are now added to the Project Resources. Click on the 'EUSART1' label under the 'Project Resources' tab to configure EUART1.
Set the EUSART baud rate to 9600. This is the default baud rate for the GSM-GPS module in asynchronous mode. Check the 'Enable EUSART Interrupts' box to indicate the end of the transmission. The configuration is shown below:
7
Set up the EUSART2
As a reference, we are going to set up EUSART2 to receive/transmit responses from GSM-GPS to a command terminal.
Under the 'Device Resources' tab, select the peripheral 'EUSART2'.
The EUSART2 and its corresponding libraries are now added to the Project Resources.
Click on the 'EUSART2' label under the 'Project Resources' tab to configure EUART2. Click on the 'Enable EUSART Interrupts' box to indicate end of transmission and reception. Configure the EUSART2 peripheral as shown below:
8
Configure the Pin Manager
There are multiple pins that need to be set in the Pin Manager. Enable the pins that are shown in the picture below:
The Grid View of the Pin Manager should look like the image above when completed.
Custom Name for Pins
Click on 'Pin Module' in the 'Project Resources' tab.
Rename RD7 as PWKEY. The PWKEY is the power key for the GSM-GPS module. To rename a pin, click on the 'Custom Name' for the pin and type in the new name as show below:
10
Adding Functionality
Download the project ZIP file, locate the SpO2_GPS_SMS.c and SpO2_GPS_SMS.h files and add them to your project folder.
Go back to MPLAB X IDE and right click on 'Source Files' in the 'Projects' tab.
Click on 'Add Existing Item' from the drop-down menu.
Choose SpO2_GPS_SMS.c from the working project folder and click on 'Select'.
The 'Projects' tab must look like the following picture after adding the file:
Now right click on 'Header Files' in the Project tab.
Click on 'Add Existing Item' from the drop-down menu.
Choose SpO2_GPS_SMS.h from the working project folder and click on 'Select'.
The 'Projects' tab must look like the following picture after adding the file:
11
Computing the SpO2 Value
The function COMPUTE_SpO2() computes the SpO2 value as follows:
- It checks for a minimum number of SpO2 samples received from the Pulse Oximeter.
- If the IR and RED values are greater than 1000, then the average values of RED and IR LED are computed. Else, the function resets the number of samples to zero.
- The SpO2 value is then calculated as shown below:
12
main.c
The main file needs modifications to incorporate the SpO2_GPS_SMS file. To add them, double click on the main.c file to open it up in the editor window.
The main.c file requires a few lines to be uncommented for the interrupts to work properly. In order for the interrupt to work, Global Interrupts and Peripheral Interrupts need to be enabled. MCC already has the control commands in the default main.c file, they are just commented out with two forward slashes (//). The forward slashes need to be removed to enable these lines of code.
To include the functionality defined for the Heart Rate/Pulse Oximeter and GSM-GPS module, the header file SpO2_GPS_SMS.h must be included in the main file. The following line is included before the main () function definition:
The Pulse Oximeter and the GSM-GPS module must be initialized. To initialize the pulse oximeter, call SpO2_Initialize (). To initialize the GSM-GPS module, call the GSM_GPS_Initialize () function.
13
Programming the Device
Make sure your development board is connected to power and that the project has the correct programming tool selected. Click on the Make and Program Device button. This will build the project and launch the programmer. In the Output window you should see a series of messages and if successful, it will end with a Programming/Verify complete message.
Results
Place the index finger over the Pulse Oximeter Sensor for six seconds for the system to take samples and compute SpO2. The SpO2 value and the current location of the patient is sent as an SMS to the desired phone number as shown below:
+CGPSINF: 32,000304.000,V,0000.0000,N,00000.0000,E,0.000,0.00,060180,,,N
OK
Your SPO2 99.562496 %
Table of Contents
|